summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorexislow <exislow@users.noreply.github.com>2024-11-15 09:57:37 +0100
committerGitHub <noreply@github.com>2024-11-15 09:57:37 +0100
commit841ffaee4d190f7b98f38e259d83e601b94f005b (patch)
tree8e8b8784749e44641d3030473539aa8a65d9ce74
parentf28d07b651a0d69229bfb6f1a1bcd3525ed99933 (diff)
parent037e6f14a20dc32055755382592e47bde94f073f (diff)
downloadtidal-dl-ng-841ffaee4d190f7b98f38e259d83e601b94f005b.tar.gz
Merge pull request #235 from exislow/201-feature-add-downloaded-songname-to-stdout
✨ Finished items will be written to log output. Minor refactoring.
-rw-r--r--tidal_dl_ng/download.py27
-rw-r--r--tidal_dl_ng/helper/tidal.py6
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