lazyad 0.0.43__py3-none-any.whl → 0.0.45__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.

Potentially problematic release.


This version of lazyad might be problematic. Click here for more details.

@@ -1,6 +1,8 @@
1
1
  from lazysdk import lazyrequests
2
2
  from lazysdk import lazytime
3
+ import xmltodict
3
4
  import copy
5
+ import time
4
6
 
5
7
 
6
8
  """
@@ -24,7 +26,7 @@ default_headers = {
24
26
  "TE": "trailers",
25
27
  "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:132.0) Gecko/20100101 Firefox/132.0"
26
28
  }
27
- default_timeout = 60
29
+ default_timeout = 60 * 10 # MTG下载最大超时时间为10分钟
28
30
 
29
31
 
30
32
  def auth(
@@ -124,6 +126,7 @@ def offers(
124
126
  def performance(
125
127
  cookie: str,
126
128
  total: bool = False,
129
+ export: bool = False,
127
130
 
128
131
  page: int = 1,
129
132
  page_size: int = 50,
@@ -143,8 +146,15 @@ def performance(
143
146
  获取广告单元列表
144
147
  需要登录:{'code': 400, 'msg': 'Please login first', 'data': None}
145
148
  验证成功:{'code': 200, 'msg': 'success', 'data': {}
149
+ :param cookie: 已经登陆的cookie
150
+ :param total: 为True时获取总记录数
151
+ :param export: 为True时下载表格文件
152
+ :param page: 页码
153
+ :param page_size: 每页数量
154
+ :param timezone: 时区
146
155
  :param start_time: 开始日期,例如:2025-03-05
147
156
  :param end_time: 结束日期,例如:2025-03-05
157
+ :param show_calendar_day:
148
158
  :param breakdowns: 分组依据(高级选项):[]
149
159
  (date:天, timestamp:小时,week:周,month:月)
150
160
  adv_offer_id:广告单元,
@@ -156,14 +166,40 @@ def performance(
156
166
  adv_campaign_id:广告
157
167
  received_price:单价
158
168
  ad_type:广告类型
169
+ :param metrics: 展示数据列(高级选项):[]
170
+ "adv_impression", # 展示
171
+ "adv_click", # 点击
172
+ "adv_install", # 转化
173
+ "ecpm", # eCPM
174
+ "ecpc", # CPC
175
+ "ecpi", # eCPI
176
+ "ctr", # CTR
177
+ "ivr", # IVR
178
+ "cvr", # CVR
179
+ "adv_original_money", # 花费
180
+ "iaa_d0_ad_revenue", # D0 Ad Rev
181
+ "iaa_d0_roas", # D0 Ad Roas
182
+ "iaa_d3_ad_revenue", # D3 Ad Rev
183
+ "iaa_d3_roas", # D3 Ad Roas
184
+ "iaa_d7_ad_revenue", # D7 Ad Rev
185
+ "iaa_d7_roas", # D7 Ad Roas
186
+ "iap_d0_ad_revenue", # D0 IAP Rev
187
+ "iap_d0_roas", # D0 IAP Roas
188
+ "iap_d3_ad_revenue", # D3 IAP Rev
189
+ "iap_d3_roas", # D3 IAP Roas
190
+ "iap_d7_ad_revenue", # D7 IAP Rev
191
+ "iap_d7_roas", # D7 IAP Roas
159
192
  :param sort: [可选-排序] 排序依据(高级选项):adv_install:转化
193
+ :param order:
160
194
  :param adv_campaign_id: [可选-筛选]广告名称
161
195
  :param promote_country_code: [可选-筛选]投放区域
196
+ :param timeout: 超时时间
162
197
  """
163
198
  scheme = "https"
164
199
  host = "ss-api.mintegral.com"
165
200
  filename = "/api/v1/reports/performance" # 获取详细数据
166
201
  filename_total = "/api/v1/reports/performance-total" # 获取总数据数据量,该请求优先
202
+ filename_export = "/api/v1/reports/performance-export" # 导出数据
167
203
 
168
204
  if not start_time:
169
205
  start_time = lazytime.get_date_string(days=0)
@@ -188,16 +224,6 @@ def performance(
188
224
  "adv_original_money", # 花费
189
225
  "iaa_d0_ad_revenue", # D0 Ad Rev
190
226
  "iaa_d0_roas", # D0 Ad Roas
191
- "iaa_d3_ad_revenue", # D3 Ad Rev
192
- "iaa_d3_roas", # D3 Ad Roas
193
- "iaa_d7_ad_revenue", # D7 Ad Rev
194
- "iaa_d7_roas", # D7 Ad Roas
195
- # "iap_d0_ad_revenue", # D0 IAP Rev
196
- # "iap_d0_roas", # D0 IAP Roas
197
- # "iap_d3_ad_revenue", # D3 IAP Rev
198
- # "iap_d3_roas", # D3 IAP Roas
199
- # "iap_d7_ad_revenue", # D7 IAP Rev
200
- # "iap_d7_roas", # D7 IAP Roas
201
227
  ]
