🛠️ Fixed crash on download / search of unavailable media items.
This commit is contained in:
@@ -177,20 +177,21 @@ class Download:
|
|||||||
video_download: bool = True,
|
video_download: bool = True,
|
||||||
download_delay: bool = False,
|
download_delay: bool = False,
|
||||||
) -> (bool, str):
|
) -> (bool, str):
|
||||||
# If no media instance is provided, we need to create the media instance.
|
try:
|
||||||
if media_id and media_type:
|
if media_id and media_type:
|
||||||
|
# If no media instance is provided, we need to create the media instance.
|
||||||
media = instantiate_media(self.session, media_type, media_id)
|
media = instantiate_media(self.session, media_type, media_id)
|
||||||
elif isinstance(media, Track):
|
elif isinstance(media, Track): # Check if media is available not deactivated / removed from TIDAL.
|
||||||
media = self.session.track(media.id, with_album=True)
|
|
||||||
elif not media:
|
|
||||||
raise MediaMissing
|
|
||||||
|
|
||||||
# Check if media is available not deactivated / removed from TIDAL.
|
|
||||||
if not media.available:
|
if not media.available:
|
||||||
self.fn_logger.info(
|
self.fn_logger.info(
|
||||||
f"This track is not available for listening anymore on TIDAL. Skipping: {name_builder_item(media)}"
|
f"This track is not available for listening anymore on TIDAL. Skipping: {name_builder_item(media)}"
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
# Re-create media instance with full album information
|
||||||
|
media = self.session.track(media.id, with_album=True)
|
||||||
|
elif not media:
|
||||||
|
raise MediaMissing
|
||||||
|
except:
|
||||||
return False, ""
|
return False, ""
|
||||||
|
|
||||||
# If video download is not allowed end here
|
# If video download is not allowed end here
|
||||||
|
|||||||
+3
-2
@@ -6,7 +6,6 @@ from requests.exceptions import HTTPError
|
|||||||
|
|
||||||
from tidal_dl_ng import version
|
from tidal_dl_ng import version
|
||||||
from tidal_dl_ng.dialog import DialogLogin, DialogPreferences, DialogVersion
|
from tidal_dl_ng.dialog import DialogLogin, DialogPreferences, DialogVersion
|
||||||
from tidal_dl_ng.helper.exceptions import MediaUnknown
|
|
||||||
from tidal_dl_ng.helper.path import get_format_template
|
from tidal_dl_ng.helper.path import get_format_template
|
||||||
from tidal_dl_ng.helper.tidal import (
|
from tidal_dl_ng.helper.tidal import (
|
||||||
get_tidal_media_id,
|
get_tidal_media_id,
|
||||||
@@ -367,7 +366,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
media = instantiate_media(self.tidal.session, media_type, item_id)
|
media = instantiate_media(self.tidal.session, media_type, item_id)
|
||||||
except MediaUnknown:
|
except:
|
||||||
|
logger_gui.error(f"Media not found (ID: {item_id}). Maybe it is not available anymore.")
|
||||||
|
|
||||||
media = None
|
media = None
|
||||||
|
|
||||||
result_search = {"direct": [media]}
|
result_search = {"direct": [media]}
|
||||||
|
|||||||
Reference in New Issue
Block a user