Fixed support for mirror of video and audio telegram files
Signed-off-by: lzzy12 <jhashivam2020@gmail.com>
This commit is contained in:
parent
d6a513e77b
commit
7d74cf29d8
|
|
@ -68,7 +68,12 @@ class TelegramDownloadHelper(DownloadHelper):
|
||||||
_message = self.__user_bot.get_messages(bot.get_me().id, message.message_id)
|
_message = self.__user_bot.get_messages(bot.get_me().id, message.message_id)
|
||||||
else:
|
else:
|
||||||
_message = self.__user_bot.get_messages(message.chat.id, message.message_id)
|
_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:
|
if media is not None:
|
||||||
with global_lock:
|
with global_lock:
|
||||||
# For avoiding locking the thread lock for long time unnecessarily
|
# For avoiding locking the thread lock for long time unnecessarily
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,25 @@
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
import requests
|
||||||
from telegram.ext import CommandHandler, run_async
|
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 import Interval, INDEX_URL
|
||||||
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 dispatcher, DOWNLOAD_DIR, DOWNLOAD_STATUS_UPDATE_INTERVAL, download_dict, download_dict_lock
|
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.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.ext_utils.bot_utils import setInterval
|
||||||
from bot.helper.telegram_helper.filters import CustomFilters
|
from bot.helper.ext_utils.exceptions import DirectDownloadLinkException
|
||||||
from bot.helper.telegram_helper.bot_commands import BotCommands
|
from bot.helper.mirror_utils.download_utils import aria2_download
|
||||||
import pathlib
|
|
||||||
import os
|
|
||||||
from bot.helper.mirror_utils.download_utils.direct_link_generator import direct_link_generator
|
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.mirror_utils.download_utils.telegram_downloader import TelegramDownloadHelper
|
||||||
from bot.helper.ext_utils.exceptions import DirectDownloadLinkException
|
from bot.helper.mirror_utils.status_utils import listeners
|
||||||
import requests
|
from bot.helper.mirror_utils.status_utils.tar_status import TarStatus
|
||||||
import threading
|
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):
|
class MirrorListener(listeners.MirrorListeners):
|
||||||
def __init__(self, bot, update, isTar=False, tag=None):
|
def __init__(self, bot, update, isTar=False, tag=None):
|
||||||
|
|
@ -142,12 +144,18 @@ def _mirror(bot, update, isTar=False):
|
||||||
link = link.strip()
|
link = link.strip()
|
||||||
reply_to = update.message.reply_to_message
|
reply_to = update.message.reply_to_message
|
||||||
if reply_to is not None:
|
if reply_to is not None:
|
||||||
|
file = None
|
||||||
tag = reply_to.from_user.username
|
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 len(link) == 0:
|
||||||
if document is not None:
|
if file is not None:
|
||||||
if document.file_size <= 20 * 1024 * 1024:
|
if file.file_size <= 20 * 1024 * 1024:
|
||||||
link = document.get_file().file_path
|
link = file.get_file().file_path
|
||||||
else:
|
else:
|
||||||
listener = MirrorListener(bot, update, isTar, tag)
|
listener = MirrorListener(bot, update, isTar, tag)
|
||||||
tg_downloader = TelegramDownloadHelper(listener)
|
tg_downloader = TelegramDownloadHelper(listener)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue