Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
Terabox ddl

- Switched back to pyro.

Signed-off-by: Dawn India <[email protected]>
  • Loading branch information
Dawn-India committed Aug 17, 2024
1 parent 2039c74 commit 5602036
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 37 deletions.
61 changes: 27 additions & 34 deletions bot/helper/task_utils/download_utils/direct_link_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from uuid import uuid4
from base64 import b64decode

from bot import config_dict
from bot import LOGGER, config_dict
from bot.helper.ext_utils.exceptions import DirectDownloadLinkException
from bot.helper.ext_utils.help_messages import PASSWORD_ERROR_MESSAGE
from bot.helper.ext_utils.links_utils import is_share_link
Expand Down Expand Up @@ -158,6 +158,7 @@ def direct_link_generator(link):
"terabox.app",
"gibibox.com",
"goaibox.com",
"terasharelink.com",
]
):
return terabox(link)
Expand Down Expand Up @@ -641,7 +642,6 @@ def uploadee(url):

def terabox(url):
"""Terabox direct link generator
Based on https://github.com/r0ld3x/terabox-downloader-bot
By: https://github.com/Dawn-India"""

pattern1 = r"/s/(\w+)"
Expand All @@ -661,12 +661,11 @@ def terabox(url):
netloc = urlparse(url).netloc
url = url.replace(
netloc,
"1024terabox.com"
"1024tera.com"
)

response = get(url)
if response.status_code != 200:
raise DirectDownloadLinkException("ERROR: Unable to fetch the page")
raise DirectDownloadLinkException("ERROR: Unable to fetch the webpage")

headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0",
Expand All @@ -686,38 +685,32 @@ def terabox(url):
json={"url": url}
)
if response.status_code != 200:
raise DirectDownloadLinkException("ERROR: Unable to fetch the page")

response_data = response.json()
responses = response_data.get(
"response",
[]
)
if not responses:
raise DirectDownloadLinkException("ERROR: No response found")

resolutions = responses[0].get(
"resolutions",
{}
)
if not resolutions:
raise DirectDownloadLinkException("ERROR: No resolutions found")
raise DirectDownloadLinkException("ERROR: Unable to fetch the JSON data")

download = resolutions.get(
"Fast Download",
""
)
video = resolutions.get(
"HD Video",
""
)
data = response.json()
details = {"contents": [], "title": "", "total_size": 0}

return (
download
if download
else video
)
for item in data["response"]:
title = item["title"]
resolutions = item.get(
"resolutions",
{}
)
zlink = resolutions.get("HD Video")
if zlink:
details["contents"].append({
"url": zlink,
"filename": title,
"path": ospath.join(
title,
"HD_Video"
)
})
details["title"] = title

if len(details["contents"]) == 1:
return details["contents"][0]["url"]
return details


def filepress(url):
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/task_utils/status_utils/telegram_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def __init__(self, listener, obj, gid, status):
self._size = self.listener.size
self._gid = gid
self._status = status
self.engine = f"NekoZee v{self._eng_ver()}"
self.engine = f"PyroZee v{self._eng_ver()}"

def _eng_ver(self):
return get_distribution("nekozee").version
return get_distribution("pyrozee").version

def processed_bytes(self):
return get_readable_file_size(self._obj.processed_bytes)
Expand Down
2 changes: 1 addition & 1 deletion bot/modules/bot_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ async def edit_variable(message, pre_message, key):
s
)
elif key == "SET_COMMANDS":
await set_commands(client)
await set_commands(bot)


async def edit_aria(message, pre_message, key):
Expand Down

0 comments on commit 5602036

Please sign in to comment.