aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex <alexta69@gmail.com>2022-02-17 19:33:09 +0200
committerGitHub <noreply@github.com>2022-02-17 19:33:09 +0200
commit865f698e71f98996c58e068e317224024ad137af (patch)
treed27125a12dfda0c1ade32d27e583131cb8edd6a4
parentupgraded yt-dlp (diff)
parentpass properties if they exist (diff)
downloadmetube-865f698e71f98996c58e068e317224024ad137af.tar.gz
metube-865f698e71f98996c58e068e317224024ad137af.tar.bz2
metube-865f698e71f98996c58e068e317224024ad137af.zip
Merge pull request #120 from almeidapaulopt/master (closes #107, closes #112)
add playlist parameters
-rw-r--r--app/ytdl.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/ytdl.py b/app/ytdl.py
index 6e406b0..38e29b8 100644
--- a/app/ytdl.py
+++ b/app/ytdl.py
@@ -210,8 +210,14 @@ class DownloadQueue:
if etype == 'playlist':
entries = entry['entries']
log.info(f'playlist detected with {len(entries)} entries')
+ playlist_index_digits = len(str(len(entries)))
results = []
- for etr in entries:
+ for index, etr in enumerate(entries, start=1):
+ etr["playlist"] = entry["id"]
+ etr["playlist_index"] = '{{0:0{0:d}d}}'.format(playlist_index_digits).format(index)
+ for property in ("id", "title", "uploader", "uploader_id"):
+ if property in entry:
+ etr[f"playlist_{property}"] = entry[property]
results.append(await self.__add_entry(etr, quality, format, already))
if any(res['status'] == 'error' for res in results):
return {'status': 'error', 'msg': ', '.join(res['msg'] for res in results if res['status'] == 'error' and 'msg' in res)}
@@ -220,7 +226,11 @@ class DownloadQueue:
if not self.queue.exists(entry['id']):
dl = DownloadInfo(entry['id'], entry['title'], entry.get('webpage_url') or entry['url'], quality, format)
dldirectory = self.config.DOWNLOAD_DIR if (quality != 'audio' and format != 'mp3') else self.config.AUDIO_DOWNLOAD_DIR
- self.queue.put(Download(dldirectory, self.config.OUTPUT_TEMPLATE, quality, format, self.config.YTDL_OPTIONS, dl))
+ output = self.config.OUTPUT_TEMPLATE
+ for property, value in entry.items():
+ if property.startswith("playlist"):
+ output = output.replace(f"%({property})s", str(value))
+ self.queue.put(Download(dldirectory, output, quality, format, self.config.YTDL_OPTIONS, dl))
self.event.set()
await self.notifier.added(dl)
return {'status': 'ok'}
bgstack15