Fix IO Block on Large Playlists
This commit is contained in:
parent
236b6eb30e
commit
8624e0174b
|
|
@ -1,7 +1,6 @@
|
|||
from .download_helper import DownloadHelper
|
||||
import time
|
||||
from youtube_dl import YoutubeDL, DownloadError
|
||||
import threading
|
||||
from bot import download_dict_lock, download_dict
|
||||
from ..status_utils.youtube_dl_download_status import YoutubeDLDownloadStatus
|
||||
import logging
|
||||
|
|
@ -139,6 +138,7 @@ class YoutubeDLHelper(DownloadHelper):
|
|||
self.onDownloadError("Download Cancelled by User!")
|
||||
|
||||
def add_download(self, link, path):
|
||||
self.__onDownloadStart()
|
||||
self.extractMetaData(link)
|
||||
LOGGER.info(f"Downloading with YT-DL: {link}")
|
||||
self.__gid = f"{self.vid_id}{self.__listener.uid}"
|
||||
|
|
@ -146,9 +146,7 @@ class YoutubeDLHelper(DownloadHelper):
|
|||
self.opts['outtmpl'] = f"{path}/{self.name}"
|
||||
else:
|
||||
self.opts['outtmpl'] = f"{path}/{self.name}/%(title)s.%(ext)s"
|
||||
|
||||
self.__onDownloadStart()
|
||||
threading.Thread(target=self.__download, args=(link,)).start()
|
||||
self.__download(link)
|
||||
|
||||
def cancel_download(self):
|
||||
self.is_cancelled = True
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from .mirror import MirrorListener
|
|||
from bot.helper.mirror_utils.download_utils.youtube_dl_download_helper import YoutubeDLHelper
|
||||
from bot.helper.telegram_helper.bot_commands import BotCommands
|
||||
from bot.helper.telegram_helper.filters import CustomFilters
|
||||
import threading
|
||||
|
||||
|
||||
def _watch(bot: Bot, update: Update, args: list, isTar=False):
|
||||
|
|
@ -23,7 +24,7 @@ def _watch(bot: Bot, update: Update, args: list, isTar=False):
|
|||
|
||||
listener = MirrorListener(bot, update, isTar, tag)
|
||||
ydl = YoutubeDLHelper(listener)
|
||||
ydl.add_download(link, f'{DOWNLOAD_DIR}{listener.uid}')
|
||||
threading.Thread(target=ydl.add_download,args=(link, f'{DOWNLOAD_DIR}{listener.uid}')).start()
|
||||
sendStatusMessage(update, bot)
|
||||
if len(Interval) == 0:
|
||||
Interval.append(setInterval(DOWNLOAD_STATUS_UPDATE_INTERVAL, update_all_messages))
|
||||
|
|
|
|||
Loading…
Reference in New Issue