2323 "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0"
2424)
2525
26+
2627def direct_link_generator (link ):
2728 """direct links generator"""
2829 domain = urlparse (link ).hostname
@@ -236,9 +237,10 @@ def buzzheavier(url):
236237 @param link: URL from buzzheavier
237238 @return: Direct download link
238239 """
239- pattern = r' ^https?://buzzheavier\.com/[a-zA-Z0-9]+$'
240+ pattern = r" ^https?://buzzheavier\.com/[a-zA-Z0-9]+$"
240241 if not match (pattern , url ):
241242 return url
243+
242244 def _bhscraper (url , folder = False ):
243245 session = Session ()
244246 if "/download" not in url :
@@ -262,10 +264,12 @@ def _bhscraper(url, folder=False):
262264 return d_url
263265 except Exception as e :
264266 raise DirectDownloadLinkException (f"ERROR: { str (e )} " ) from e
265-
267+
266268 with Session () as session :
267269 tree = HTML (session .get (url ).text )
268- if link := tree .xpath ("//a[contains(@class, 'link-button') and contains(@class, 'gay-button')]/@hx-get" ):
270+ if link := tree .xpath (
271+ "//a[contains(@class, 'link-button') and contains(@class, 'gay-button')]/@hx-get"
272+ ):
269273 return _bhscraper ("https://buzzheavier.com" + link [0 ])
270274 elif folders := tree .xpath ("//tbody[@id='tbody']/tr" ):
271275 details = {"contents" : [], "title" : "" , "total_size" : 0 }
@@ -279,8 +283,8 @@ def _bhscraper(url, folder=False):
279283 "path" : "" ,
280284 "filename" : filename ,
281285 "url" : url ,
282- }
283- details ["contents" ].append (item )
286+ }
287+ details ["contents" ].append (item )
284288 size = speed_string_to_bytes (size )
285289 details ["total_size" ] += size
286290 except :
@@ -377,28 +381,33 @@ def devuploads(url):
377381 direct_link = html .xpath ("//input[@name='orilink']/@value" )
378382 return direct_link [0 ]
379383
384+
380385def uploadhaven (url ):
381386 """
382387 Generate a direct download link for uploadhaven.com URLs.
383388 @param url: URL from uploadhaven.com
384389 @return: Direct download link
385390 """
386391 try :
387- res = get (url ,headers = {' Referer' : ' http://steamunlocked.net/' })
392+ res = get (url , headers = {" Referer" : " http://steamunlocked.net/" })
388393 html = HTML (res .text )
389394 if not html .xpath ('//form[@method="POST"]//input' ):
390- raise DirectDownloadLinkException ("ERROR: Unable to find link data" )
391- data = {i .get ("name" ): i .get ("value" ) for i in html .xpath ('//form[@method="POST"]//input' )}
395+ raise DirectDownloadLinkException ("ERROR: Unable to find link data" )
396+ data = {
397+ i .get ("name" ): i .get ("value" )
398+ for i in html .xpath ('//form[@method="POST"]//input' )
399+ }
392400 sleep (15 )
393- res = post (url , data = data , headers = {' Referer' : url }, cookies = res .cookies )
401+ res = post (url , data = data , headers = {" Referer" : url }, cookies = res .cookies )
394402 html = HTML (res .text )
395403 if not html .xpath ('//div[@class="alert alert-success mb-0"]//a' ):
396404 raise DirectDownloadLinkException ("ERROR: Unable to find link data" )
397405 a = html .xpath ('//div[@class="alert alert-success mb-0"]//a' )[0 ]
398- return a .get (' href' )
406+ return a .get (" href" )
399407 except Exception as e :
400408 raise DirectDownloadLinkException (f"ERROR: { str (e )} " ) from e
401409
410+
402411def mediafile (url ):
403412 """
404413 Generate a direct download link for mediafile.cc URLs.
@@ -409,20 +418,27 @@ def mediafile(url):
409418 res = get (url , allow_redirects = True )
410419 match = search (r"href='([^']+)'" , res .text )
411420 if not match :
412- raise DirectDownloadLinkException ("ERROR: Unable to find link data" )
421+ raise DirectDownloadLinkException ("ERROR: Unable to find link data" )
413422 download_url = match .group (1 )
414423 sleep (60 )
415- res = get (download_url , headers = {' Referer' : url }, cookies = res .cookies )
416- postvalue = search (r' showFileInformation(.*);' , res .text )
424+ res = get (download_url , headers = {" Referer" : url }, cookies = res .cookies )
425+ postvalue = search (r" showFileInformation(.*);" , res .text )
417426 if not postvalue :
418- raise DirectDownloadLinkException ("ERROR: Unable to find post value" )
419- postid = postvalue .group (1 ).replace ('(' ,'' ).replace (')' ,'' )
420- response = post ('https://mediafile.cc/account/ajax/file_details' ,data = {"u" : postid }, headers = {"X-Requested-With" : "XMLHttpRequest" })
421- html = response .json ()['html' ]
422- return [i for i in findall (r'https://[^\s"\']+' , html ) if 'download_token' in i ][1 ]
427+ raise DirectDownloadLinkException ("ERROR: Unable to find post value" )
428+ postid = postvalue .group (1 ).replace ("(" , "" ).replace (")" , "" )
429+ response = post (
430+ "https://mediafile.cc/account/ajax/file_details" ,
431+ data = {"u" : postid },
432+ headers = {"X-Requested-With" : "XMLHttpRequest" },
433+ )
434+ html = response .json ()["html" ]
435+ return [
436+ i for i in findall (r'https://[^\s"\']+' , html ) if "download_token" in i
437+ ][1 ]
423438 except Exception as e :
424439 raise DirectDownloadLinkException (f"ERROR: { str (e )} " ) from e
425440
441+
426442def mediafire (url , session = None ):
427443 if "/folder/" in url :
428444 return mediafireFolder (url )
@@ -779,7 +795,7 @@ def terabox(url):
779795 "path" : "" ,
780796 "filename" : data ["📂 Title" ],
781797 "url" : data ["🔽 Direct Download Link" ],
782- }
798+ }
783799 details ["contents" ].append (item )
784800 size = (data ["📏 Size" ]).replace (" " , "" )
785801 size = speed_string_to_bytes (size )
@@ -794,7 +810,7 @@ def terabox(url):
794810
795811def filepress (url ):
796812 try :
797- url = get (f"https://filebee.xyz/file/{ url .split ('/' )[- 1 ]} " ).url
813+ url = get (f"https://filebee.xyz/file/{ url .split ('/' )[- 1 ]} " ).url
798814 raw = urlparse (url )
799815 json_data = {
800816 "id" : raw .path .split ("/" )[- 1 ],
0 commit comments