lazyad 0.0.15__tar.gz → 0.0.16__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.15
3
+ Version: 0.0.16
4
4
  Summary: 基于Python的懒人包-适用于广告投放模块
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazyad
6
6
  Author: ZeroSeeker
@@ -0,0 +1,202 @@
1
+ from lazysdk import lazyrequests
2
+ from lazysdk import lazytime
3
+ import showlog
4
+ import copy
5
+
6
+
7
+ default_headers = {
8
+ "Accept": "application/json, text/plain, */*",
9
+ "Accept-Encoding": "gzip, deflate",
10
+ "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
11
+ "Connection": "keep-alive",
12
+ "Host": "cli2.mobgi.com",
13
+ "Origin": "https://cl.mobgi.com",
14
+ "Referer": "https://cl.mobgi.com/",
15
+ "Sec-Fetch-Dest": "empty",
16
+ "Sec-Fetch-Mode": "cors",
17
+ "Sec-Fetch-Site": "same-site",
18
+ "TE": "trailers",
19
+ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Firefox/105.0",
20
+ }
21
+
22
+
23
+ def get_media_account(
24
+ media_type: str,
25
+ cookie: str = None,
26
+ page: int = 1,
27
+ page_size: int = 20,
28
+ total_count: int = 0
29
+ ):
30
+ """
31
+ 获取 推广-账户管理下的账户列表
32
+ :param media_type: 媒体类型
33
+ :param cookie:
34
+ :param page:
35
+ :param page_size:
36
+ :param total_count:
37
+ :return:
38
+ """
39
+
40
+ url = 'https://cli2.mobgi.com/Media/Account/getList'
41
+ data = {
42
+ "media_type": media_type,
43
+ "advertiser_type": "1",
44
+ "page": page,
45
+ "page_size": page_size,
46
+ "total_count": total_count
47
+ }
48
+ headers = copy.deepcopy(default_headers)
49
+ headers["Cookie"] = cookie
50
+
51
+ return lazyrequests.lazy_requests(
52
+ method='POST',
53
+ url=url,
54
+ json=data,
55
+ headers=headers,
56
+ return_json=True
57
+ )
58
+
59
+
60
+ def get_ad_report(
61
+ cookie: str,
62
+ start_date: str = None,
63
+ end_date: str = None,
64
+ page: int = 1,
65
+ page_size: int = 20,
66
+ media_type: str = "gdt_new",
67
+ sort_field: str = "cost",
68
+ time_dim: str = "sum",
69
+ sort_direction: str = "desc",
70
+ data_dim: str = "ad",
71
+ data_type: str = "list",
72
+ conditions: dict = None,
73
+ kpis: list = None,
74
+ relate_dims: list = None,
75
+ ):
76
+ """
77
+ 报表-广告报表
78
+ :param cookie:
79
+ :param start_date: 数据开始日期,默认为当日
80
+ :param end_date: 数据结束日期,默认为当日
81
+ :param page: 页码
82
+ :param page_size: 每页数量
83
+ :param media_type: 媒体:gdt_new|广点通(新指标体系),toutiao_upgrade|今日头条2.0,aggregate|不限
84
+ :param sort_field: 排序字段
85
+ :param time_dim: 数据的时间维度汇总方式
86
+ :param sort_direction: 排序方式,desc降序
87
+ :param data_dim: 数据维度,ad广告,advertiser_id:账户
88
+ :param data_type:
89
+ :param conditions: 搜索条件
90
+ :param kpis: 需要获取的字段
91
+ :param relate_dims: 关联维度,advertiser_id:账户
92
+ :return:
93
+ """
94
+ if not start_date:
95
+ start_date = lazytime.get_date_string(days=0)
96
+ if not end_date:
97
+ end_date = lazytime.get_date_string(days=0)
98
+ url = "https://cli2.mobgi.com/ReportV23/AdReport/getReport"
99
+ data = {
100
+ "start_date": start_date,
101
+ "end_date": end_date,
102
+ "page": page,
103
+ "page_size": page_size,
104
+ "media_type": media_type,
105
+ "time_dim": time_dim,
106
+ "data_type": data_type,
107
+ "data_dim": data_dim,
108
+ "sort_field": sort_field,
109
+ "sort_direction": sort_direction,
110
+ }
111
+ if media_type == "baidu":
112
+ if not conditions:
113
+ conditions = {
114
+ "keyword": "",
115
+ "advertiser_id": [],
116
+ "app_id": [],
117
+ "owner_user_id": [],
118
+ "media_agent_id": []
119
+ }
120
+ if not kpis:
121
+ kpis = [
122
+ "cost",
123
+ "weixinfollowsuccessconversions",
124
+ "weixinfollowsuccessconversionscost",
125
+ "payreaduv",
126
+ "payreaduvcost",
127
+ "cpc"
128
+ ]
129
+ if not relate_dims:
130
+ relate_dims = ["advertiser_id"]
131
+
132
+ elif media_type == "gdt_new":
133
+ if not conditions:
134
+ conditions = {
135
+ "keyword": "",
136
+ "advertiser_id": [],
137
+ "app_id": [],
138
+ "owner_user_id": [],
139
+ "media_agent_id": [],
140
+ "landing_type": [],
141
+ "time_line": "REPORTING_TIME"
142
+ }
143
+ if not kpis:
144
+ kpis = [
145
+ "cost",
146
+ "conversions_count",
147
+ "from_follow_uv",
148
+ "cheout_fd",
149
+ "cheout_fd_reward",
150
+ "thousand_display_price",
151
+ "first_pay_count",
152
+ "conversions_cost",
153
+ "from_follow_cost",
154
+ "valid_click_count",
155
+ "cpc"
156
+ ]
157
+ if not relate_dims:
158
+ relate_dims = ["advertiser_id"]
159
+
160
+ elif media_type == "toutiao_upgrade":
161
+ if not conditions:
162
+ conditions = {
163
+ "keyword": "",
164
+ "advertiser_id": [],
165
+ "app_id": [],
166
+ "owner_user_id": [],
167
+ "media_agent_id": [],
168
+ "landing_type": [],
169
+ "cl_create_way": []
170
+ }
171
+ if not kpis:
172
+ kpis = [
173
+ "stat_cost",
174
+ "cpm_platform",
175
+ "convert_cnt",
176
+ "conversion_cost",
177
+ "active",
178
+ "active_cost",
179
+ "click_cnt",
180
+ "cpc_platform",
181
+ "attribution_game_in_app_ltv_1day",
182
+ "attribution_game_in_app_roi_1day",
183
+ "ctr"
184
+ ]
185
+ if not relate_dims:
186
+ relate_dims = ["advertiser_id"]
187
+
188
+ else:
189
+ showlog.warning("未知媒体类型")
190
+ return
191
+
192
+ headers = copy.deepcopy(default_headers)
193
+ headers["Cookie"] = cookie
194
+ data["conditions"] = conditions
195
+ data["kpis"] = kpis
196
+ data["relate_dims"] = relate_dims
197
+ return lazyrequests.lazy_requests(
198
+ method="POST",
199
+ url=url,
200
+ json=data,
201
+ headers=headers
202
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazyad
3
- Version: 0.0.15
3
+ Version: 0.0.16
4
4
  Summary: 基于Python的懒人包-适用于广告投放模块
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazyad
6
6
  Author: ZeroSeeker
@@ -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.15",
16
+ version="0.0.16",
17
17
  description="基于Python的懒人包-适用于广告投放模块",
18
18
  long_description=long_description,
19
19
  long_description_content_type="text/markdown",
@@ -1,54 +0,0 @@
1
- from lazysdk import lazyrequests
2
- import copy
3
-
4
- default_headers = {
5
- "Accept": "application/json, text/plain, */*",
6
- "Accept-Encoding": "gzip, deflate",
7
- "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
8
- "Connection": "keep-alive",
9
- "Host": "cli2.mobgi.com",
10
- "Origin": "https://cl.mobgi.com",
11
- "Referer": "https://cl.mobgi.com/",
12
- "Sec-Fetch-Dest": "empty",
13
- "Sec-Fetch-Mode": "cors",
14
- "Sec-Fetch-Site": "same-site",
15
- "TE": "trailers",
16
- "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Firefox/105.0",
17
- }
18
-
19
-
20
- def get_media_account(
21
- media_type: str,
22
- cookie: str = None,
23
- page: int = 1,
24
- page_size: int = 20,
25
- total_count: int = 0
26
- ):
27
- """
28
- 获取 推广-账户管理下的账户列表
29
- :param media_type: 媒体类型
30
- :param cookie:
31
- :param page:
32
- :param page_size:
33
- :param total_count:
34
- :return:
35
- """
36
-
37
- url = 'https://cli2.mobgi.com/Media/Account/getList'
38
- data = {
39
- "media_type": media_type,
40
- "advertiser_type": "1",
41
- "page": page,
42
- "page_size": page_size,
43
- "total_count": total_count
44
- }
45
- headers = copy.deepcopy(default_headers)
46
- headers["Cookie"] = cookie
47
-
48
- return lazyrequests.lazy_requests(
49
- method='POST',
50
- url=url,
51
- json=data,
52
- headers=headers,
53
- return_json=True
54
- )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes