@@ -40,6 +40,8 @@ def direct_link_generator(link):
4040 return uploadhaven (link )
4141 elif "fuckingfast.co" in domain :
4242 return fuckingfast_dl (link )
43+ elif "mediafile.cc" in domain :
44+ return mediafile (link )
4345 elif "mediafire.com" in domain :
4446 return mediafire (link )
4547 elif "osdn.net" in domain :
@@ -399,6 +401,30 @@ def uploadhaven(url):
399401 except Exception as e :
400402 raise DirectDownloadLinkException (f"ERROR: { str (e )} " ) from e
401403
404+ def mediafile (url ):
405+ """
406+ Generate a direct download link for mediafile.cc URLs.
407+ @param url: URL from mediafile.cc
408+ @return: Direct download link
409+ """
410+ try :
411+ res = get (url , allow_redirects = True )
412+ match = re .search (r"href='([^']+)'" , res .text )
413+ if not match :
414+ raise DirectDownloadLinkException ("ERROR: Unable to find link data" )
415+ download_url = match .group (1 )
416+ sleep (60 )
417+ res = get (download_url , headers = {'Referer' : url }, cookies = res .cookies )
418+ postvalue = re .search (r'showFileInformation(.*);' , res .text )
419+ if not postvalue :
420+ raise DirectDownloadLinkException ("ERROR: Unable to find post value" )
421+ postid = postvalue .group (1 ).replace ('(' ,'' ).replace (')' ,'' )
422+ response = post ('https://mediafile.cc/account/ajax/file_details' ,data = {"u" : postid }, headers = {"X-Requested-With" : "XMLHttpRequest" })
423+ html = response .json ()['html' ]
424+ return [i for i in re .findall (r'https://[^\s"\']+' , html ) if 'download_token' in i ][1 ]
425+ except Exception as e :
426+ raise DirectDownloadLinkException (f"ERROR: { str (e )} " ) from e
427+
402428def mediafire (url , session = None ):
403429 if "/folder/" in url :
404430 return mediafireFolder (url )
0 commit comments