From deab875acd647d02654f1a721824842923419ff0 Mon Sep 17 00:00:00 2001 From: almeidapaulopt Date: Thu, 17 Feb 2022 15:28:24 +0000 Subject: ass playlist parameters --- app/ytdl.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/ytdl.py b/app/ytdl.py index 6e406b0..46f4f1c 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -210,8 +210,15 @@ 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) + etr["playlist_id"] = entry["id"] + etr["playlist_title"] = entry["title"] + etr["playlist_uploader"] = entry["uploader"] + etr["playlist_uploader_id"] = entry["uploader_id"] 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 +227,15 @@ 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 + if "playlist" in entry: + output = output.replace("%(playlist_index)s",entry["playlist_index"]) + output = output.replace("%(playlist_id)s",entry["playlist_id"]) + output = output.replace("%(playlist_title)s",entry["playlist_title"]) + output = output.replace("%(playlist_uploader)s",str(entry["playlist_uploader"])) + output = output.replace("%(playlist_uploader_id)s",str(entry["playlist_uploader_id"])) + output = output.replace("%(playlist)s",entry["playlist"]) + self.queue.put(Download(dldirectory, output, quality, format, self.config.YTDL_OPTIONS, dl)) self.event.set() await self.notifier.added(dl) return {'status': 'ok'} -- cgit