Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:AttributeError:[#127] type object 'Translation' has no attribute … #128

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Hash Minner
Copyright (c) 2022 @kalanakt | www.netronk.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
111 changes: 49 additions & 62 deletions Uploader/button.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
# MIT License

# Copyright (c) 2022 Hash Minner

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE

import os
import json
import time
Expand All @@ -33,14 +11,16 @@
from Uploader.functions.ran_text import random_char
from Uploader.functions.display_progress import progress_for_pyrogram, humanbytes

logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger(__name__)
logging.getLogger("pyrogram").setLevel(logging.WARNING)


logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger(__name__)


Expand All @@ -50,17 +30,21 @@ async def youtube_dl_call_back(bot, update):
tg_send_type, youtube_dl_format, youtube_dl_ext, ranom = cb_data.split("|")
print(cb_data)
random1 = random_char(5)
save_ytdl_json_path = Config.DOWNLOAD_LOCATION + \
"/" + str(update.from_user.id) + f'{ranom}' + ".json"
save_ytdl_json_path = (
Config.DOWNLOAD_LOCATION + "/" +
str(update.from_user.id) + f"{ranom}" + ".json"
)
try:
with open(save_ytdl_json_path, "r", encoding="utf8") as f:
response_json = json.load(f)
except (FileNotFoundError) as e:
except FileNotFoundError as e:
await update.message.delete()
return False
youtube_dl_url = update.message.reply_to_message.text
custom_file_name = str(response_json.get("title")) + \
"_" + youtube_dl_format + "." + youtube_dl_ext
custom_file_name = (
str(response_json.get("title")) + "_" +
youtube_dl_format + "." + youtube_dl_ext
)
youtube_dl_username = None
youtube_dl_password = None
if "|" in youtube_dl_url:
Expand All @@ -80,7 +64,7 @@ async def youtube_dl_call_back(bot, update):
elif entity.type == "url":
o = entity.offset
l = entity.length
youtube_dl_url = youtube_dl_url[o:o + l]
youtube_dl_url = youtube_dl_url[o: o + l]
if youtube_dl_url is not None:
youtube_dl_url = youtube_dl_url.strip()
if custom_file_name is not None:
Expand All @@ -99,17 +83,18 @@ async def youtube_dl_call_back(bot, update):
elif entity.type == "url":
o = entity.offset
l = entity.length
youtube_dl_url = youtube_dl_url[o:o + l]
youtube_dl_url = youtube_dl_url[o: o + l]
await update.message.edit_caption(
caption=Translation.DOWNLOAD_START.format(custom_file_name)

)
description = Translation.CUSTOM_CAPTION_UL_FILE
if "fulltitle" in response_json:
description = response_json["fulltitle"][:1021]
# escape Markdown and special characters
tmp_directory_for_each_user = Config.DOWNLOAD_LOCATION + \
"/" + str(update.from_user.id) + f'{random1}'
tmp_directory_for_each_user = (
Config.DOWNLOAD_LOCATION + "/" +
str(update.from_user.id) + f"{random1}"
)
if not os.path.isdir(tmp_directory_for_each_user):
os.makedirs(tmp_directory_for_each_user)
download_directory = f"{tmp_directory_for_each_user}/{custom_file_name}"
Expand All @@ -119,13 +104,17 @@ async def youtube_dl_call_back(bot, update):
command_to_exec = [
"yt-dlp",
"-c",
"--max-filesize", str(Config.TG_MAX_FILE_SIZE),
"--max-filesize",
str(Config.TG_MAX_FILE_SIZE),
"--bidi-workaround",
"--extract-audio",
"--audio-format", youtube_dl_ext,
"--audio-quality", youtube_dl_format,
"--audio-format",
youtube_dl_ext,
"--audio-quality",
youtube_dl_format,
youtube_dl_url,
"-o", download_directory
"-o",
download_directory,
]
else:
# command_to_exec = ["yt-dlp", "-f", youtube_dl_format, "--hls-prefer-ffmpeg", "--recode-video", "mp4", "-k", youtube_dl_url, "-o", download_directory]
Expand All @@ -135,12 +124,15 @@ async def youtube_dl_call_back(bot, update):
command_to_exec = [
"yt-dlp",
"-c",
"--max-filesize", str(Config.TG_MAX_FILE_SIZE),
"--max-filesize",
str(Config.TG_MAX_FILE_SIZE),
"--embed-subs",
"-f", minus_f_format,
"-f",
minus_f_format,
"--bidi-workaround",
youtube_dl_url,
"-o", download_directory
"-o",
download_directory,
]

if Config.HTTP_PROXY != "":
Expand Down Expand Up @@ -171,10 +163,7 @@ async def youtube_dl_call_back(bot, update):
ad_string_to_replace = "please report this issue on https://github.com/kalanakt/All-Url-Uploader/issues"
if e_response and ad_string_to_replace in e_response:
error_message = e_response.replace(ad_string_to_replace, "")
await update.message.edit_caption(

text=error_message
)
await update.message.edit_caption(text=error_message)
return False

if t_response:
Expand All @@ -199,17 +188,15 @@ async def youtube_dl_call_back(bot, update):
thumb = download_location if os.path.isfile(
download_location) else None

if ((file_size > Config.TG_MAX_FILE_SIZE)):
if file_size > Config.TG_MAX_FILE_SIZE:
await update.message.edit_caption(

caption=Translation.RCHD_TG_API_LIMIT.format(
time_taken_for_download, humanbytes(file_size))

time_taken_for_download, humanbytes(file_size)
)
)
else:
await update.message.edit_caption(
caption=Translation.UPLOAD_START.format(custom_file_name)

)
start_time = time.time()
if tg_send_type == "video":
Expand All @@ -228,8 +215,8 @@ async def youtube_dl_call_back(bot, update):
progress_args=(
Translation.UPLOAD_START,
update.message,
start_time
)
start_time,
),
)
elif tg_send_type == "audio":
duration = await Mdata03(download_directory)
Expand All @@ -244,8 +231,8 @@ async def youtube_dl_call_back(bot, update):
progress_args=(
Translation.UPLOAD_START,
update.message,
start_time
)
start_time,
),
)
elif tg_send_type == "vm":
width, duration = await Mdata02(download_directory)
Expand All @@ -260,8 +247,8 @@ async def youtube_dl_call_back(bot, update):
progress_args=(
Translation.UPLOAD_START,
update.message,
start_time
)
start_time,
),
)
else:
await update.message.reply_document(
Expand All @@ -275,8 +262,8 @@ async def youtube_dl_call_back(bot, update):
progress_args=(
Translation.UPLOAD_START,
update.message,
start_time
)
start_time,
),
)

end_two = datetime.now()
Expand All @@ -287,8 +274,8 @@ async def youtube_dl_call_back(bot, update):
pass
await update.message.edit_caption(
caption=Translation.AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS.format(
time_taken_for_download, time_taken_for_upload)

time_taken_for_download, time_taken_for_upload
)
)

logger.info(f"Downloaded in: {str(time_taken_for_download)}")
Expand Down
28 changes: 4 additions & 24 deletions Uploader/callbacks.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
# MIT License

# Copyright (c) 2022 Hash Minner

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE

from Uploader.dl_button import ddl_call_back
from Uploader.button import youtube_dl_call_back
from Uploader.script import Translation
from pyrogram import Client
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger(__name__)


Expand Down
22 changes: 0 additions & 22 deletions Uploader/commands.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
# MIT License

# Copyright (c) 2022 Hash Minner

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE

from pyrogram import Client, filters
from pyrogram.types import Message
from Uploader.script import Translation
Expand Down
Loading
Loading