lazyad 0.0.47__tar.gz → 0.0.49__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.47
3
+ Version: 0.0.49
4
4
  Summary: 基于Python的懒人包-适用于广告投放模块
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazyad
6
6
  Author: ZeroSeeker
@@ -0,0 +1,321 @@
1
+ from lazysdk import lazyrequests
2
+ from lazysdk import lazybase64
3
+ from lazysdk import lazytime
4
+
5
+
6
+ def make_auth(
7
+ keyid,
8
+ secret_key
9
+ ):
10
+ """
11
+ 生成校验字符串
12
+ :param keyid:
13
+ :param secret_key:
14
+ :return:
15
+ """
16
+ authorization = f"{keyid}:{secret_key}"
17
+ return f"Basic {lazybase64.lazy_b64encode(authorization)}"
18
+
19
+
20
+ def apps(
21
+ organization_id,
22
+ keyid,
23
+ secret_key
24
+ ):
25
+ """
26
+ 获取app列表
27
+ https://services.docs.unity.com/advertise/v1/index.html#section/Get-Started/First-Call:-List-Apps
28
+ :param organization_id:
29
+ :param keyid:
30
+ :param secret_key:
31
+ :return:
32
+ """
33
+ url = f"https://services.api.unity.com/advertise/v1/organizations/{organization_id}/apps"
34
+ headers = {"Authorization": make_auth(keyid=keyid, secret_key=secret_key)}
35
+ return lazyrequests.lazy_requests(
36
+ method="GET",
37
+ url=url,
38
+ headers=headers
39
+ )
40
+
41
+
42
+ def list_campaigns(
43
+ organization_id,
44
+ app_id,
45
+ keyid,
46
+ secret_key
47
+ ):
48
+ """
49
+ 获取Campaigns列表
50
+ https://services.docs.unity.com/advertise/v1/index.html#tag/Campaigns
51
+ :param organization_id:
52
+ :param app_id:
53
+ :param keyid:
54
+ :param secret_key:
55
+ :return:
56
+ """
57
+ url = f"https://services.api.unity.com/advertise/v1/organizations/{organization_id}/apps/{app_id}/campaigns"
58
+ headers = {"Authorization": make_auth(keyid=keyid, secret_key=secret_key)}
59
+ return lazyrequests.lazy_requests(
60
+ method="GET",
61
+ url=url,
62
+ headers=headers
63
+ )
64
+
65
+
66
+ def get_campaign(
67
+ organization_id,
68
+ app_id,
69
+ campaign_id,
70
+ keyid,
71
+ secret_key,
72
+ include_fields: list = None
73
+ ):
74
+ """
75
+ 获取Campaign信息
76
+ https://services.docs.unity.com/advertise/v1/index.html#tag/Campaigns/operation/advertise_getCampaign
77
+ :param organization_id:
78
+ :param app_id:
79
+ :param campaign_id:
80
+ :param keyid:
81
+ :param secret_key:
82
+ :param include_fields: ["cpiBids", "sourceBids", "roasBids", "retentionBids", "eventOptimizationBids", "budget"]
83
+ :return:
84
+ """
85
+ default_include_fields = ["cpiBids", "sourceBids", "roasBids", "retentionBids", "eventOptimizationBids", "budget"]
86
+ url = f"https://services.api.unity.com/advertise/v1/organizations/{organization_id}/apps/{app_id}/campaigns/{campaign_id}"
87
+ headers = {"Authorization": make_auth(keyid=keyid, secret_key=secret_key)}
88
+ if include_fields:
89
+ pass
90
+ else:
91
+ include_fields = default_include_fields
92
+ params_list = list()
93
+ for each in include_fields:
94
+ params_list.append(f"includeFields={each}")
95
+ params_str = "&".join(params_list)
96
+ return lazyrequests.lazy_requests(
97
+ method="GET",
98
+ url=f"{url}?{params_str}",
99
+ headers=headers
100
+ )
101
+
102
+
103
+ def get_budget(
104
+ organization_id,
105
+ app_id,
106
+ campaign_id,
107
+ keyid,
108
+ secret_key
109
+ ):
110
+ """
111
+ 获取 Campaign budget
112
+ https://services.docs.unity.com/advertise/v1/index.html#tag/Campaigns/operation/advertise_getCampaignBudget
113
+ :param organization_id:
114
+ :param app_id:
115
+ :param campaign_id:
116
+ :param keyid:
117
+ :param secret_key:
118
+ :return:
119
+ """
120
+ url = f"https://services.api.unity.com/advertise/v1/organizations/{organization_id}/apps/{app_id}/campaigns/{campaign_id}/budget"
121
+ headers = {"Authorization": make_auth(keyid=keyid, secret_key=secret_key)}
122
+ return lazyrequests.lazy_requests(
123
+ method="GET",
124
+ url=url,
125
+ headers=headers
126
+ )
127
+
128
+
129
+ def get_targeting_options(
130
+ organization_id,
131
+ app_id,
132
+ campaign_id,
133
+ keyid,
134
+ secret_key
135
+ ):
136
+ """
137
+ Get targeting options
138
+ https://services.docs.unity.com/advertise/v1/index.html#tag/Campaigns/operation/advertise_getTargeting
139
+ :param organization_id:
140
+ :param app_id:
141
+ :param campaign_id:
142
+ :param keyid:
143
+ :param secret_key:
144
+ :return:
145
+ """
146
+ url = f"https://services.api.unity.com/advertise/v1/organizations/{organization_id}/apps/{app_id}/campaigns/{campaign_id}/targeting"
147
+ headers = {"Authorization": make_auth(keyid=keyid, secret_key=secret_key)}
148
+ return lazyrequests.lazy_requests(
149
+ method="GET",
150
+ url=url,
151
+ headers=headers
152
+ )
153
+
154
+
155
+ def update_targeting_options(
156
+ organization_id,
157
+ app_id,
158
+ campaign_id,
159
+ keyid,
160
+ secret_key,
161
+ allow_list: list = None,
162
+ block_list: list = None,
163
+ iso_os_min: str = None
164
+ ):
165
+ """
166
+ Update targeting options
167
+ https://services.docs.unity.com/advertise/v1/index.html#tag/Campaigns/operation/advertise_updateTargeting
168
+ :param organization_id:
169
+ :param app_id:
170
+ :param campaign_id:
171
+ :param keyid:
172
+ :param secret_key:
173
+
174
+ :param allow_list:
175
+ :param block_list:
176
+ :param iso_os_min:
177
+ :return:
178
+ """
179
+ url = f"https://services.api.unity.com/advertise/v1/organizations/{organization_id}/apps/{app_id}/campaigns/{campaign_id}/targeting"
180
+ headers = {"Authorization": make_auth(keyid=keyid, secret_key=secret_key)}
181
+ data = {}
182
+ if allow_list or block_list:
183
+ data["appTargeting"] = {}
184
+ if allow_list:
185
+ data["appTargeting"]["allowList"] = allow_list
186
+ if block_list: # 黑名单
187
+ data["appTargeting"]["blockList"] = block_list
188
+ if iso_os_min:
189
+ data["deviceTargeting"] = {}
190
+ if iso_os_min:
191
+ data["deviceTargeting"]["osMin"] = iso_os_min
192
+ return lazyrequests.lazy_requests(
193
+ method="PATCH",
194
+ url=url,
195
+ headers=headers,
196
+ json=data
197
+ )
198
+
199
+
200
+ def reports(
201
+ organization_id,
202
+ keyid,
203
+ secret_key,
204
+ start: str,
205
+ end: str,
206
+ scale: str = "day",
207
+ metrics: list = None,
208
+ breakdowns: list = None
209
+ ):
210
+ """
211
+ https://services.docs.unity.com/statistics/index.html#tag/Acquisitions/operation/stats_acquisition
212
+ :param metrics:
213
+ starts
214
+ views
215
+ clicks
216
+ installs
217
+ spend
218
+ cpi
219
+ ctr
220
+ cvr
221
+ ecpm
222
+ d0AdRevenue
223
+ d1AdRevenue
224
+ d3AdRevenue
225
+ d7AdRevenue
226
+ d14AdRevenue
227
+ d0AdRevenueRoas
228
+ d1AdRevenueRoas
229
+ d3AdRevenueRoas
230
+ d7AdRevenueRoas
231
+ d14AdRevenueRoas
232
+ d0IapRevenue
233
+ d1IapRevenue
234
+ d3IapRevenue
235
+ d7IapRevenue
236
+ d14IapRevenue
237
+ d0IapRoas
238
+ d1IapRoas
239
+ d3IapRoas
240
+ d7IapRoas
241
+ d14IapRoas
242
+ d0Purchases
243
+ d1Purchases
244
+ d3Purchases
245
+ d7Purchases
246
+ d14Purchases
247
+ d0UniquePurchasers
248
+ d1UniquePurchasers
249
+ d3UniquePurchasers
250
+ d7UniquePurchasers
251
+ d14UniquePurchasers
252
+ d0Retained
253
+ d1Retained
254
+ d3Retained
255
+ d7Retained
256
+ d14Retained
257
+ d0RetentionRate
258
+ d1RetentionRate
259
+ d3RetentionRate
260
+ d7RetentionRate
261
+ d14RetentionRate
262
+ d0TotalRoas
263
+ d1TotalRoas
264
+ d3TotalRoas
265
+ d7TotalRoas
266
+ d14TotalRoas
267
+ d0LevelComplete
268
+ d1LevelComplete
269
+ d3LevelComplete
270
+ d7LevelComplete
271
+ d14LevelComplete
272
+ d0CostPerLevelComplete
273
+ d1CostPerLevelComplete
274
+ d3CostPerLevelComplete
275
+ d7CostPerLevelComplete
276
+ d14CostPerLevelComplete
277
+ d0LevelCompleteRate
278
+ d1LevelCompleteRate
279
+ d3LevelCompleteRate
280
+ d7LevelCompleteRate
281
+ d14LevelCompleteRate
282
+ :param breakdowns:
283
+ app,campaign,country,creativePack,
284
+ creativePackType,osVersion,platform,sourceAppId,store,targetGame,eventType,eventName
285
+ :return:
286
+ """
287
+ authorization = f"Basic {keyid}:{secret_key}"
288
+ url = f"https://services.api.unity.com/advertise/stats/v2/organizations/{organization_id}/reports/acquisitions"
289
+ params = {
290
+ "scale": scale, # "summary" "hour" "day" "week" "month"
291
+ "format": "json"
292
+ }
293
+
294
+ if not metrics:
295
+ metrics = [
296
+ "spend"
297
+ ]
298
+ if not breakdowns:
299
+ breakdowns = [
300
+ "country"
301
+ ]
302
+
303
+ params["breakdowns"] = ",".join(breakdowns)
304
+ params["metrics"] = ",".join(metrics)
305
+ params["start"] = start
306
+ params["end"] = end
307
+
308
+ headers = {"Authorization": authorization}
309
+ response = lazyrequests.lazy_requests(
310
+ method="GET",
311
+ url=url,
312
+ params=params,
313
+ headers=headers
314
+ )
315
+
316
+ status = response.get("status")
317
+ if status is None:
318
+ data = response.get("data")
319
+ return data
320
+ else:
321
+ return response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazyad
3
- Version: 0.0.47
3
+ Version: 0.0.49
4
4
  Summary: 基于Python的懒人包-适用于广告投放模块
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazyad
6
6
  Author: ZeroSeeker
@@ -13,4 +13,5 @@ lazyad/crawlers/oceanengine.py
13
13
  lazyad/crawlers/qq.py
14
14
  lazyad/open/__init__.py
15
15
  lazyad/open/mintegral.py
16
- lazyad/open/qq.py
16
+ lazyad/open/qq.py
17
+ lazyad/open/unity.py
@@ -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.47",
16
+ version="0.0.49",
17
17
  description="基于Python的懒人包-适用于广告投放模块",
18
18
  long_description=long_description,
19
19
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes