lazyad 0.0.44__tar.gz → 0.0.46__tar.gz

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,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazyad
3
- Version: 0.0.44
3
+ Version: 0.0.46
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,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,
@@ -137,14 +140,22 @@ def performance(
137
140
  order: str = "DESC",
138
141
  adv_campaign_id: int = None,
139
142
  promote_country_code: str = None,
140
- timeout: int = default_timeout
143
+ timeout: int = default_timeout,
144
+ stream: bool = False
141
145
  ):
142
146
  """
143
147
  获取广告单元列表
144
148
  需要登录:{'code': 400, 'msg': 'Please login first', 'data': None}
145
149
  验证成功:{'code': 200, 'msg': 'success', 'data': {}
150
+ :param cookie: 已经登陆的cookie
151
+ :param total: 为True时获取总记录数
152
+ :param export: 为True时下载表格文件
153
+ :param page: 页码
154
+ :param page_size: 每页数量
155
+ :param timezone: 时区
146
156
  :param start_time: 开始日期,例如:2025-03-05
147
157
  :param end_time: 结束日期,例如:2025-03-05
158
+ :param show_calendar_day:
148
159
  :param breakdowns: 分组依据(高级选项):[]
149
160
  (date:天, timestamp:小时,week:周,month:月)
150
161
  adv_offer_id:广告单元,
@@ -156,14 +167,41 @@ def performance(
156
167
  adv_campaign_id:广告
157
168
  received_price:单价
158
169
  ad_type:广告类型
170
+ :param metrics: 展示数据列(高级选项):[]
171
+ "adv_impression", # 展示
172
+ "adv_click", # 点击
173
+ "adv_install", # 转化
174
+ "ecpm", # eCPM
175
+ "ecpc", # CPC
176
+ "ecpi", # eCPI
177
+ "ctr", # CTR
178
+ "ivr", # IVR
179
+ "cvr", # CVR
180
+ "adv_original_money", # 花费
181
+ "iaa_d0_ad_revenue", # D0 Ad Rev
182
+ "iaa_d0_roas", # D0 Ad Roas
183
+ "iaa_d3_ad_revenue", # D3 Ad Rev
184
+ "iaa_d3_roas", # D3 Ad Roas
185
+ "iaa_d7_ad_revenue", # D7 Ad Rev
186
+ "iaa_d7_roas", # D7 Ad Roas
187
+ "iap_d0_ad_revenue", # D0 IAP Rev
188
+ "iap_d0_roas", # D0 IAP Roas
189
+ "iap_d3_ad_revenue", # D3 IAP Rev
190
+ "iap_d3_roas", # D3 IAP Roas
191
+ "iap_d7_ad_revenue", # D7 IAP Rev
192
+ "iap_d7_roas", # D7 IAP Roas
159
193
  :param sort: [可选-排序] 排序依据(高级选项):adv_install:转化
194
+ :param order:
160
195
  :param adv_campaign_id: [可选-筛选]广告名称
161
196
  :param promote_country_code: [可选-筛选]投放区域
197
+ :param timeout: 超时时间
198
+ :param stream: 为True时为流式下载
162
199
  """
163
200
  scheme = "https"
164
201
  host = "ss-api.mintegral.com"
165
202
  filename = "/api/v1/reports/performance" # 获取详细数据
166
203
  filename_total = "/api/v1/reports/performance-total" # 获取总数据数据量,该请求优先
204
+ filename_export = "/api/v1/reports/performance-export" # 导出数据
167
205
 
168
206
  if not start_time:
169
207
  start_time = lazytime.get_date_string(days=0)
@@ -188,16 +226,6 @@ def performance(
188
226
  "adv_original_money", # 花费
189
227
  "iaa_d0_ad_revenue", # D0 Ad Rev
190
228
  "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
229
  ]
202
230
  params = {
203
231
  "limit": page_size,
@@ -224,6 +252,17 @@ def performance(
224
252
  headers=headers,
225
253
  timeout=timeout
226
254
  )
255
+ elif export:
256
+ params["t"] = int(time.time()*1000)
257
+ return lazyrequests.lazy_requests(
258
+ method="GET",
259
+ params=params,
260
+ url=f"{scheme}://{host}{filename_export}",
261
+ headers=headers,
262
+ timeout=timeout,
263
+ return_json=False,
264
+ stream=stream
265
+ ) # 直接返回,由接收数据端自行处理
227
266
  else:
228
267
  return lazyrequests.lazy_requests(
229
268
  method="GET",
@@ -232,3 +271,21 @@ def performance(
232
271
  headers=headers,
233
272
  timeout=timeout
234
273
  )
274
+
275
+
276
+ def xml_to_dict(xml_str):
277
+ """
278
+ 将MTG下载的表格内容转换为[dict]格式,方便后续处理
279
+ :param xml_str:
280
+ :return:
281
+ """
282
+ parsed_dict = xmltodict.parse(xml_str)
283
+
284
+ # 提取表格数据(根据实际结构调整路径)
285
+ rows = parsed_dict["Workbook"]["Worksheet"]["Table"]["Row"]
286
+ headers = [cell["Data"]["#text"] for cell in rows[0]["Cell"]]
287
+ data_list = [
288
+ {headers[i]: cell["Data"]["#text"] for i, cell in enumerate(row["Cell"])}
289
+ for row in rows[1:]
290
+ ]
291
+ return data_list
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazyad
3
- Version: 0.0.44
3
+ Version: 0.0.46
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
 
@@ -0,0 +1,2 @@
1
+ lazysdk>=0.1.88
2
+ xmltodict==0.14.2
@@ -13,7 +13,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
13
13
 
14
14
  setuptools.setup(
15
15
  name="lazyad",
16
- version="0.0.44",
16
+ version="0.0.46",
17
17
  description="基于Python的懒人包-适用于广告投放模块",
18
18
  long_description=long_description,
19
19
  long_description_content_type="text/markdown",
@@ -28,5 +28,6 @@ setuptools.setup(
28
28
  ],
29
29
  install_requires=[
30
30
  'lazysdk>=0.1.88',
31
+ "xmltodict==0.14.2"
31
32
  ]
32
33
  )
@@ -1 +0,0 @@
1
- lazysdk>=0.1.88
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes