From 037e6f14a20dc32055755382592e47bde94f073f Mon Sep 17 00:00:00 2001 From: Robert Honz Date: Fri, 15 Nov 2024 09:53:21 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Finished=20items=20will=20be=20writ?= =?UTF-8?q?ten=20to=20log=20output.=20Minor=20refactoring.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tidal_dl_ng/download.py | 27 ++++++++++++--------------- tidal_dl_ng/helper/tidal.py | 6 ++++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/tidal_dl_ng/download.py b/tidal_dl_ng/download.py index bdc2481..735ea51 100644 --- a/tidal_dl_ng/download.py +++ b/tidal_dl_ng/download.py @@ -244,10 +244,8 @@ class Download: self.progress.advance(p_task) result = True - except Exception as e: - error = e + except Exception: self.progress.advance(p_task) - self.fn_logger.exception(e) # To send the progress to the GUI, we need to emit the percentage. if not progress_to_stdout: @@ -397,9 +395,13 @@ class Download: self._move_lyrics(tmp_path_lyrics, path_media_dst) # Move cover file + # TODO: Cover is downloaded with every track of the album. Needs refactoring, so cover is only + # dowloaded for an album once. if self.settings.data.cover_album_file and tmp_path_cover: self._move_cover(tmp_path_cover, path_media_dst) + self.fn_logger.info(f"Downloaded item '{name_builder_item(media)}'.") + # Move final file to the configured destination directory. shutil.move(tmp_path_file, path_media_dst) @@ -590,29 +592,22 @@ class Download: file_name_relative = format_path_media(file_template, media) # Get the name of the list and check, if videos should be included. - videos_include: bool = True - - if isinstance(media, Mix): - list_media_name = media.title[:30] - elif video_download: - list_media_name = name_builder_title(media)[:30] - else: - videos_include = False - list_media_name = name_builder_title(media)[:30] + list_media_name: str = name_builder_title(media) + list_media_name_short: str = list_media_name[:30] # Get all items of the list. - items = items_results_all(media, videos_include=videos_include) + items = items_results_all(media, videos_include=video_download) # Determine where to redirect the progress information. if self.progress_gui is None: progress_stdout: bool = True else: progress_stdout: bool = False - self.progress_gui.list_name.emit(list_media_name[:30]) + self.progress_gui.list_name.emit(list_media_name_short[:30]) # Create the list progress task. p_task1: TaskID = self.progress.add_task( - f"[green]List '{list_media_name}'", total=len(items), visible=progress_stdout + f"[green]List '{list_media_name_short}'", total=len(items), visible=progress_stdout ) is_album: bool = isinstance(media, Album) @@ -636,6 +631,8 @@ class Download: if not progress_stdout: self.progress_gui.list_item.emit(self.progress.tasks[p_task1].percentage) + self.fn_logger.info(f"Finished list '{list_media_name}'.") + def _video_convert(self, path_file: pathlib.Path) -> pathlib.Path: path_file_out: pathlib.Path = path_file.with_suffix(AudioExtensions.MP4) result, _ = ( diff --git a/tidal_dl_ng/helper/tidal.py b/tidal_dl_ng/helper/tidal.py index ebea4cd..e568cc6 100644 --- a/tidal_dl_ng/helper/tidal.py +++ b/tidal_dl_ng/helper/tidal.py @@ -25,8 +25,10 @@ def name_builder_album_artist(media: Track | Album) -> str: return ", ".join(artists_tmp) -def name_builder_title(media: Track | Video) -> str: - result: str = media.full_name if hasattr(media, "full_name") else media.name +def name_builder_title(media: Track | Video | Mix | Playlist | Album | Video) -> str: + result: str = ( + media.title if isinstance(media, Mix) else media.full_name if hasattr(media, "full_name") else media.name + ) return result