Skip to content

Commit

Permalink
Minor change
Browse files Browse the repository at this point in the history
Minor fix and sync f97076b

Co-Authored-By: RK Shaju <[email protected]>
  • Loading branch information
rk-shaju authored and Dawn-India committed Nov 15, 2024
1 parent 8172d4f commit b3b089b
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
zee_env/*
config.env
*.pyc
data*
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /usr/src/app
RUN chmod 777 /usr/src/app

COPY requirements.txt .
RUN pip3 install --break-system-packages --no-cache-dir -r requirements.txt
RUN zee_env/bin/pip3.12 install --no-cache-dir -r requirements.txt

COPY . .

Expand Down
2 changes: 1 addition & 1 deletion bot/helper/ext_utils/help_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
name_sub = r"""
<b>Name Substitution</b>: -ns
b>Name Substitution</b>: -ns
<b>Name Substitution</b>: -ns
/cmd link -ns script/code/s | mirror/leech | tea/ /s | clone | cpu/ | \[ZEE\]/ZEE | \\text\\/text/s
This will affect on all files. Format: wordToReplace/wordToReplaceWith/sensitiveCase
Word Subtitions. You can add pattern instead of normal text. Timeout: 60 sec
Expand Down
27 changes: 17 additions & 10 deletions bot/helper/task_utils/download_utils/direct_link_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from ...ext_utils.links_utils import is_share_link
from ...ext_utils.status_utils import speed_string_to_bytes


user_agent = (
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0"
)
Expand All @@ -42,7 +41,7 @@ def direct_link_generator(link):
domain = urlparse(link).hostname
if not domain:
raise DirectDownloadLinkException("ERROR: Invalid URL")
if "yadi.sk" in link or "disk.yandex." in link:
elif "yadi.sk" in link or "disk.yandex." in link:
return yandex_disk(link)
elif "mediafire.com" in domain:
return mediafire(link)
Expand All @@ -54,7 +53,14 @@ def direct_link_generator(link):
return hxfile(link)
elif "1drv.ms" in domain:
return onedrive(link)
elif "pixeldrain.com" in domain:
elif any(
x in domain
for x
in [
"pixeldrain.com",
"pixeldra.in"
]
):
return pixeldrain(link)
elif "racaty" in domain:
return racaty(link)
Expand Down Expand Up @@ -448,11 +454,11 @@ def pixeldrain(url):
url = url.strip("/ ")
file_id = url.split("/")[-1]
if url.split("/")[-2] == "l":
info_link = f"https://pixeldrain.com/api/list/{file_id}"
dl_link = f"https://pixeldrain.com/api/list/{file_id}/zip?download"
info_link = f"https://pixeldra.in/api/list/{file_id}"
dl_link = f"https://pixeldra.in/api/list/{file_id}/zip?download"
else:
info_link = f"https://pixeldrain.com/api/file/{file_id}/info"
dl_link = f"https://pixeldrain.com/api/file/{file_id}?download"
info_link = f"https://pixeldra.in/api/file/{file_id}/info"
dl_link = f"https://pixeldra.in/api/file/{file_id}?download"
with create_scraper() as session:
try:
resp = session.get(info_link).json()
Expand All @@ -462,10 +468,11 @@ def pixeldrain(url):
return dl_link
else:
raise DirectDownloadLinkException(
f"ERROR: Cant't download due {resp['message']}."
f"ERROR: Can't download due to {resp['message']}."
)



def streamtape(url):
splitted_url = url.split("/")
_id = (
Expand Down Expand Up @@ -1107,11 +1114,11 @@ def __get_token(session):
"Accept": "*/*",
"Connection": "keep-alive",
}
__url = f"https://api.gofile.io/accounts"
__url = "https://api.gofile.io/accounts"
try:
__res = session.post(__url, headers=headers).json()
if __res["status"] != "ok":
raise DirectDownloadLinkException(f"ERROR: Failed to get token.")
raise DirectDownloadLinkException("ERROR: Failed to get token.")
return __res["data"]["token"]
except Exception as e:
raise e
Expand Down
10 changes: 5 additions & 5 deletions bot/helper/task_utils/download_utils/yt_dlp_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def __init__(self, listener):
self._eta = "-"
self._listener = listener
self._gid = ""
self._downloading = False
self._ext = ""
self.is_playlist = False
self.playlist_index = 0
Expand Down Expand Up @@ -123,7 +122,6 @@ def eta(self):
return self._eta

def _on_download_progress(self, d):
self._downloading = True
if self._listener.is_cancelled:
raise ValueError("Cancelling...")
if d["status"] == "finished":
Expand Down Expand Up @@ -438,8 +436,7 @@ async def add_download(self, path, qual, playlist, options):
async def cancel_task(self):
self._listener.is_cancelled = True
LOGGER.info(f"Cancelling Download: {self._listener.name}")
if not self._downloading:
await self._listener.on_download_error("Download Cancelled by User!")
await self._listener.on_download_error("Download Cancelled by User!")

def _set_options(self, options):
options = options.split("|")
Expand Down Expand Up @@ -487,7 +484,10 @@ def _set_options(self, options):
list
):
self.opts[key].extend(tuple(value))
elif isinstance(value, dict):
elif isinstance(
value,
dict
):
self.opts[key].append(value)
elif key == "download_ranges":
if isinstance(value, list):
Expand Down
30 changes: 14 additions & 16 deletions bot/helper/task_utils/telegram_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ async def _send_media_group(self, subkey, key, msgs):
msgs_list
)
dm_msgs_list = await self._sent_DMmsg.reply_media_group(
media=grouped_media,
media=grouped_media, # type: ignore
quote=True
)
self._sent_DMmsg = dm_msgs_list[-1]
Expand Down Expand Up @@ -572,20 +572,18 @@ async def upload(self, o_files, ft_delete):
self._corrupted += 1
if self._listener.is_cancelled:
return
continue
finally:
if (
not self._listener.is_cancelled
and await aiopath.exists(self._up_path)
and (
not self._listener.seed
or self._listener.new_dir
or dirpath.endswith("/splited_files_zee")
or "/copied_zee/" in self._up_path
or delete_file
)
):
await remove(self._up_path)
if (
not self._listener.is_cancelled
and await aiopath.exists(self._up_path)
and (
not self._listener.seed
or self._listener.new_dir
or dirpath.endswith("/splited_files_zee")
or "/copied_zee/" in self._up_path
or delete_file
)
):
await remove(self._up_path)
for (
key,
value
Expand Down Expand Up @@ -884,7 +882,7 @@ async def _upload_file(self, cap_mono, file, o_path, force_document=False):
LOGGER.error(f"{err_type}{err}. Path: {self._up_path}")
if (
"Telegram says: [400" in str(err)
and key != "documents"
and key != "documents" # type: ignore
):
LOGGER.error(f"Retrying As Document. Path: {self._up_path}")
return await self._upload_file(
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ aria2p
asyncio
bencoding
cloudscraper
cryptography
dnspython
feedparser
flask
Expand Down
4 changes: 3 additions & 1 deletion start.sh
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
python3 update.py && python3 -m bot
source zee_env/bin/activate
python3 update.py
python3 -m bot

0 comments on commit b3b089b

Please sign in to comment.