This repository has been archived by the owner on Nov 29, 2022. It is now read-only.
forked from bluemutedwisdom/google-play-downloader
-
Notifications
You must be signed in to change notification settings - Fork 8
/
AssetRequest.py
78 lines (56 loc) · 2.57 KB
/
AssetRequest.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
from ProtocolBuffer import ProtocolBuffer
class AssetRequest:
def __init__(self, package_name, auth_token, device_id, operator, device_name, sdk_version):
self.encode_table = [0, [16], 2, [24], 4, [34], 6, [42], 8, [50], 10, [58], 12, [66], 14, [74], 16, [82], 18, [90], 20, [19, 82], 22, [10], 24, [20]]
self.pad = [10]
self.buffer = ProtocolBuffer()
self.auth_token = auth_token
self.is_secure = True
self.sdk_version = 2009011
self.device_id = device_id
self.device_name = device_name
self.sdk_version = sdk_version
self.locale = "en"
self.country = "us"
self.operator_alpha = operator.name
self.sim_operator_alpha = operator.name
self.operator_code = operator.code
self.sim_operator_code = operator.code
self.package_name = package_name
def encode(self):
self.buffer.reset()
header_len = 0
for encoder in self.encode_table:
enc_type = type(encoder).__name__
if enc_type == "list":
self.buffer.buffer += encoder
elif enc_type == "int":
if encoder == 0:
self.buffer.update(self.auth_token)
elif encoder == 2:
self.buffer.update(self.is_secure)
elif encoder == 4:
self.buffer.update(self.sdk_version)
elif encoder == 6:
self.buffer.update(self.device_id)
elif encoder == 8:
self.buffer.update('%s:%d' % (self.device_name, self.sdk_version))
elif encoder == 10:
self.buffer.update(self.locale)
elif encoder == 12:
self.buffer.update(self.country)
elif encoder == 14:
self.buffer.update(self.operator_alpha)
elif encoder == 16:
self.buffer.update(self.sim_operator_alpha)
elif encoder == 18:
self.buffer.update(self.operator_code)
elif encoder == 20:
self.buffer.update(self.sim_operator_code)
header_len = len(self.buffer.buffer) + 1
elif encoder == 22:
self.buffer.update(len(self.package_name) + 2)
elif encoder == 24:
self.buffer.update(self.package_name)
self.buffer.buffer = self.pad + ProtocolBuffer().update(header_len) + self.pad + self.buffer.buffer
return self.buffer.finalize()