@@ -24,12 +24,8 @@ def direct_link_generator(link: str):
24
24
""" direct links generator """
25
25
if not link :
26
26
raise DirectDownloadLinkException ("`No links found!`" )
27
- if 'drive.google.com' in link :
28
- return gdrive (link )
29
27
elif 'zippyshare.com' in link :
30
28
return zippy_share (link )
31
- elif 'mega.' in link :
32
- return mega_dl (link )
33
29
elif 'yadi.sk' in link :
34
30
return yandex_disk (link )
35
31
elif 'cloud.mail.ru' in link :
@@ -40,49 +36,10 @@ def direct_link_generator(link: str):
40
36
return osdn (link )
41
37
elif 'github.com' in link :
42
38
return github (link )
43
- elif 'androidfilehost.com' in link :
44
- return androidfilehost (link )
45
39
else :
46
40
raise DirectDownloadLinkException (f'No Direct link function found for { link } ' )
47
41
48
42
49
- def gdrive (url : str ) -> str :
50
- """ GDrive direct links generator """
51
- drive = 'https://drive.google.com'
52
- try :
53
- link = re .findall (r'\bhttps?://drive\.google\.com\S+' , url )[0 ]
54
- except IndexError :
55
- reply = "`No Google drive links found`\n "
56
- return reply
57
- file_id = ''
58
- if link .find ("view" ) != - 1 :
59
- file_id = link .split ('/' )[- 2 ]
60
- elif link .find ("open?id=" ) != - 1 :
61
- file_id = link .split ("open?id=" )[1 ].strip ()
62
- elif link .find ("uc?id=" ) != - 1 :
63
- file_id = link .split ("uc?id=" )[1 ].strip ()
64
- url = f'{ drive } /uc?export=download&id={ file_id } '
65
- download = requests .get (url , stream = True , allow_redirects = False )
66
- cookies = download .cookies
67
- try :
68
- # In case of small file size, Google downloads directly
69
- dl_url = download .headers ["location" ]
70
- if 'accounts.google.com' in dl_url : # non-public file
71
- raise DirectDownloadLinkException ('`Link not public`' )
72
- except KeyError :
73
- # In case of download warning page
74
- page = BeautifulSoup (download .content , 'lxml' )
75
- export = drive + page .find ('a' , {'id' : 'uc-download-link' }).get ('href' )
76
- response = requests .get (export ,
77
- stream = True ,
78
- allow_redirects = False ,
79
- cookies = cookies )
80
- dl_url = response .headers ['location' ]
81
- if 'accounts.google.com' in dl_url :
82
- raise DirectDownloadLinkException ('`Link not public`' )
83
- return dl_url
84
-
85
-
86
43
def zippy_share (url : str ) -> str :
87
44
""" ZippyShare direct links generator
88
45
Based on https://github.com/LameLemon/ziggy"""
@@ -125,23 +82,6 @@ def yandex_disk(url: str) -> str:
125
82
raise DirectDownloadLinkException ("`Error: File not found / Download limit reached`\n " )
126
83
127
84
128
- def mega_dl (url : str ) -> str :
129
- """ MEGA.nz direct links generator
130
- Using https://github.com/tonikelope/megadown"""
131
- try :
132
- link = re .findall (r'\bhttps?://.*mega.*\.nz\S+' , url )[0 ]
133
- except IndexError :
134
- raise DirectDownloadLinkException ("`No MEGA.nz links found`\n " )
135
- command = f'vendor/megadown/megadown -q -m { link } '
136
- result = popen (command ).read ()
137
- try :
138
- data = json .loads (result )
139
- except json .JSONDecodeError :
140
- raise DirectDownloadLinkException ("`Error: Can't extract the link`\n " )
141
- dl_url = data ['url' ]
142
- return dl_url
143
-
144
-
145
85
def cm_ru (url : str ) -> str :
146
86
""" cloud.mail.ru direct links generator
147
87
Using https://github.com/JrMasterModelBuilder/cmrudl.py"""
@@ -206,49 +146,6 @@ def github(url: str) -> str:
206
146
raise DirectDownloadLinkException ("`Error: Can't extract the link`\n " )
207
147
208
148
209
- def androidfilehost (url : str ) -> str :
210
- """ AFH direct links generator """
211
- try :
212
- link = re .findall (r'\bhttps?://.*androidfilehost.*fid.*\S+' , url )[0 ]
213
- except IndexError :
214
- raise DirectDownloadLinkException ("`No AFH links found`\n " )
215
- fid = re .findall (r'\?fid=(.*)' , link )[0 ]
216
- session = requests .Session ()
217
- user_agent = useragent ()
218
- headers = {'user-agent' : user_agent }
219
- res = session .get (link , headers = headers , allow_redirects = True )
220
- headers = {
221
- 'origin' : 'https://androidfilehost.com' ,
222
- 'accept-encoding' : 'gzip, deflate, br' ,
223
- 'accept-language' : 'en-US,en;q=0.9' ,
224
- 'user-agent' : user_agent ,
225
- 'content-type' : 'application/x-www-form-urlencoded; charset=UTF-8' ,
226
- 'x-mod-sbb-ctype' : 'xhr' ,
227
- 'accept' : '*/*' ,
228
- 'referer' : f'https://androidfilehost.com/?fid={ fid } ' ,
229
- 'authority' : 'androidfilehost.com' ,
230
- 'x-requested-with' : 'XMLHttpRequest' ,
231
- }
232
- data = {
233
- 'submit' : 'submit' ,
234
- 'action' : 'getdownloadmirrors' ,
235
- 'fid' : f'{ fid } '
236
- }
237
- error = "`Error: Can't find Mirrors for the link`\n "
238
- try :
239
- req = session .post (
240
- 'https://androidfilehost.com/libs/otf/mirrors.otf.php' ,
241
- headers = headers ,
242
- data = data ,
243
- cookies = res .cookies )
244
- mirrors = req .json ()['MIRRORS' ]
245
- except (json .decoder .JSONDecodeError , TypeError ):
246
- raise DirectDownloadLinkException (error )
247
- if not mirrors :
248
- raise DirectDownloadLinkException (error )
249
- return mirrors [0 ]
250
-
251
-
252
149
def useragent ():
253
150
"""
254
151
useragent random setter
0 commit comments