|
1
|
|
|
from typing import ( |
|
|
|
|
|
|
2
|
|
|
Optional, |
|
3
|
|
|
Tuple, |
|
4
|
|
|
Dict |
|
5
|
|
|
) |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
class VKMusicData: |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
def __init__( |
|
11
|
|
|
self, |
|
|
|
|
|
|
12
|
|
|
cookies: str, |
|
|
|
|
|
|
13
|
|
|
user_agent: Optional[str] = None |
|
|
|
|
|
|
14
|
|
|
) -> "VKMusicData": |
|
15
|
|
|
|
|
16
|
|
|
if user_agent is None: |
|
17
|
|
|
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \ |
|
18
|
|
|
" (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" |
|
19
|
|
|
|
|
20
|
|
|
self.base_url: str = "https://luxvk.com" |
|
21
|
|
|
self.main_headers: Dict[str, str] = { |
|
22
|
|
|
"user-agent": user_agent, |
|
23
|
|
|
"cookie": f"{cookies} e6885c05e8_blockTimer=1; u_e6885c05e8=1; e6885c05e8_delayCount=6" |
|
24
|
|
|
} |
|
25
|
|
|
self.download_headers: Dict[str, str] = { |
|
26
|
|
|
"user-agent": user_agent |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
class VKAuthData: |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
def __init__( |
|
33
|
|
|
self, |
|
|
|
|
|
|
34
|
|
|
username: str, |
|
|
|
|
|
|
35
|
|
|
password: str, |
|
|
|
|
|
|
36
|
|
|
user_agent: Optional[str] = None |
|
|
|
|
|
|
37
|
|
|
) -> "VKAuthData": |
|
38
|
|
|
|
|
39
|
|
|
if user_agent is None: |
|
40
|
|
|
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \ |
|
41
|
|
|
" (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" |
|
42
|
|
|
|
|
43
|
|
|
self.links: Tuple[str, ...] = ( |
|
44
|
|
|
"https://oauth.vk.com/authorize?client_id=6102407" \ |
|
|
|
|
|
|
45
|
|
|
"&redirect_uri=http://luxvk.com&response_type=code", |
|
46
|
|
|
"https://login.vk.com/?act=connect_authorize", |
|
|
|
|
|
|
47
|
|
|
"https://api.vk.com/method/auth.getOauthCode?v=5.207&client_id=6102407", |
|
|
|
|
|
|
48
|
|
|
"http://luxvk.com/" |
|
|
|
|
|
|
49
|
|
|
) |
|
50
|
|
|
self.vkid_auth_link: Optional[str] = None |
|
51
|
|
|
self.auth_part_pattern: str = r'"auth":\s*{\s*"(?:\w+|_\w+)"\s*:\s*"(.*?)",\s*' \ |
|
52
|
|
|
r'"(?:\w+|_\w+)"\s*:\s*"(.*?)",\s*"(?:\w+|_\w+)"\s*:\s*([0-9]+),\s*"(?:\w+|_\w+)"' \ |
|
53
|
|
|
r'\s*:\s*([0-9]+),\s*"(?:\w+|_\w+)"\s*:\s*([0-9]+)\s*}' |
|
54
|
|
|
self.main_headers: Dict[str, str] = { |
|
55
|
|
|
"user-agent": user_agent |
|
56
|
|
|
} |
|
57
|
|
|
self.connect_auth_data: Dict[str, str] = { |
|
58
|
|
|
"username": username, |
|
59
|
|
|
"password": password, |
|
60
|
|
|
"sid": "", |
|
61
|
|
|
"uuid": "", |
|
62
|
|
|
"v": "5.207", |
|
63
|
|
|
"version": 1, |
|
64
|
|
|
"app_id": "6102407", |
|
65
|
|
|
} |
|
66
|
|
|
self.oauth_code_data: Dict[str, str] = { |
|
67
|
|
|
"redirect_uri": "http://luxvk.com", |
|
68
|
|
|
"app_id": "6102407", |
|
69
|
|
|
} |
|
70
|
|
|
self.code: Optional[str] = None |
|
71
|
|
|
|