Merge pull request #235 from exislow/201-feature-add-downloaded-songname-to-stdout
✨ Finished items will be written to log output. Minor refactoring.
This commit is contained in:
+12
-15
@@ -244,10 +244,8 @@ class Download:
|
|||||||
self.progress.advance(p_task)
|
self.progress.advance(p_task)
|
||||||
|
|
||||||
result = True
|
result = True
|
||||||
except Exception as e:
|
except Exception:
|
||||||
error = e
|
|
||||||
self.progress.advance(p_task)
|
self.progress.advance(p_task)
|
||||||
self.fn_logger.exception(e)
|
|
||||||
|
|
||||||
# To send the progress to the GUI, we need to emit the percentage.
|
# To send the progress to the GUI, we need to emit the percentage.
|
||||||
if not progress_to_stdout:
|
if not progress_to_stdout:
|
||||||
@@ -397,9 +395,13 @@ class Download:
|
|||||||
self._move_lyrics(tmp_path_lyrics, path_media_dst)
|
self._move_lyrics(tmp_path_lyrics, path_media_dst)
|
||||||
|
|
||||||
# Move cover file
|
# 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:
|
if self.settings.data.cover_album_file and tmp_path_cover:
|
||||||
self._move_cover(tmp_path_cover, path_media_dst)
|
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.
|
# Move final file to the configured destination directory.
|
||||||
shutil.move(tmp_path_file, path_media_dst)
|
shutil.move(tmp_path_file, path_media_dst)
|
||||||
|
|
||||||
@@ -590,29 +592,22 @@ class Download:
|
|||||||
file_name_relative = format_path_media(file_template, media)
|
file_name_relative = format_path_media(file_template, media)
|
||||||
|
|
||||||
# Get the name of the list and check, if videos should be included.
|
# Get the name of the list and check, if videos should be included.
|
||||||
videos_include: bool = True
|
list_media_name: str = name_builder_title(media)
|
||||||
|
list_media_name_short: str = list_media_name[:30]
|
||||||
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]
|
|
||||||
|
|
||||||
# Get all items of the list.
|
# 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.
|
# Determine where to redirect the progress information.
|
||||||
if self.progress_gui is None:
|
if self.progress_gui is None:
|
||||||
progress_stdout: bool = True
|
progress_stdout: bool = True
|
||||||
else:
|
else:
|
||||||
progress_stdout: bool = False
|
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.
|
# Create the list progress task.
|
||||||
p_task1: TaskID = self.progress.add_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)
|
is_album: bool = isinstance(media, Album)
|
||||||
@@ -636,6 +631,8 @@ class Download:
|
|||||||
if not progress_stdout:
|
if not progress_stdout:
|
||||||
self.progress_gui.list_item.emit(self.progress.tasks[p_task1].percentage)
|
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:
|
def _video_convert(self, path_file: pathlib.Path) -> pathlib.Path:
|
||||||
path_file_out: pathlib.Path = path_file.with_suffix(AudioExtensions.MP4)
|
path_file_out: pathlib.Path = path_file.with_suffix(AudioExtensions.MP4)
|
||||||
result, _ = (
|
result, _ = (
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ def name_builder_album_artist(media: Track | Album) -> str:
|
|||||||
return ", ".join(artists_tmp)
|
return ", ".join(artists_tmp)
|
||||||
|
|
||||||
|
|
||||||
def name_builder_title(media: Track | Video) -> str:
|
def name_builder_title(media: Track | Video | Mix | Playlist | Album | Video) -> str:
|
||||||
result: str = media.full_name if hasattr(media, "full_name") else media.name
|
result: str = (
|
||||||
|
media.title if isinstance(media, Mix) else media.full_name if hasattr(media, "full_name") else media.name
|
||||||
|
)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user