diff options
author | Alex Shnitman <alexta69@gmail.com> | 2021-11-20 09:48:11 +0200 |
---|---|---|
committer | Alex Shnitman <alexta69@gmail.com> | 2021-11-20 09:48:11 +0200 |
commit | 829cc8e5b09f9ea863ef7b6649ede706ce2d9bec (patch) | |
tree | d496c4a804bcb1fc5bda4ba2ef60e5b9af618a21 /app | |
parent | dl_formats options are now inline (diff) | |
parent | fix breakage after upgrade (diff) | |
download | metube-829cc8e5b09f9ea863ef7b6649ede706ce2d9bec.tar.gz metube-829cc8e5b09f9ea863ef7b6649ede706ce2d9bec.tar.bz2 metube-829cc8e5b09f9ea863ef7b6649ede706ce2d9bec.zip |
Merge branch 'master' of https://github.com/alexta69/metube into mp3-support
Diffstat (limited to 'app')
-rw-r--r-- | app/ytdl.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/ytdl.py b/app/ytdl.py index 63c3786..688744b 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -85,7 +85,7 @@ class Download: self.notifier = notifier
self.info.status = 'preparing'
await self.notifier.updated(self.info)
- asyncio.ensure_future(self.update_status())
+ asyncio.create_task(self.update_status())
return await self.loop.run_in_executor(None, self.proc.join)
def cancel(self):
@@ -129,8 +129,13 @@ class DownloadQueue: self.notifier = notifier
self.queue = OrderedDict()
self.done = OrderedDict()
- self.event = asyncio.Event()
- asyncio.ensure_future(self.__download())
+ self.initialized = False
+
+ def __initialize(self):
+ if not self.initialized:
+ self.initialized = True
+ self.event = asyncio.Event()
+ asyncio.create_task(self.__download())
def __extract_info(self, url):
return yt_dlp.YoutubeDL(params={
@@ -165,6 +170,7 @@ class DownloadQueue: async def add(self, url, quality, format, already=None):
log.info(f'adding {url}')
+ self.__initialize()
already = set() if already is None else already
if url in already:
log.info('recursion detected, skipping')
|