Handle ItemExists in core.py

Signed-off-by: nathom <nathanthomas707@gmail.com>
This commit is contained in:
nathom 2021-07-06 15:13:43 -07:00
parent 835c8d4cc6
commit 26cb32b9a4
2 changed files with 11 additions and 5 deletions

View file

@ -49,6 +49,7 @@ from . import db
from streamrip.exceptions import ( from streamrip.exceptions import (
AuthenticationError, AuthenticationError,
PartialFailure, PartialFailure,
ItemExists,
MissingCredentials, MissingCredentials,
NonStreamable, NonStreamable,
NoResultsFound, NoResultsFound,
@ -303,6 +304,9 @@ class MusicDL(list):
for failed_item in e.failed_items: for failed_item in e.failed_items:
self.failed_db.add(failed_item) self.failed_db.add(failed_item)
continue continue
except ItemExists as e:
click.secho(f'"{e!s}" already exists. Skipping.', fg="yellow")
continue
if hasattr(item, "id"): if hasattr(item, "id"):
self.db.add([item.id]) self.db.add([item.id])

View file

@ -207,10 +207,13 @@ class Track(Media):
raise ItemExists(self.final_path) raise ItemExists(self.final_path)
if hasattr(self, "cover_url"): if hasattr(self, "cover_url"):
try:
self.download_cover( self.download_cover(
width=kwargs.get("max_artwork_width", 999999), width=kwargs.get("max_artwork_width", 999999),
height=kwargs.get("max_artwork_height", 999999), height=kwargs.get("max_artwork_height", 999999),
) # only downloads for playlists and singles ) # only downloads for playlists and singles
except ItemExists as e:
logger.debug(e)
self.path = os.path.join(gettempdir(), f"{hash(self.id)}_{self.quality}.tmp") self.path = os.path.join(gettempdir(), f"{hash(self.id)}_{self.quality}.tmp")
@ -230,7 +233,6 @@ class Track(Media):
:param progress_bar: turn on/off progress bar :param progress_bar: turn on/off progress bar
:type progress_bar: bool :type progress_bar: bool
""" """
# raise NonStreamable
self._prepare_download( self._prepare_download(
quality=quality, quality=quality,
parent_folder=parent_folder, parent_folder=parent_folder,