use info_dict for message, simplify cache template, #271

This commit is contained in:
simon 2022-07-18 11:37:43 +07:00
parent 2d13011866
commit cc2fff8bef
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 4 additions and 10 deletions

View File

@ -36,7 +36,6 @@
"app_root": "/app", "app_root": "/app",
"cache_dir": "/cache", "cache_dir": "/cache",
"videos": "/youtube", "videos": "/youtube",
"file_template": "%(id)s_%(title)s.mp4",
"colors": "dark", "colors": "dark",
"enable_cast": false "enable_cast": false
}, },

View File

@ -241,12 +241,8 @@ class VideoDownloader:
def _progress_hook(self, response): def _progress_hook(self, response):
"""process the progress_hooks from yt_dlp""" """process the progress_hooks from yt_dlp"""
# title title = "Downloading: " + response["info_dict"]["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
try: try:
percent = response["_percent_str"] percent = response["_percent_str"]
size = response["_total_bytes_str"] size = response["_total_bytes_str"]
@ -255,6 +251,7 @@ class VideoDownloader:
message = f"{percent} of {size} at {speed} - time left: {eta}" message = f"{percent} of {size} at {speed} - time left: {eta}"
except KeyError: except KeyError:
message = "processing" message = "processing"
mess_dict = { mess_dict = {
"status": self.MSG, "status": self.MSG,
"level": "info", "level": "info",
@ -274,11 +271,9 @@ class VideoDownloader:
self.obs = { self.obs = {
"default_search": "ytsearch", "default_search": "ytsearch",
"merge_output_format": "mp4", "merge_output_format": "mp4",
"restrictfilenames": True,
"outtmpl": ( "outtmpl": (
self.config["application"]["cache_dir"] self.config["application"]["cache_dir"]
+ "/download/" + "/download/%(id)s.mp4"
+ self.config["application"]["file_template"]
), ),
"progress_hooks": [self._progress_hook], "progress_hooks": [self._progress_hook],
"noprogress": True, "noprogress": True,