Fixed support for mirror of video and audio telegram files

Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
lzzy12 2020-03-22 15:55:59 +05:30
parent d6a513e77b
commit 7d74cf29d8
2 changed files with 32 additions and 19 deletions

View File

@ -68,7 +68,12 @@ class TelegramDownloadHelper(DownloadHelper):
_message = self.__user_bot.get_messages(bot.get_me().id, message.message_id)
else:
_message = self.__user_bot.get_messages(message.chat.id, message.message_id)
media = _message.document
media = None
media_array = [_message.document, _message.video, _message.audio]
for i in media_array:
if i is not None:
media = i
break
if media is not None:
with global_lock:
# For avoiding locking the thread lock for long time unnecessarily

View File

@ -1,23 +1,25 @@
import os
import pathlib
import requests
from telegram.ext import CommandHandler, run_async
from bot.helper.mirror_utils.status_utils import listeners
from bot.helper.mirror_utils.upload_utils import gdriveTools
from bot.helper.mirror_utils.download_utils import aria2_download
from bot.helper.mirror_utils.status_utils.upload_status import UploadStatus
from bot.helper.mirror_utils.status_utils.tar_status import TarStatus
from bot import Interval, INDEX_URL
from bot import dispatcher, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, download_dict, download_dict_lock
from bot.helper.ext_utils import fs_utils, bot_utils
from bot import Interval, INDEX_URL
from bot.helper.telegram_helper.message_utils import *
from bot.helper.ext_utils.bot_utils import setInterval
from bot.helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper.bot_commands import BotCommands
import pathlib
import os
from bot.helper.ext_utils.exceptions import DirectDownloadLinkException
from bot.helper.mirror_utils.download_utils import aria2_download
from bot.helper.mirror_utils.download_utils.direct_link_generator import direct_link_generator
from bot.helper.mirror_utils.download_utils.telegram_downloader import TelegramDownloadHelper
from bot.helper.ext_utils.exceptions import DirectDownloadLinkException
import requests
import threading
from bot.helper.mirror_utils.status_utils import listeners
from bot.helper.mirror_utils.status_utils.tar_status import TarStatus
from bot.helper.mirror_utils.status_utils.upload_status import UploadStatus
from bot.helper.mirror_utils.upload_utils import gdriveTools
from bot.helper.telegram_helper.bot_commands import BotCommands
from bot.helper.telegram_helper.filters import CustomFilters
from bot.helper.telegram_helper.message_utils import *
class MirrorListener(listeners.MirrorListeners):
def __init__(self, bot, update, isTar=False, tag=None):
@ -142,12 +144,18 @@ def _mirror(bot, update, isTar=False):
link = link.strip()
reply_to = update.message.reply_to_message
if reply_to is not None:
file = None
tag = reply_to.from_user.username
document = reply_to.document
media_array = [reply_to.document, reply_to.video, reply_to.audio]
for i in media_array:
if i is not None:
file = i
break
if len(link) == 0:
if document is not None:
if document.file_size <= 20 * 1024 * 1024:
link = document.get_file().file_path
if file is not None:
if file.file_size <= 20 * 1024 * 1024:
link = file.get_file().file_path
else:
listener = MirrorListener(bot, update, isTar, tag)
tg_downloader = TelegramDownloadHelper(listener)