From cc2fff8beff01fdafdaf4678b6fc6fc497c4b08d Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 18 Jul 2022 11:37:43 +0700 Subject: [PATCH] use info_dict for message, simplify cache template, #271 --- tubearchivist/home/config.json | 1 - tubearchivist/home/src/download/yt_dlp_handler.py | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tubearchivist/home/config.json b/tubearchivist/home/config.json index 3e5e941..95c1211 100644 --- a/tubearchivist/home/config.json +++ b/tubearchivist/home/config.json @@ -36,7 +36,6 @@ "app_root": "/app", "cache_dir": "/cache", "videos": "/youtube", - "file_template": "%(id)s_%(title)s.mp4", "colors": "dark", "enable_cast": false }, diff --git a/tubearchivist/home/src/download/yt_dlp_handler.py b/tubearchivist/home/src/download/yt_dlp_handler.py index 2731921..52b0b73 100644 --- a/tubearchivist/home/src/download/yt_dlp_handler.py +++ b/tubearchivist/home/src/download/yt_dlp_handler.py @@ -241,12 +241,8 @@ class VideoDownloader: def _progress_hook(self, response): """process the progress_hooks from yt_dlp""" - # title - path = os.path.split(response["filename"])[-1][12:] - filename = os.path.splitext(os.path.splitext(path)[0])[0] - filename_clean = filename.replace("_", " ") - title = "Downloading: " + filename_clean - # message + title = "Downloading: " + response["info_dict"]["title"] + try: percent = response["_percent_str"] size = response["_total_bytes_str"] @@ -255,6 +251,7 @@ class VideoDownloader: message = f"{percent} of {size} at {speed} - time left: {eta}" except KeyError: message = "processing" + mess_dict = { "status": self.MSG, "level": "info", @@ -274,11 +271,9 @@ class VideoDownloader: self.obs = { "default_search": "ytsearch", "merge_output_format": "mp4", - "restrictfilenames": True, "outtmpl": ( self.config["application"]["cache_dir"] - + "/download/" - + self.config["application"]["file_template"] + + "/download/%(id)s.mp4" ), "progress_hooks": [self._progress_hook], "noprogress": True,