forked from zhaoboy9692/imaotai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iMTShop.py
306 lines (272 loc) · 11.9 KB
/
iMTShop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
import datetime
import os
import random
import time
import requests
import base64
import json
from notify import send
# 微信公众号@爱上羊毛侠 二次开发
# 微信公众号@小白技术社首发
# 青龙面板加入环境变量Mt_Version和MTTokenD
# MTTokenD是茅台预约参数,多个请换行,格式'省份,城市,经度,维度,设备id,token,MT-Token-Wap(抓包小茅运)'
# Mt_Version是app版本号如 1.3.6 必填(填最新版本,目前好像没法获取)
# MT-Token-Wap参数是小茅运的领奖励,不需要的话MTTokenD格式改成 省份,城市,经度,维度,设备id,token,''
p_c_map = {}
mt_r = 'clips_OlU6TmFRag5rCXwbNAQ/Tz1SKlN8THcecBp/'
# res_map = {'10213': '贵州茅台酒(癸卯兔年)', '2476': '贵州茅台酒(壬寅虎年)', '2478': '贵州茅台酒(珍品)',
# '10214': '贵州茅台酒(癸卯兔年)x2'}
# 下面定义的是申请哪几个,想申请全部的话把上面注释删掉,把下面的注释掉
res_map = {'10213': '贵州茅台酒(癸卯兔年)', '2478': '贵州茅台酒(珍品)',
'10214': '贵州茅台酒(癸卯兔年)x2'}
def mt_add(itemId, shopId, sessionId, userId, token, Device_ID):
MT_K = f'{int(time.time() * 1000)}'
r = requests.get(
f'http://82.157.10.108:8086/get_mtv?DeviceID={Device_ID}&MTk={MT_K}&version={mt_version}&key=yaohuo')
headers = {'User-Agent': 'iPhone 14',
'MT-Token': token,
'MT-Network-Type': 'WIFI', 'MT-User-Tag': '0',
'MT-R': mt_r, 'MT-Lat': '', 'MT-K': MT_K,
'MT-Lng': '', 'MT-Info': '028e7f96f6369cafe1d105579c5b9377', 'MT-APP-Version': mt_version,
'MT-Request-ID': f'{int(time.time() * 1000)}', 'Accept-Language': 'zh-Hans-CN;q=1',
'MT-Device-ID': Device_ID, 'MT-V': r.text,
'MT-Bundle-ID': 'com.moutai.mall',
'mt-lng': lng,
'mt-lat': lat}
d = {"itemInfoList": [{"count": 1, "itemId": str(itemId)}], "sessionId": sessionId, "userId": str(userId),
"shopId": str(shopId)}
r = requests.get('http://82.157.10.108:8086/get_actParam?key=yaohuo&actParam=' + base64.b64encode(
json.dumps(d).replace(' ', '').encode('utf8')).decode())
d['actParam'] = r.text
json_data = d
response = requests.post('https://app.moutai519.com.cn/xhr/front/mall/reservation/add', headers=headers,
json=json_data)
code = response.json().get('code', 0)
if code == 2000:
return response.json().get('data', {}).get('successDesc', "未知")
return '申购失败:' + response.json().get('message', "未知原因")
def tongzhi(ss):
user_list = os.getenv('mtec_user', '').split(',')
for user in user_list:
url = 'http://wxpusher.zjiecode.com/api/send/message/?appToken=&content={}&uid={}'.format(
ss, user)
r = requests.get(url)
print(r.text)
def get_session_id(device_id, token):
headers = {
'mt-device-id': device_id,
'mt-user-tag': '0',
'accept': '*/*',
'mt-network-type': 'WIFI',
'mt-token': token,
'mt-bundle-id': 'com.moutai.mall',
'accept-language': 'zh-Hans-CN;q=1',
'mt-request-id': f'{int(time.time() * 1000)}',
'mt-app-version': mt_version,
'user-agent': 'iPhone 14',
'mt-r': mt_r,
'mt-lng': lng,
'mt-lat': lat
}
response = requests.get('https://static.moutai519.com.cn/mt-backend/xhr/front/mall/index/session/get/' + time_keys,
headers=headers)
sessionId = response.json().get('data', {}).get('sessionId')
itemList = response.json().get('data', {}).get('itemList', [])
itemCodes = [item.get('itemCode') for item in itemList]
return sessionId, itemCodes
def get_shop_item(sessionId, itemId, device_id, token, province, city):
headers = {
'mt-device-id': device_id,
'mt-user-tag': '0',
'mt-lat': '',
'accept': '*/*',
'mt-network-type': 'WIFI',
'mt-token': token,
'mt-bundle-id': 'com.moutai.mall',
'accept-language': 'zh-Hans-CN;q=1',
'mt-request-id': f'{int(time.time() * 1000)}',
'mt-r': mt_r,
'mt-app-version': mt_version,
'user-agent': 'iPhone 14',
'mt-lng': lng,
'mt-lat': lat
}
response = requests.get(
'https://static.moutai519.com.cn/mt-backend/xhr/front/mall/shop/list/slim/v3/' + str(
sessionId) + '/' + province + '/' + str(itemId) + '/' + time_keys,
headers=headers)
data = response.json().get('data', {})
shops = data.get('shops', [])
shop_id_ = p_c_map[province][city]
for shop in shops:
if not shop.get('shopId') in shop_id_:
continue
if itemId in str(shop):
return shop.get('shopId')
def get_user_id(token, Device_ID):
headers = {
'MT-User-Tag': '0',
'Accept': '*/*',
'MT-Network-Type': 'WIFI',
'MT-Token': token,
'MT-Bundle-ID': 'com.moutai.mall',
'Accept-Language': 'zh-Hans-CN;q=1, en-CN;q=0.9',
'MT-Request-ID': f'{int(time.time() * 1000)}',
'MT-APP-Version': mt_version,
'User-Agent': 'iOS;16.0.1;Apple;iPhone 14 ProMax',
'MT-R': mt_r,
'MT-Device-ID': Device_ID,
'mt-lng': lng,
'mt-lat': lat
}
response = requests.get(
'https://app.moutai519.com.cn/xhr/front/user/info', headers=headers)
userName = response.json().get('data', {}).get('userName')
userId = response.json().get('data', {}).get('userId')
mobile = response.json().get('data', {}).get('mobile')
return userName, userId, mobile
def getUserEnergyAward(device_id, ck):
"""
领取耐力
:return:
"""
cookies = {
'MT-Device-ID-Wap': device_id,
'MT-Token-Wap': ck,
'YX_SUPPORT_WEBP': '1',
}
headers = {
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_2_1 like Mac OS X)',
'Referer': 'https://h5.moutai519.com.cn/gux/game/main?appConfig=2_1_2',
'Client-User-Agent': 'iOS;15.0.1;Apple;iPhone 12 ProMax',
'MT-R': mt_r,
'Origin': 'https://h5.moutai519.com.cn',
'MT-APP-Version': mt_version,
'MT-Request-ID': f'{int(time.time() * 1000)}',
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
'MT-Device-ID': device_id,
'Accept': 'application/json, text/javascript, */*; q=0.01',
'mt-lng': lng,
'mt-lat': lat
}
response = requests.post('https://h5.moutai519.com.cn/game/isolationPage/getUserEnergyAward', cookies=cookies,
headers=headers, json={})
return response.json().get('message') if '无法领取奖励' in response.text else "领取奖励成功"
def get_map():
global p_c_map
url = 'https://static.moutai519.com.cn/mt-backend/xhr/front/mall/resource/get'
headers = {
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0_1 like Mac OS X)',
'Referer': 'https://h5.moutai519.com.cn/gux/game/main?appConfig=2_1_2',
'Client-User-Agent': 'iOS;16.0.1;Apple;iPhone 14 ProMax',
'MT-R': mt_r,
'Origin': 'https://h5.moutai519.com.cn',
'MT-APP-Version': mt_version,
'MT-Request-ID': f'{int(time.time() * 1000)}{random.randint(1111111, 999999999)}{int(time.time() * 1000)}',
'Accept-Language': 'zh-CN,zh-Hans;q=1',
'MT-Device-ID': f'{int(time.time() * 1000)}{random.randint(1111111, 999999999)}{int(time.time() * 1000)}',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'mt-lng': lng,
'mt-lat': lat
}
res = requests.get(url, headers=headers, )
mtshops = res.json().get('data', {}).get('mtshops_pc', {})
urls = mtshops.get('url')
r = requests.get(urls)
for k, v in dict(r.json()).items():
provinceName = v.get('provinceName')
cityName = v.get('cityName')
if not p_c_map.get(provinceName):
p_c_map[provinceName] = {}
if not p_c_map[provinceName].get(cityName, None):
p_c_map[provinceName][cityName] = [k]
else:
p_c_map[provinceName][cityName].append(k)
return p_c_map
def login(phone, vCode, Device_ID):
"""
:param phone: 手机号
:param vCode: 验证码
:param Device_ID: 设备id
:return:
"""
MT_K = f'{int(time.time() * 1000)}'
r = requests.get(
f'http://82.157.10.108:8086/get_mtv?DeviceID={Device_ID}&MTk={MT_K}&version={mt_version}&key=yaohuo')
headers = {
'MT-Device-ID': Device_ID,
'MT-User-Tag': '0',
'Accept': '*/*',
'MT-Network-Type': 'WIFI',
'MT-Token': '',
'MT-K': MT_K,
'MT-Bundle-ID': 'com.moutai.mall',
'MT-V': r.text,
'User-Agent': 'iOS;16.0.1;Apple;iPhone 14 ProMax',
'Accept-Language': 'zh-Hans-CN;q=1',
'MT-Request-ID': f'{int(time.time() * 1000)}18342',
'MT-R': mt_r,
'MT-APP-Version': mt_version,
}
json_data = {
'ydToken': '',
'mobile': f'{phone}',
'vCode': f'{vCode}',
'ydLogId': '',
}
response = requests.post('https://app.moutai519.com.cn/xhr/front/user/register/login', headers=headers,
json=json_data)
data = response.json().get('data', {})
token = data.get('token')
cookie = data.get('cookie') # MT-Token-Wap
print(Device_ID, token, cookie)
return Device_ID, token, cookie
if __name__ == '__main__':
mt_tokens = os.getenv("MTTokenD")
mt_version = os.getenv("Mt_Version")
if not mt_tokens:
print('MTToken is null')
exit()
if not mt_version:
print('版本号为空 is null')
exit()
mt_token_list = mt_tokens.split('&')
s = "-------------------总共" + \
str(int(len(mt_token_list))) + \
"个用户-------------------"+'\n'
userCount = 0
if len(mt_token_list) > 0:
for mt_token in mt_token_list:
userCount += 1
province, city, lng, lat, device_id, token, ck = mt_token.split(
',')
time_keys = str(
int(time.mktime(datetime.date.today().timetuple())) * 1000)
get_map()
try:
sessionId, itemCodes = get_session_id(device_id, token)
userName, user_id, mobile = get_user_id(token, device_id)
if not user_id:
s += "第"+str(userCount)+"个用户token失效,请重新登录"+'\n'
continue
s += "第"+str(userCount)+"个用户----------------"+userName + '_' + \
mobile + "开始任务" + "----------------"+'\n'
for itemCode in itemCodes:
name = res_map.get(str(itemCode))
if name:
shop_id = get_shop_item(
sessionId, itemCode, device_id, token, province, city)
res = mt_add(itemCode, str(shop_id), sessionId,
user_id, token, device_id)
s += itemCode + \
'_' + name + '---------------' + res + '\n'
if not ck:
r = getUserEnergyAward(device_id, ck)
s += userName + '_' + mobile + '---------------' + \
"小茅运:" + r + '\n'
s += userName + '_' + mobile + "正常结束任务"+'\n \n'
except Exception as e:
s += userName + '_' + mobile + "异常信息"+e
send("i茅台申购+小茅运", s)