@@ -711,10 +711,41 @@ def uploadee(url):
711711
712712def terabox (url ):
713713 try :
714- encoded_url = quote (url )
715- return f"https://teradlrobot.cheemsbackup.workers.dev/?url={ encoded_url } "
714+ def find_key (data : dict , keyword : str ) -> str :
715+ for key in data :
716+ if keyword .lower () in key .lower ():
717+ return key
718+ return None
719+
720+ encoded_url = quote (url , safe = '' )
721+ api_url = f"https://wdzone-terabox-api.vercel.app/api?url={ encoded_url } "
722+
723+ headers = {
724+ "User-Agent" : (
725+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
726+ "AppleWebKit/537.36 (KHTML, like Gecko) "
727+ "Chrome/135.0.0.0 Safari/537.36"
728+ )
729+ }
730+
731+ resp = get (api_url , headers = headers )
732+ if resp .status_code != 200 :
733+ raise DirectDownloadLinkException (f"API returned status { resp .status_code } " )
734+
735+ data = resp .json ()
736+ info_key = find_key (data , "Extracted Info" )
737+ info_list = data .get (info_key , [])
738+
739+ if isinstance (info_list , list ) and info_list :
740+ link_key = find_key (info_list [0 ], "Direct Download Link" )
741+ download_link = info_list [0 ].get (link_key )
742+ if download_link and download_link .startswith ("http" ):
743+ return download_link
744+
745+ raise DirectDownloadLinkException (f"No usable download link found." )
746+
716747 except Exception as e :
717- raise DirectDownloadLinkException ("Failed to bypass Terabox URL" ) from e
748+ raise DirectDownloadLinkException (f "Failed to get direct link: { e } " )
718749
719750
720751def filepress (url ):
0 commit comments