This repository has been archived by the owner on Sep 29, 2021. It is now read-only.
/
account.py
132 lines (110 loc) · 5.38 KB
/
account.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
import hashlib
import requests
from datetime import datetime, timedelta
from .filter import McDailyFilter
class McDailyAccount:
def __init__(self):
""" User info """
self.username = '' # Username
self.password = '' # Password
self.access_token = '' # Token
self.param_string = '' # username + password
self.card_no = '' # Card no
""" System info """
self.str1 = datetime.strftime(datetime.now(), '%Y/%m/%d %H:%M:%S') # Device Time
self.str2 = '2.2.0' # App Version
self.str3 = datetime.strftime(datetime.now(), '%Y%m%d%H%M%S') # Call time
self.model_id = 'Pixel XL' # Model ID
self.os_version = '9' # Android OS Version
self.platform = 'Android' # platform
self.device_uuid = 'device_uuid' # Device Uuid
self.order_no = self.device_uuid + self.str3 # Order No
""" Request json data """
self.json = {
"access_token" : self.access_token,
"source_info" : {
"app_version" : self.str2,
"device_time" : self.str1,
"device_uuid" : self.device_uuid,
"model_id" : self.model_id,
"os_version" : self.os_version,
"platform" : self.platform,
}
}
def login(self, username, password):
self.username = username
self.password = password
self.param_string = username + password
""" Mask = md5('Mc' + order_no + platform + os_version + model_id + device_uuid + str1 + str2 + param_string + 'Donalds') """
data = 'Mc%s%s%s%s%s%s%s%sDonalds' % (
self.order_no,
self.platform,
self.os_version,
self.model_id,
self.device_uuid,
self.str1,
self.str2,
self.param_string
)
hash = hashlib.md5()
hash.update(data.encode('utf-8'))
json = {
"account" : self.username,
"password" : self.password,
"OrderNo" : self.order_no,
"mask" : hash.hexdigest(),
"source_info" : {
"app_version" : self.str2,
"device_time" : self.str1,
"device_uuid" : self.device_uuid,
"model_id" : self.model_id,
"os_version" : self.os_version,
"Platform" : self.platform,
}
}
response = requests.post('https://api.mcddaily.com.tw/login_by_mobile', json = json, headers = {'user-agent' : 'okhttp/3.10.0'})
self.set_token(response.json()['results']['member_info']['access_token'])
return response
def set_token(self, access_token):
self.access_token = access_token
self.json['access_token'] = access_token
def get_card_query(self, card_no):
self.card_no = card_no
""" Mask = md5('Mc' + order_no + access_token + card_no + callTime + 'Donalds') """
data = 'Mc%s%s%s%sDonalds' % (
self.order_no,
self.access_token,
self.card_no,
self.str3,
)
hash = hashlib.md5()
hash.update(data.encode('utf-8'))
json = {
"OrderNo" : self.order_no,
"access_token" : self.access_token,
"callTime" : self.str3,
"cardNo" : self.card_no,
"mask" : mask.hexdigest(),
}
respones = requests.post('https://api.mcddaily.com.tw/queryBonus', json = json, headers = {'user-agent' : 'okhttp/3.10.0'})
return respones
def lottery_get_item(self):
respones = requests.post('https://api1.mcddailyapp.com/lottery/get_item', json = self.json, headers = {'user-agent' : 'okhttp/3.10.0'})
return McDailyFilter(respones.json()).get_object()
def coupon_get_list(self):
respones = requests.post('https://api1.mcddailyapp.com/coupon/get_list', json = self.json, headers = {'user-agent' : 'okhttp/3.10.0'})
return McDailyFilter(respones.json()).get_object()
def sticker_get_list(self):
respones = requests.post('https://api1.mcddailyapp.com/sticker/get_list', json = self.json, headers = {'user-agent' : 'okhttp/3.10.0'})
return McDailyFilter(respones.json()).get_object()
def sticker_redeem(self):
sticker_list = self.sticker_get_list()
if len(sticker_list) < 6:
return 'Just %d stickers' % len(sticker_list)
sticker_id_list = []
for i in range(6):
sticker_id_list.append(sticker_list[i].sticker_id)
json = self.json
json['sticker_ids'] = sticker_id_list
respones = requests.post('https://api1.mcddailyapp.com/sticker/redeem', json = json, headers = {'user-agent' : 'okhttp/3.10.0'})
return McDailyFilter(respones.json()).get_object()