lazyad 0.0.57__py3-none-any.whl → 0.0.78__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,8 @@ default_headers = {
19
19
  "TE": "trailers",
20
20
  "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Firefox/105.0",
21
21
  }
22
+ default_host = "cli2.mobgi.com"
23
+ hosts = ["cli1.mobgi.com", "cli2.mobgi.com"]
22
24
 
23
25
 
24
26
  def get_media_account(
@@ -26,7 +28,8 @@ def get_media_account(
26
28
  cookie: str = None,
27
29
  page: int = 1,
28
30
  page_size: int = 20,
29
- total_count: int = 0
31
+ total_count: int = 0,
32
+ host: str = default_host,
30
33
  ):
31
34
  """
32
35
  获取 推广-账户管理下的账户列表
@@ -38,7 +41,7 @@ def get_media_account(
38
41
  :return:
39
42
  """
40
43
 
41
- url = 'https://cli2.mobgi.com/Media/Account/getList'
44
+ url = f'https://{host}/Media/Account/getList'
42
45
  data = {
43
46
  "media_type": media_type,
44
47
  "advertiser_type": "1",
@@ -73,6 +76,8 @@ def get_ad_report(
73
76
  conditions: dict = None,
74
77
  kpis: list = None,
75
78
  relate_dims: list = None,
79
+ host: str = default_host,
80
+ db_type: str = "doris"
76
81
  ):
77
82
  """
78
83
  报表-广告报表
@@ -96,7 +101,7 @@ def get_ad_report(
96
101
  start_date = lazytime.get_date_string(days=0)
97
102
  if not end_date:
98
103
  end_date = lazytime.get_date_string(days=0)
99
- url = "https://cli2.mobgi.com/ReportV23/AdReport/getReport"
104
+ url = f"https://{host}/ReportV23/AdReport/getReport"
100
105
  data = {
101
106
  "start_date": start_date,
102
107
  "end_date": end_date,
@@ -108,6 +113,7 @@ def get_ad_report(
108
113
  "data_dim": data_dim,
109
114
  "sort_field": sort_field,
110
115
  "sort_direction": sort_direction,
116
+ "db_type": db_type
111
117
  }
112
118
  if media_type == "baidu":
113
119
  if not conditions:
@@ -130,7 +136,7 @@ def get_ad_report(
130
136
  if not relate_dims:
131
137
  relate_dims = ["advertiser_id"]
132
138
 
133
- elif media_type == "gdt_new":
139
+ elif media_type in ["gdt_new", "gdt_upgrade"]:
134
140
  if not conditions:
135
141
  conditions = {
136
142
  "keyword": "",
@@ -187,8 +193,8 @@ def get_ad_report(
187
193
  relate_dims = ["advertiser_id"]
188
194
 
189
195
  else:
190
- showlog.warning("未知媒体类型")
191
- return
196
+ showlog.warning("未知媒体类型,不指定默认参数")
197
+ pass
192
198
 
193
199
  headers = copy.deepcopy(default_headers)
194
200
  headers["Cookie"] = cookie
@@ -219,7 +225,9 @@ def get_plan_list(
219
225
  cdt_start_date: str = None,
220
226
  cdt_end_date: str = None,
221
227
  kpis: list = None,
222
- req_source: str = None
228
+ req_source: str = None,
229
+ host: str = default_host,
230
+ base_infos: list = None
223
231
  ):
224
232
  """
225
233
  获取推广计划
@@ -249,6 +257,23 @@ def get_plan_list(
249
257
  cdt_start_date = lazytime.get_date_string(days=-365)
250
258
  if not cdt_end_date:
251
259
  cdt_end_date = lazytime.get_date_string(days=0)
260
+ if not base_infos:
261
+ base_infos = [
262
+ "adgroup_name",
263
+ "adgroup_id",
264
+ "advertiser_id",
265
+ "company",
266
+ "optimization_goal",
267
+ "system_status",
268
+ "bid_amount",
269
+ "deep_conversion_worth_roi",
270
+ "created_time",
271
+ "user_name",
272
+ "daily_budget",
273
+ "bid_mode",
274
+ "deep_conversion_spec",
275
+ "begin_date"
276
+ ]
252
277
  data = {
253
278
  "start_date": start_date,
254
279
  "end_date": end_date,
@@ -256,10 +281,11 @@ def get_plan_list(
256
281
  "page_size": page_size,
257
282
  "sort_field": sort_field,
258
283
  "sort_direction": sort_direction,
259
- "data_type": data_type
284
+ "data_type": data_type,
285
+ "base_infos": base_infos
260
286
  }
261
287
  if media_type == "baidu":
262
- url = "https://cli2.mobgi.com/Baidu/Campaign/getList"
288
+ url = f"https://{host}/Baidu/Campaign/getList"
263
289
  if not conditions:
264
290
  conditions = {
265
291
  "cl_project_id": [],
@@ -275,8 +301,8 @@ def get_plan_list(
275
301
  if media_account_id:
276
302
  conditions["media_account_id"] = [media_account_id]
277
303
  data["conditions"] = json.dumps(conditions)
278
- elif media_type == "gdt_new":
279
- url = "https://cli2.mobgi.com/Gdt/MainList/getList"
304
+ elif media_type in ["gdt_new"]:
305
+ url = f"https://{host}/Gdt/MainList/getList"
280
306
  if not conditions:
281
307
  conditions = {
282
308
  "is_deleted": "",
@@ -331,10 +357,12 @@ def update_ad_batch(
331
357
  campaign_feed_id: int = None,
332
358
  campaign_feed_ids: list = None,
333
359
 
334
- operate: str = "disable"
360
+ operate: str = "disable",
361
+ host: str = default_host
335
362
  ):
336
363
  """
337
364
  暂停广告
365
+ : param operate: 操作:暂停:DISABLE,删除:DELETE
338
366
  :return:
339
367
  """
340
368
  headers = copy.deepcopy(default_headers)
@@ -348,12 +376,12 @@ def update_ad_batch(
348
376
  "field": operate
349
377
  }
350
378
  if adgroup_id or adgroup_ids:
351
- url = "https://cli2.mobgi.com/Gdt/MainList/updateAdGroupBatch"
379
+ url = f"https://{host}/Gdt/MainList/updateAdGroupBatch"
352
380
  if not adgroup_ids:
353
381
  adgroup_ids = [adgroup_id]
354
382
  post_data["adgroup_ids"] = adgroup_ids
355
383
  elif campaign_id or campaign_ids:
356
- url = "https://cli2.mobgi.com/Gdt/MainList/updateCampaignBatch"
384
+ url = f"https://{host}/Gdt/MainList/updateCampaignBatch"
357
385
  if campaign_id and not campaign_ids:
358
386
  campaign_ids = [campaign_id]
359
387
  post_data["campaign_ids"] = campaign_ids
@@ -362,7 +390,7 @@ def update_ad_batch(
362
390
 
363
391
  elif media_type == "baidu":
364
392
  if adgroup_feed_id or adgroup_feed_ids:
365
- url = "https://cli2.mobgi.com/Baidu/AdGroup/batchUpdate"
393
+ url = f"https://{host}/Baidu/AdGroup/batchUpdate"
366
394
  if adgroup_feed_id and not adgroup_feed_ids:
367
395
  adgroup_feed_ids = [adgroup_feed_id]
368
396
  post_data = {
@@ -370,7 +398,7 @@ def update_ad_batch(
370
398
  "opt_status": operate
371
399
  }
372
400
  elif campaign_feed_id or campaign_feed_ids:
373
- url = "https://cli2.mobgi.com/Baidu/Campaign/batchUpdate"
401
+ url = f"https://{host}/Baidu/Campaign/batchUpdate"
374
402
  if campaign_feed_id and not campaign_feed_ids:
375
403
  campaign_feed_ids = [campaign_feed_id]
376
404
  post_data = {
@@ -380,7 +408,7 @@ def update_ad_batch(
380
408
  else:
381
409
  return
382
410
  elif media_type == "toutiao_upgrade":
383
- url = "https://cli2.mobgi.com/Toutiao/Promotion/updateStatus"
411
+ url = f"https://{host}/Toutiao/Promotion/updateStatus"
384
412
  if promotion_id and not promotion_ids:
385
413
  promotion_ids = [promotion_id]
386
414
  post_data = {
@@ -445,7 +473,8 @@ def get_material_report(
445
473
  data_type: str = "list",
446
474
  sort_direction: str = "desc",
447
475
  conditions: dict = None,
448
- relate_dims: list = None
476
+ relate_dims: list = None,
477
+ host: str = "cli2.mobgi.com",
449
478
  ):
450
479
  """
451
480
  报表-素材报表
@@ -454,22 +483,26 @@ def get_material_report(
454
483
  :param end_date:
455
484
  :param page:
456
485
  :param page_size:
457
- :param media_type:媒体:gdt_new|广点通(新指标体系),toutiao_upgrade|今日头条2.0aggregate|不限,baidu:百度信息流
458
- :param data_dim:
486
+ :param media_type:媒体:gdt_new|广点通(新指标体系),toutiao_upgrade|今日头条2.0/巨量广告,aggregate|不限,baidu:百度信息流
487
+ :param data_dim: 数据维度:素材
459
488
  :param data_type:
460
- :param sort_direction:
461
- :param sort_field:
489
+ :param sort_direction: 排序
490
+ :param sort_field: 排序字段,stat_cost:消耗
462
491
  :param time_dim: 时间维度的数据汇总方式,days:分日,sum:汇总
463
492
  :param conditions:
464
493
  :param kpis:
465
- :param relate_dims:
494
+ :param relate_dims:关联维度,
495
+ material_create_time:上传时间 --> material_create_time
496
+ owner_user_id:优化师 --> user_name
497
+ creative_user_id:创意人 --> creative_user
498
+ :param host:
466
499
  :return:
467
500
  """
468
501
  if not start_date:
469
502
  start_date = lazytime.get_date_string(days=0)
470
503
  if not end_date:
471
504
  end_date = lazytime.get_date_string(days=0)
472
- url = "https://cli2.mobgi.com/ReportV23/MaterialReport/getReport"
505
+ url = f"https://{host}/ReportV23/MaterialReport/getReport"
473
506
  data = {
474
507
  "time_dim": time_dim,
475
508
  "media_type": media_type,
@@ -572,7 +605,8 @@ def get_account_report(
572
605
  conditions: dict = None,
573
606
  kpis: list = None,
574
607
  base_infos: list = None,
575
- time_line: str = "REPORTING_TIME"
608
+ time_line: str = "REPORTING_TIME",
609
+ host: str = "cli2.mobgi.com",
576
610
  ):
577
611
  """
578
612
  推广-广告管理-媒体账户
@@ -593,7 +627,7 @@ def get_account_report(
593
627
  start_date = lazytime.get_date_string(days=0)
594
628
  if not end_date:
595
629
  end_date = lazytime.get_date_string(days=0)
596
- url = "https://cli2.mobgi.com/MainPanelReport/AccountReport/getReport"
630
+ url = f"https://{host}/MainPanelReport/AccountReport/getReport"
597
631
  data = {
598
632
  "data_type": data_type,
599
633
  "media_type": media_type,
@@ -840,7 +874,7 @@ def get_project_report(
840
874
  def get_material_detail(
841
875
  cookie: str,
842
876
  material_id: str,
843
- host: str = None
877
+ host: str = default_host
844
878
  ):
845
879
  """
846
880
  获取素材详情
@@ -849,7 +883,7 @@ def get_material_detail(
849
883
  :param host:
850
884
  :return:
851
885
  """
852
- url = "https://cli2.mobgi.com/Material/Manage/detail"
886
+ url = f"https://{host}/Material/Manage/detail"
853
887
  data = {
854
888
  "material_id": material_id
855
889
  }
@@ -863,3 +897,537 @@ def get_material_detail(
863
897
  params=data,
864
898
  headers=headers
865
899
  )
900
+
901
+
902
+ def deactivate_material(
903
+ cookie: str,
904
+ is_deactivate: int,
905
+ material_id: str = None,
906
+ material_ids: list = None,
907
+ host: str = default_host
908
+ ):
909
+ """
910
+ 启用/禁用素材
911
+ :param cookie:
912
+ :param is_deactivate: 0:启用,1:禁用
913
+ :param material_id: 素材ID
914
+ :param material_ids: [素材ID]
915
+ :param host:
916
+ :return:
917
+ """
918
+ url = f"https://{host}/Material/Manage/deactivate"
919
+ if not material_ids:
920
+ material_ids = [material_id]
921
+ data = {
922
+ "material_ids": material_ids,
923
+ "is_deactivate": is_deactivate
924
+ }
925
+ headers = copy.deepcopy(default_headers)
926
+ headers["Cookie"] = cookie
927
+ if host:
928
+ headers["Host"] = host
929
+ return lazyrequests.lazy_requests(
930
+ method="POST",
931
+ url=url,
932
+ json=data,
933
+ headers=headers
934
+ )
935
+
936
+
937
+ def get_toutiao_promotion(
938
+ cookie: str,
939
+ user_id: list = None,
940
+ material_id: str = None,
941
+ cdt_start_date: str = None,
942
+ cdt_end_date: str = None,
943
+ start_date: str = None,
944
+ end_date: str = None,
945
+ host: str = default_host,
946
+ page: int = 1,
947
+ page_size: int = 20,
948
+ sort_field: str = "create_time",
949
+ sort_direction: str = "desc",
950
+ data_type: str = "list"
951
+ ):
952
+ """
953
+ 推广-巨量广告-广告 查询
954
+ :param cookie:
955
+ :param material_id: 素材ID
956
+ :param cdt_start_date: 创建时间,例如:2025-07-05 00:00:00
957
+ :param cdt_end_date: 创建时间,例如:2025-08-04 23:59:59
958
+ :param start_date: 数据日期,例如:2025-08-04
959
+ :param end_date: 数据日期,例如:2025-08-04
960
+ :param host:
961
+ :return:
962
+ """
963
+ url = f"https://{host}/Toutiao/Promotion/getList"
964
+ if not user_id:
965
+ user_id = []
966
+ conditions = {
967
+ "search_field":"promotion_name",
968
+ "search_keyword":"",
969
+ "cl_project_id":[],
970
+ "cl_app_id":[],
971
+ "user_id": user_id,
972
+ "media_account_id":[],
973
+ "companys":[],
974
+ "landing_type":"",
975
+ "delivery_mode":"",
976
+ "project_id":[],
977
+ "status_first":"",
978
+ "scene_type":[],
979
+ "strategy_id":[],
980
+ "ad_type":"",
981
+ "learning_phase":[],
982
+ "star_delivery_type":"",
983
+ "star_task_id":"",
984
+ "app_type":"",
985
+ "external_action":[],
986
+ "deep_external_action":[],
987
+ "deep_bid_type":[],
988
+ "material_id": material_id,
989
+ "search_type":"like",
990
+ "combinatorial_id":"",
991
+ "status":"",
992
+ "status_second":"",
993
+ "cdt_start_date": cdt_start_date,
994
+ "cdt_end_date": cdt_end_date
995
+ }
996
+ data = {
997
+ "conditions": json.dumps(conditions),
998
+ "start_date": start_date,
999
+ "end_date": end_date,
1000
+ "page": page,
1001
+ "page_size": page_size,
1002
+ # "total_count": 1,
1003
+ # "total_page": 1,
1004
+ "sort_field": sort_field,
1005
+ "sort_direction": sort_direction,
1006
+ "data_type": data_type
1007
+ }
1008
+ headers = copy.deepcopy(default_headers)
1009
+ headers["Cookie"] = cookie
1010
+ if host:
1011
+ headers["Host"] = host
1012
+ return lazyrequests.lazy_requests(
1013
+ method="POST",
1014
+ url=url,
1015
+ json=data,
1016
+ headers=headers
1017
+ )
1018
+
1019
+
1020
+ def MainPanelReport_AdReport_getReport(
1021
+ cookie: str,
1022
+ media_type: str,
1023
+ sort_field: str,
1024
+ media_account_id: int = None,
1025
+ page: int = 1,
1026
+ page_size: int = 20,
1027
+ start_date: str = None,
1028
+ end_date: str = None,
1029
+ sort_direction: str = "desc",
1030
+ data_type: str = "list",
1031
+ conditions: dict = None,
1032
+ cdt_start_date: str = None,
1033
+ cdt_end_date: str = None,
1034
+ kpis: list = None,
1035
+ req_source: str = None,
1036
+
1037
+ base_infos: list = None,
1038
+ search_field: str = None,
1039
+ search_keyword: str = None,
1040
+ time_line: str = None,
1041
+
1042
+ scheme: str = "https",
1043
+ host: str = default_host,
1044
+ filename: str = "/MainPanelReport/AdReport/getReport"
1045
+ ):
1046
+ """
1047
+ 推广-广告管理-广告
1048
+ :param cookie:
1049
+ :param media_type:
1050
+ :param media_account_id:
1051
+ :param sort_field: 排序字段
1052
+ :param page:
1053
+ :param page_size:
1054
+ :param start_date: 数据开始日期
1055
+ :param end_date: 数据结束日期
1056
+ :param sort_direction: 排序方式,desc:降序
1057
+ :param data_type:
1058
+ :param conditions: 搜索条件
1059
+ :param cdt_start_date: 创建开始时间
1060
+ :param cdt_end_date: 创建结束时间
1061
+ :param kpis:
1062
+ :param req_source: 腾讯需要的参数
1063
+ :return:
1064
+ """
1065
+ url = f"{scheme}://{host}{filename}"
1066
+ if not start_date:
1067
+ start_date = lazytime.get_date_string(days=0)
1068
+ if not end_date:
1069
+ end_date = lazytime.get_date_string(days=0)
1070
+ if not cdt_start_date:
1071
+ cdt_start_date = lazytime.get_date_string(days=-365)
1072
+ if not cdt_end_date:
1073
+ cdt_end_date = lazytime.get_date_string(days=0)
1074
+ if not base_infos:
1075
+ base_infos = [
1076
+ "adgroup_name",
1077
+ "adgroup_id",
1078
+ "advertiser_id",
1079
+ "company",
1080
+ "optimization_goal",
1081
+ "system_status",
1082
+ "bid_amount",
1083
+ "deep_conversion_worth_roi",
1084
+ "created_time",
1085
+ "user_name",
1086
+ "daily_budget",
1087
+ "bid_mode",
1088
+ "deep_conversion_spec",
1089
+ "begin_date"
1090
+ ]
1091
+
1092
+ data = dict()
1093
+
1094
+ # 默认参数
1095
+ if base_infos:
1096
+ data["base_infos"] = base_infos
1097
+ if conditions:
1098
+ data["conditions"] = conditions
1099
+ if data_type:
1100
+ data["data_type"] = data_type
1101
+ if end_date:
1102
+ data["end_date"] = end_date
1103
+ if kpis:
1104
+ data["kpis"] = kpis
1105
+ if media_type:
1106
+ data["media_type"] = media_type
1107
+ if page:
1108
+ data["page"] = page
1109
+ if page_size:
1110
+ data["page_size"] = page_size
1111
+ if sort_direction:
1112
+ data["sort_direction"] = sort_direction
1113
+ if sort_field:
1114
+ data["sort_field"] = sort_field
1115
+ if start_date:
1116
+ data["start_date"] = start_date
1117
+ if time_line:
1118
+ data["time_line"] = time_line
1119
+ if req_source:
1120
+ data["req_source"] = req_source
1121
+
1122
+ if media_type == "baidu":
1123
+ if not conditions:
1124
+ conditions = {
1125
+ "cl_project_id": [],
1126
+ "optimize_user_id": [],
1127
+ "media_account_id": [],
1128
+ "extension_subject": [],
1129
+ "status": "",
1130
+ "keyword": "",
1131
+ "companys": [],
1132
+ "cdt_start_date": f"{cdt_start_date} 00:00:00",
1133
+ "cdt_end_date": f"{cdt_end_date} 23:59:59"
1134
+ }
1135
+ if media_account_id:
1136
+ conditions["media_account_id"] = [media_account_id]
1137
+ data["conditions"] = json.dumps(conditions)
1138
+
1139
+ elif media_type in ["gdt_new", "gdt_upgrade"]:
1140
+ if not time_line:
1141
+ time_line = "REPORTING_TIME"
1142
+ if not conditions:
1143
+ conditions = {
1144
+ "is_deleted": "",
1145
+ "auto_acquisition_status": [],
1146
+ "combinatorial_id": [],
1147
+ "companys": [],
1148
+ "configured_status": ["STATUS_NO_DELETED"], # 所有未删除
1149
+ "created_time": [cdt_start_date, cdt_end_date],
1150
+ "last_modified_time": [],
1151
+ "media_project_id": [],
1152
+ "owner_user_id": [],
1153
+ "search_field": search_field,
1154
+ "search_keyword": search_keyword,
1155
+ "system_status": [],
1156
+ "time_line": time_line,
1157
+ }
1158
+ data["conditions"] = json.dumps(conditions)
1159
+ if time_line:
1160
+ data["time_line"] = time_line
1161
+ else:
1162
+ pass
1163
+ headers = copy.deepcopy(default_headers)
1164
+ headers["Cookie"] = cookie
1165
+ return lazyrequests.lazy_requests(
1166
+ method="POST",
1167
+ url=url,
1168
+ json=data,
1169
+ headers=headers
1170
+ )
1171
+
1172
+
1173
+ def MainPanelReport_AccountReport_getReport(
1174
+ cookie: str,
1175
+ media_type: str,
1176
+ sort_field: str,
1177
+ media_account_id: int = None,
1178
+ page: int = 1,
1179
+ page_size: int = 20,
1180
+ start_date: str = None,
1181
+ end_date: str = None,
1182
+ sort_direction: str = "desc",
1183
+ data_type: str = "list",
1184
+ conditions: dict = None,
1185
+ cdt_start_date: str = None,
1186
+ cdt_end_date: str = None,
1187
+ kpis: list = None,
1188
+ req_source: str = None,
1189
+
1190
+ base_infos: list = None,
1191
+ search_field: str = None,
1192
+ search_keyword: str = None,
1193
+ time_line: str = None,
1194
+
1195
+ scheme: str = "https",
1196
+ host: str = default_host,
1197
+ filename: str = "/MainPanelReport/AccountReport/getReport"
1198
+ ):
1199
+ """
1200
+ 推广-广告管理-账户
1201
+ :param cookie:
1202
+ :param media_type:
1203
+ :param media_account_id:
1204
+ :param sort_field: 排序字段
1205
+ :param page:
1206
+ :param page_size:
1207
+ :param start_date: 数据开始日期
1208
+ :param end_date: 数据结束日期
1209
+ :param sort_direction: 排序方式,desc:降序
1210
+ :param data_type:
1211
+ :param conditions: 搜索条件
1212
+ :param cdt_start_date: 创建开始时间
1213
+ :param cdt_end_date: 创建结束时间
1214
+ :param kpis:
1215
+ :param req_source: 腾讯需要的参数
1216
+ :return:
1217
+ """
1218
+ url = f"{scheme}://{host}{filename}"
1219
+ data = dict()
1220
+
1221
+ # 默认参数
1222
+ if base_infos:
1223
+ data["base_infos"] = base_infos
1224
+ if conditions:
1225
+ data["conditions"] = conditions
1226
+ if data_type:
1227
+ data["data_type"] = data_type
1228
+ if end_date:
1229
+ data["end_date"] = end_date
1230
+ if kpis:
1231
+ data["kpis"] = kpis
1232
+ if media_type:
1233
+ data["media_type"] = media_type
1234
+ if page:
1235
+ data["page"] = page
1236
+ if page_size:
1237
+ data["page_size"] = page_size
1238
+ if sort_direction:
1239
+ data["sort_direction"] = sort_direction
1240
+ if sort_field:
1241
+ data["sort_field"] = sort_field
1242
+ if start_date:
1243
+ data["start_date"] = start_date
1244
+ if time_line:
1245
+ data["time_line"] = time_line
1246
+ if req_source:
1247
+ data["req_source"] = req_source
1248
+
1249
+ headers = copy.deepcopy(default_headers)
1250
+ headers["Cookie"] = cookie
1251
+ return lazyrequests.lazy_requests(
1252
+ method="POST",
1253
+ url=url,
1254
+ json=data,
1255
+ headers=headers
1256
+ )
1257
+
1258
+
1259
+ def Advertiser_getRealAdvertiserData(
1260
+ cookie: str,
1261
+ start_date: str = None,
1262
+ end_date: str = None,
1263
+ media_account_ids: list = None,
1264
+ conditions: str = None,
1265
+ scheme: str = "https",
1266
+ host: str = default_host,
1267
+ filename: str = "/Toutiao/Advertiser/getRealAdvertiserData"
1268
+ ):
1269
+ """
1270
+ 推广-广告管理-广告 获取最新的广告数据
1271
+ :param cookie:
1272
+ :param start_date: 数据开始日期
1273
+ :param end_date: 数据结束日期
1274
+ :return:
1275
+ """
1276
+ url = f"{scheme}://{host}{filename}"
1277
+ if not start_date:
1278
+ start_date = lazytime.get_date_string(days=0)
1279
+ if not end_date:
1280
+ end_date = lazytime.get_date_string(days=0)
1281
+
1282
+ if not conditions and media_account_ids:
1283
+ conditions_list = list()
1284
+ for each_media_account_id in media_account_ids:
1285
+ conditions_list.append({"media_account_id": str(each_media_account_id)})
1286
+ conditions = json.dumps(conditions_list)
1287
+ data = {
1288
+ "conditions": conditions,
1289
+ "start_date": start_date,
1290
+ "end_date": end_date
1291
+ }
1292
+ headers = copy.deepcopy(default_headers)
1293
+ headers["Cookie"] = cookie
1294
+ return lazyrequests.lazy_requests(
1295
+ method="POST",
1296
+ url=url,
1297
+ json=data,
1298
+ headers=headers
1299
+ )
1300
+
1301
+
1302
+ def Project_getList(
1303
+ cookie: str,
1304
+ sort_field: str,
1305
+ start_date: str = None,
1306
+ end_date: str = None,
1307
+ media_account_ids: list = None,
1308
+ conditions: str = None,
1309
+ data_type: str = "list",
1310
+ page: int = 1,
1311
+ page_size: int = 20,
1312
+ sort_direction: str = "desc",
1313
+ total_count: int = None,
1314
+ total_page: int = None,
1315
+
1316
+ scheme: str = "https",
1317
+ host: str = default_host,
1318
+ filename: str = "/Toutiao/Project/getList"
1319
+ ):
1320
+ """
1321
+ 推广-广告管理-项目
1322
+ :param cookie:
1323
+ :param start_date: 数据开始日期
1324
+ :param end_date: 数据结束日期
1325
+ :return:
1326
+ """
1327
+ url = f"{scheme}://{host}{filename}"
1328
+ if not start_date:
1329
+ start_date = lazytime.get_date_string(days=0)
1330
+ if not end_date:
1331
+ end_date = lazytime.get_date_string(days=0)
1332
+
1333
+ if not conditions and media_account_ids:
1334
+ conditions_list = list()
1335
+ for each_media_account_id in media_account_ids:
1336
+ conditions_list.append({"media_account_id": str(each_media_account_id)})
1337
+ conditions = json.dumps(conditions_list)
1338
+
1339
+ data = dict()
1340
+ if conditions:
1341
+ data["conditions"] = conditions
1342
+ if data_type:
1343
+ data["data_type"] = data_type
1344
+ if start_date:
1345
+ data["start_date"] = start_date
1346
+ if end_date:
1347
+ data["end_date"] = end_date
1348
+ if page:
1349
+ data["page"] = page
1350
+ if page_size:
1351
+ data["page_size"] = page_size
1352
+ if sort_direction:
1353
+ data["sort_direction"] = sort_direction
1354
+ if sort_field:
1355
+ data["sort_field"] = sort_field
1356
+ if total_count:
1357
+ data["total_count"] = total_count
1358
+ if total_page:
1359
+ data["total_page"] = total_page
1360
+
1361
+ headers = copy.deepcopy(default_headers)
1362
+ headers["Cookie"] = cookie
1363
+ return lazyrequests.lazy_requests(
1364
+ method="POST",
1365
+ url=url,
1366
+ json=data,
1367
+ headers=headers
1368
+ )
1369
+
1370
+
1371
+ def Project_updateStatus(
1372
+ cookie: str,
1373
+ opt_status: str,
1374
+ project_ids: list = None,
1375
+ time: str = None,
1376
+
1377
+ scheme: str = "https",
1378
+ host: str = default_host,
1379
+ filename: str = "/Toutiao/Project/updateStatus"
1380
+ ):
1381
+ """
1382
+ 推广-广告管理-项目 操作
1383
+ :param cookie:
1384
+ :param opt_status: 暂停:DISABLE,删除:DELETE
1385
+ :param start_date: 数据开始日期
1386
+ :param end_date: 数据结束日期
1387
+ :return:
1388
+ """
1389
+ url = f"{scheme}://{host}{filename}"
1390
+
1391
+ data = dict()
1392
+ if opt_status:
1393
+ data["opt_status"] = opt_status
1394
+ if project_ids:
1395
+ data["project_ids"] = project_ids
1396
+ if time:
1397
+ data["time"] = time
1398
+ headers = copy.deepcopy(default_headers)
1399
+ headers["Cookie"] = cookie
1400
+ return lazyrequests.lazy_requests(
1401
+ method="POST",
1402
+ url=url,
1403
+ json=data,
1404
+ headers=headers
1405
+ )
1406
+
1407
+
1408
+ def getTaskResult(
1409
+ cookie: str,
1410
+ batch_id: str = None,
1411
+
1412
+ scheme: str = "https",
1413
+ host: str = default_host,
1414
+ filename: str = "/Toutiao/Tools/getTaskResult"
1415
+ ):
1416
+ """
1417
+ 获取任务结果
1418
+ :param cookie:
1419
+ :param batch_id:
1420
+ :return:
1421
+ """
1422
+ url = f"{scheme}://{host}{filename}"
1423
+ data = dict()
1424
+ if batch_id:
1425
+ data["batch_id"] = batch_id
1426
+ headers = copy.deepcopy(default_headers)
1427
+ headers["Cookie"] = cookie
1428
+ return lazyrequests.lazy_requests(
1429
+ method="POST",
1430
+ url=url,
1431
+ json=data,
1432
+ headers=headers
1433
+ )
@@ -284,6 +284,7 @@ def performance(
284
284
  timeout=timeout
285
285
  )
286
286
 
287
+
287
288
  def sanitize_entities(
288
289
  xml_content
289
290
  ):
@@ -319,3 +320,196 @@ def xml_to_dict(xml_str):
319
320
  for row in rows[1:]
320
321
  ]
321
322
  return data_list
323
+
324
+
325
+ def history(
326
+ cookie: str,
327
+ page: int = 1,
328
+ page_size: int = 50,
329
+ objective_type: str = "",
330
+ objective: list = None,
331
+ operator: list = None,
332
+ operation: list = None,
333
+ feature: list = None,
334
+
335
+ start_time: str = None,
336
+ end_time: str = None,
337
+ timezone: int = 8,
338
+ ):
339
+ """
340
+ 获取 操作日志
341
+ 注意:开始时间和结束时间如果为相同时间则无法获取数据
342
+ 需要登录:{'code': 400, 'msg': 'Please login first', 'data': None}
343
+ 验证成功:{'code': 200, 'msg': 'success', 'data': {}
344
+ :param timezone: 时区,默认:UTC+8:8
345
+ :param start_time: 开始时间,默认:days=-7,例如:2025-08-05 00:00:00
346
+ :param end_time: 结束时间,默认:days=1,例如:2025-08-05 00:00:00
347
+ :param objective_type: 查询类型,全部:"",广告:adv_campaign,广告单元:adv_offer
348
+ """
349
+ scheme = "https"
350
+ host = "ss-api.mintegral.com"
351
+ filename = "/api/v1/history/index"
352
+ if not start_time:
353
+ start_time = lazytime.get_datetime_relative(days=-7)
354
+ if not end_time:
355
+ end_time = lazytime.get_datetime_relative(days=1)
356
+ if not objective:
357
+ objective = []
358
+ if not operator:
359
+ operator = []
360
+ if not operation:
361
+ operation = []
362
+ if not feature:
363
+ feature = []
364
+ data = {
365
+ "limit": page_size,
366
+ "page": page,
367
+ "timezone": str(timezone),
368
+ "start_time": start_time,
369
+ "end_time": end_time,
370
+ "objective_type": objective_type,
371
+ "objective": objective,
372
+ "operator": operator,
373
+ "operation": operation,
374
+ "feature": feature
375
+ }
376
+ url = f"{scheme}://{host}{filename}"
377
+ headers = copy.deepcopy(default_headers)
378
+ headers["Cookie"] = cookie
379
+ return lazyrequests.lazy_requests(
380
+ method="POST",
381
+ json=data,
382
+ url=url,
383
+ headers=headers
384
+ )
385
+
386
+
387
+ def reports(
388
+ cookie: str,
389
+ url_filename: str,
390
+ total: bool = False,
391
+
392
+ page: int = 1,
393
+ page_size: int = 50,
394
+ timezone: int = 8,
395
+ start_time: str = None,
396
+ end_time: str = None,
397
+ show_calendar_day: int = 2,
398
+ breakdowns: list = None,
399
+ metrics: list = None,
400
+ sort: str = None,
401
+ order: str = "DESC",
402
+ adv_campaign_id: int = None,
403
+ promote_country_code: str = None,
404
+ timeout: int = default_timeout,
405
+ stream: bool = False,
406
+
407
+ ):
408
+ """
409
+ 获取 报表中心报表
410
+ 需要登录:{'code': 400, 'msg': 'Please login first', 'data': None}
411
+ 验证成功:{'code': 200, 'msg': 'success', 'data': {}
412
+ :param cookie: 已经登陆的cookie
413
+ :param url_filename: 具体地址,例如:/api/v1/reports/creative
414
+
415
+ :param total: 为True时获取总记录数
416
+ :param export: 为True时下载表格文件
417
+ :param page: 页码
418
+ :param page_size: 每页数量
419
+ :param timezone: 时区
420
+ :param start_time: 开始日期,例如:2025-03-05
421
+ :param end_time: 结束日期,例如:2025-03-05
422
+ :param show_calendar_day:
423
+ :param breakdowns: 分组依据(高级选项):[]
424
+ (date:天, timestamp:小时,week:周,month:月)
425
+ adv_offer_id:广告单元,
426
+ bid_type:Bid Type,
427
+ country_code:国家或地区
428
+ app:应用id(子渠道)
429
+ package_name:包名(子渠道)
430
+ app_name:应用名称(子渠道)
431
+ adv_campaign_id:广告
432
+ received_price:单价
433
+ ad_type:广告类型
434
+ :param metrics: 展示数据列(高级选项):[]
435
+ "adv_impression", # 展示
436
+ "adv_click", # 点击
437
+ "adv_install", # 转化
438
+ "ecpm", # eCPM
439
+ "ecpc", # CPC
440
+ "ecpi", # eCPI
441
+ "ctr", # CTR
442
+ "ivr", # IVR
443
+ "cvr", # CVR
444
+ "adv_original_money", # 花费
445
+ "iaa_d0_ad_revenue", # D0 Ad Rev
446
+ "iaa_d0_roas", # D0 Ad Roas
447
+ "iaa_d3_ad_revenue", # D3 Ad Rev
448
+ "iaa_d3_roas", # D3 Ad Roas
449
+ "iaa_d7_ad_revenue", # D7 Ad Rev
450
+ "iaa_d7_roas", # D7 Ad Roas
451
+ "iap_d0_ad_revenue", # D0 IAP Rev
452
+ "iap_d0_roas", # D0 IAP Roas
453
+ "iap_d3_ad_revenue", # D3 IAP Rev
454
+ "iap_d3_roas", # D3 IAP Roas
455
+ "iap_d7_ad_revenue", # D7 IAP Rev
456
+ "iap_d7_roas", # D7 IAP Roas
457
+ :param sort: [可选-排序] 排序依据(高级选项):adv_install:转化
458
+ :param order:
459
+ :param adv_campaign_id: [可选-筛选]广告名称
460
+ :param promote_country_code: [可选-筛选]投放区域
461
+ :param timeout: 超时时间
462
+ :param stream: 为True时为流式下载
463
+ """
464
+ scheme = "https"
465
+ host = "ss-api.mintegral.com"
466
+
467
+ if not start_time:
468
+ start_time = lazytime.get_date_string(days=0)
469
+ if not end_time:
470
+ end_time = lazytime.get_date_string(days=0)
471
+ if not breakdowns: # 数据维度
472
+ breakdowns = [
473
+ "date",
474
+ "adv_offer_id"
475
+ ]
476
+ if not metrics: # 数据指标
477
+ metrics = [
478
+ "adv_impression", # 展示
479
+ "adv_click", # 点击
480
+ "adv_install", # 转化
481
+ "ecpm", # eCPM
482
+ "ecpc", # CPC
483
+ "ecpi", # eCPI
484
+ "ctr", # CTR
485
+ "ivr", # IVR
486
+ "cvr", # CVR
487
+ "adv_original_money", # 花费
488
+ "iaa_d0_ad_revenue", # D0 Ad Rev
489
+ "iaa_d0_roas", # D0 Ad Roas
490
+ ]
491
+ params = {
492
+ "limit": page_size,
493
+ "page": page,
494
+ "timezone": timezone,
495
+ "start_time": start_time,
496
+ "end_time": end_time,
497
+ "order": order, # 排序
498
+ "breakdowns": ",".join(breakdowns),
499
+ "metrics": ",".join(metrics),
500
+ "show_calendar_day": show_calendar_day
501
+ }
502
+ if sort:
503
+ params["sort"] = sort
504
+ if adv_campaign_id:
505
+ params["adv_campaign_id"] = adv_campaign_id
506
+ headers = copy.deepcopy(default_headers)
507
+ headers["Cookie"] = cookie
508
+
509
+ return lazyrequests.lazy_requests(
510
+ method="GET",
511
+ params=params,
512
+ url=f"{scheme}://{host}{url_filename}",
513
+ headers=headers,
514
+ timeout=timeout
515
+ )
@@ -0,0 +1,37 @@
1
+ # 微盛,企业管家 https://platform.wshoto.com
2
+ from lazysdk import lazyrequests
3
+ import copy
4
+
5
+
6
+ default_headers = {
7
+ "Accept": "application/json, text/plain, */*",
8
+ "Accept-Encoding": "gzip, deflate, zstd",
9
+ "Accept-Language": "en-US,en;q=0.5",
10
+ "Cache-Control": "no-cache",
11
+ "Connection": "keep-alive",
12
+ "Host": "platform.wshoto.com",
13
+ "Origin": "https://platform.wshoto.com",
14
+ "Pragma": "no-cache",
15
+ "Referer": "https://platform.wshoto.com/index/dashboard",
16
+ "Sec-Fetch-Dest": "empty",
17
+ "Sec-Fetch-Mode": "cors",
18
+ "Sec-Fetch-Site": "same-origin",
19
+ "TE": "trailers",
20
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0",
21
+ "x-admin-header": "1",
22
+ "x-clientType-header": "pc",
23
+ "x-header-host": "platform.wshoto.com",
24
+ }
25
+
26
+
27
+ def dashboard(
28
+ authorization: str
29
+ ):
30
+ url = "https://platform.wshoto.com/bff/index/private/pc/dashboard?saMode=SECRET"
31
+ headers = copy.deepcopy(default_headers)
32
+ headers["Authorization"] = authorization
33
+ return lazyrequests.lazy_requests(
34
+ method="POST",
35
+ url=url,
36
+ headers=headers
37
+ )
lazyad/open/apple.py ADDED
@@ -0,0 +1,71 @@
1
+ from lazysdk import lazyrequests
2
+ import showlog
3
+
4
+
5
+ def lookup(
6
+ track_id: int = None,
7
+ bundle_id: str = None,
8
+ country: str = None
9
+ ):
10
+ """
11
+ 获取app信息/开发者信息
12
+ :param track_id:
13
+ :param bundle_id:
14
+ :param country:
15
+ :return:
16
+ """
17
+ params = dict()
18
+ url = "https://itunes.apple.com/lookup"
19
+ if country:
20
+ params['country'] = country
21
+
22
+ if track_id is not None:
23
+ params["id"] = track_id
24
+ # url = f"https://itunes.apple.com/lookup?id={track_id}"
25
+ elif bundle_id is not None:
26
+ params["bundleId"] = bundle_id
27
+ # url = f"https://itunes.apple.com/lookup?bundleId={bundle_id}"
28
+ else:
29
+ return None
30
+ return lazyrequests.lazy_requests(
31
+ method="GET",
32
+ url=url,
33
+ params=params
34
+ )
35
+
36
+
37
+ def lookup_auto(
38
+ input_str: str
39
+ ):
40
+ """
41
+ 输入待查询的字符串,自动处理查询结果
42
+ :param input_str:
43
+ :return:
44
+ """
45
+ bundle_id = None
46
+ track_id = None
47
+ if input_str.startswith("id") and input_str[2:].isdigit():
48
+ # 以id开头,后续为数字的格式,判断为track_id
49
+ showlog.info(f"输入 [{input_str}] 类型为 [id+track_id]")
50
+ track_id = input_str[2:]
51
+ elif input_str.startswith("tempBundleId"):
52
+ showlog.info(f"输入 [{input_str}] 类型为 [tempBundleId]")
53
+ bundle_id = input_str
54
+ elif input_str.isdigit(): # 全部为数字
55
+ showlog.info(f"输入 [{input_str}] 类型为 [track_id]")
56
+ track_id = input_str
57
+ else:
58
+ showlog.info(f"输入 [{input_str}] 类型为 [bundle_id]")
59
+ bundle_id = input_str
60
+
61
+ if track_id:
62
+ if isinstance(track_id, str):
63
+ return {"track_id": track_id, "lookup_res": lookup(track_id=int(track_id))}
64
+ elif isinstance(track_id, int):
65
+ return {"track_id": track_id, "lookup_res": lookup(track_id=track_id)}
66
+ else:
67
+ return None
68
+ elif bundle_id:
69
+ return {"bundle_id": bundle_id, "lookup_res": lookup(bundle_id=bundle_id)}
70
+ else:
71
+ return None
@@ -0,0 +1,31 @@
1
+ from lazysdk import lazyrequests
2
+
3
+
4
+ def campaigns(token: str):
5
+ """
6
+ 获取所有的campaign
7
+ """
8
+ url = "https://o.applovin.com/campaign_management/v1/campaigns"
9
+ return lazyrequests.lazy_requests(
10
+ method="GET",
11
+ url=url,
12
+ headers={"Authorization": token},
13
+ timeout=60
14
+ )
15
+
16
+
17
+ def campaign_targets(
18
+ token: str,
19
+ campaign_id: str
20
+ ):
21
+ """
22
+ 获取所有的campaign的目标信息
23
+ """
24
+ url = f"https://o.applovin.com/campaign_management/v1/campaign_targets/{campaign_id}"
25
+ return lazyrequests.lazy_requests(
26
+ method="GET",
27
+ url=url,
28
+ headers={"Authorization": token},
29
+ timeout=60
30
+ )
31
+
@@ -1,15 +1,17 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: lazyad
3
- Version: 0.0.57
4
- Summary: 基于Python的懒人包-适用于广告投放模块
5
- Home-page: https://gitee.com/ZeroSeeker/lazyad
6
- Author: ZeroSeeker
7
- Author-email: zeroseeker@foxmail.com
8
- Classifier: Programming Language :: Python :: 3
3
+ Version: 0.0.78
4
+ Summary: make it easy to use ad api
5
+ Project-URL: Homepage, https://gitee.com/ZeroSeeker/lazyad
6
+ Project-URL: Issues, https://gitee.com/ZeroSeeker/lazyad/issues
7
+ Author-email: ZeroSeeker <zeroseeker@foxmail.com>
8
+ License-Expression: MIT
9
9
  Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.8
12
+ Requires-Dist: lazysdk>=0.1.88
13
+ Requires-Dist: xmltodict==0.15.0
10
14
  Description-Content-Type: text/markdown
11
- Requires-Dist: lazysdk >=0.1.88
12
- Requires-Dist: xmltodict ==0.14.2
13
15
 
14
16
  # lazyad
15
17
 
@@ -1,15 +1,17 @@
1
1
  lazyad/__init__.py,sha256=tnVTFEgdzgMWQI0mZqy3DAueMJjpypPb15DdxJ-9TiU,41
2
2
  lazyad/crawlers/__init__.py,sha256=GK3GGpiUJbESc1uGTwSmEnsSUwYDNZfJCxeLYB4CpS4,68
3
- lazyad/crawlers/chuangliang.py,sha256=O22E-mnNAUbi5kNBaK5EQQ-YyJq7vgTOx1dDAYaaNLY,24916
4
- lazyad/crawlers/mintegral.py,sha256=awhS2yb48nh5f_yENyUy_vsleuMivrBsYbqrM7eS2jM,9622
3
+ lazyad/crawlers/chuangliang.py,sha256=u4yuRookTZk2ygBK64EGJZuHrUAFC7WcfVmkwf1ujrQ,40958
4
+ lazyad/crawlers/mintegral.py,sha256=paibUE4R_sClQbGVVeRK9T5TzGqq6iDfWwDowWdipNk,15787
5
5
  lazyad/crawlers/oceanengine.py,sha256=kjBEpCb_h5OpodCTqzvXd5MBBwAuw3Oq5UKWoTCXrQM,4540
6
6
  lazyad/crawlers/qq.py,sha256=X_VjdgzAcDfckEAHrvdqBLtnmAuCBHPJVWu2H-IHZBA,5649
7
+ lazyad/crawlers/wshoto.py,sha256=3xckDjK-BpEGPMLHUBgQ8OWuUq77EBL9f7d4j0jwuAY,1224
7
8
  lazyad/open/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ lazyad/open/apple.py,sha256=bdcI5hj8lITSx9aXHwAn4xr0_8upTriFfJveK47u-ZI,2074
10
+ lazyad/open/applovin.py,sha256=pV_N0e22AmSD9wq2Zx4IhJHM0bKS-hO-gCjKIq2n_NM,686
8
11
  lazyad/open/kuaishou.py,sha256=B4wz3XW1hLQy7XR_nDQwrMUrYnm9Djec7OXKXRdiYXc,635
9
12
  lazyad/open/mintegral.py,sha256=BXCaCfnz2iUsR-RtDSA8I27KSK8r4v3xkZfllD9q_vY,12788
10
13
  lazyad/open/qq.py,sha256=pru1p4LCjURD9N5ukx-OStYAmDCvrTW4VMB2N0-3i5Q,6904
11
14
  lazyad/open/unity.py,sha256=A0tEN5k40xq0v1cRnTLwRN5N7CBIe2oAyMRH1uxDAEw,8493
12
- lazyad-0.0.57.dist-info/METADATA,sha256=04H_gc0qW8Ram7DqC835rgJIVJtgpkGTvLWjM8Tzs3o,1918
13
- lazyad-0.0.57.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
14
- lazyad-0.0.57.dist-info/top_level.txt,sha256=RAPjtj4gZYpsKAM3fAQrWyyn84xjdRuaiUS76gx6eNs,7
15
- lazyad-0.0.57.dist-info/RECORD,,
15
+ lazyad-0.0.78.dist-info/METADATA,sha256=-ir8THgToHaOA8XX5K1Myr-zHOI2Xtx6PBsj0ecadvg,2007
16
+ lazyad-0.0.78.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
17
+ lazyad-0.0.78.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
-
@@ -1 +0,0 @@
1
- lazyad