202
228
  params = {
203
229
  "limit": page_size,
@@ -224,6 +250,17 @@ def performance(
224
250
  headers=headers,
225
251
  timeout=timeout
226
252
  )
253
+ elif export:
254
+ params["t"] = int(time.time()*1000)
255
+ response = lazyrequests.lazy_requests(
256
+ method="GET",
257
+ params=params,
258
+ url=f"{scheme}://{host}{filename_export}",
259
+ headers=headers,
260
+ timeout=timeout,
261
+ return_json=False
262
+ )
263
+ return xml_to_dict(response.text)
227
264
  else:
228
265
  return lazyrequests.lazy_requests(
229
266
  method="GET",
@@ -232,3 +269,21 @@ def performance(
232
269
  headers=headers,
233
270
  timeout=timeout
234
271
  )
272
+
273
+
274
+ def xml_to_dict(xml_str):
275
+ """
276
+ 将MTG下载的表格内容转换为[dict]格式,方便后续处理
277
+ :param xml_str:
278
+ :return:
279
+ """
280
+ parsed_dict = xmltodict.parse(xml_str)
281
+
282
+ # 提取表格数据(根据实际结构调整路径)
283
+ rows = parsed_dict["Workbook"]["Worksheet"]["Table"]["Row"]
284
+ headers = [cell["Data"]["#text"] for cell in rows[0]["Cell"]]
285
+ data_list = [
286
+ {headers[i]: cell["Data"]["#text"] for i, cell in enumerate(row["Cell"])}
287
+ for row in rows[1:]
288
+ ]
289
+ return data_list
lazyad/open/mintegral.py CHANGED
@@ -347,3 +347,32 @@ def update_budget(
347
347
  "mtgid": mtgid
348
348
  }
349
349
  )
350
+
351
+
352
+ def get_campaign(
353
+ api_key: str,
354
+ access_key: str,
355
+ page: int = 1,
356
+ limit: int = 50
357
+ ):
358
+ """
359
+ 获取广告
360
+ https://adv.mintegral.com/doc/cn/guide/campaign/getCampaign.html
361
+ :param api_key:
362
+ :param access_key:
363
+ :param page:
364
+ :param limit:
365
+ :return:
366
+ """
367
+ url = "https://ss-api.mintegral.com/api/open/v1/campaign"
368
+ token_info = make_token(api_key=api_key)
369
+ params = {"access-key": access_key}
370
+ params.update(token_info)
371
+ params["page"] = page
372
+ params["limit"] = limit
373
+ return lazyrequests.lazy_requests(
374
+ method="GET",
375
+ url=url,
376
+ params=params
377
+ )
378
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazyad
3
- Version: 0.0.43
3
+ Version: 0.0.45
4
4
  Summary: 基于Python的懒人包-适用于广告投放模块
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazyad
6
6
  Author: ZeroSeeker
@@ -9,6 +9,7 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Operating System :: OS Independent
10
10
  Description-Content-Type: text/markdown
11
11
  Requires-Dist: lazysdk >=0.1.88
12
+ Requires-Dist: xmltodict ==0.14.2
12
13
 
13
14
  # lazyad
14
15
 
@@ -1,13 +1,13 @@
1
1
  lazyad/__init__.py,sha256=tnVTFEgdzgMWQI0mZqy3DAueMJjpypPb15DdxJ-9TiU,41
2
2
  lazyad/crawlers/__init__.py,sha256=GK3GGpiUJbESc1uGTwSmEnsSUwYDNZfJCxeLYB4CpS4,68
3
3
  lazyad/crawlers/chuangliang.py,sha256=nU57GkUGAXcu8TquqB9hg8Ysvl5E3ZlGX6pedj_nIwo,24830
4
- lazyad/crawlers/mintegral.py,sha256=vgF1TwnvvqAVvZPqRRJyZ0qo1_9ARVt2f2brKjdkyvU,7043
4
+ lazyad/crawlers/mintegral.py,sha256=vOJRZs8mspS7hKLQHBabW0UGNCvH9uCmBdMib2o2_VE,8788
5
5
  lazyad/crawlers/oceanengine.py,sha256=kjBEpCb_h5OpodCTqzvXd5MBBwAuw3Oq5UKWoTCXrQM,4540
6
6
  lazyad/crawlers/qq.py,sha256=X_VjdgzAcDfckEAHrvdqBLtnmAuCBHPJVWu2H-IHZBA,5649
7
7
  lazyad/open/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- lazyad/open/mintegral.py,sha256=YJbDMyzDct8-zjJXFreOVVHKOz6xuIale3aS7HsPuSM,10917
8
+ lazyad/open/mintegral.py,sha256=iybtS0u9WFbZwEXnIKeFzDth4peqOfFqZUSl0oKLkiM,11581
9
9
  lazyad/open/qq.py,sha256=pru1p4LCjURD9N5ukx-OStYAmDCvrTW4VMB2N0-3i5Q,6904
10
- lazyad-0.0.43.dist-info/METADATA,sha256=KlQ51rMyassu2-GQ_NfqaD4wSK6SNspXYeo93nHlP7Y,1884
11
- lazyad-0.0.43.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
12
- lazyad-0.0.43.dist-info/top_level.txt,sha256=RAPjtj4gZYpsKAM3fAQrWyyn84xjdRuaiUS76gx6eNs,7
13
- lazyad-0.0.43.dist-info/RECORD,,
10
+ lazyad-0.0.45.dist-info/METADATA,sha256=DAArvfvaXkIOBMIlhVuwo-suU2skCBy72jJ_Vf8IRCo,1918
11
+ lazyad-0.0.45.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
12
+ lazyad-0.0.45.dist-info/top_level.txt,sha256=RAPjtj4gZYpsKAM3fAQrWyyn84xjdRuaiUS76gx6eNs,7
13
+ lazyad-0.0.45.dist-info/RECORD,,