Workaround for "Youtube Music playlist stalls on uploaded music" music-assistant/support#4469#3156
Workaround for "Youtube Music playlist stalls on uploaded music" music-assistant/support#4469#3156whitty wants to merge 2 commits intomusic-assistant:devfrom
Conversation
User uploaded media may resolve a prov_album_id of the form `FEmusic_library_privately_owned_release_detailb_po_...` which causes an exception to be thrown by ytmusicapi.get_album(). Return None instead of throwing an otherwise uncaught exception (#4469) which prevents playback from stalling.
|
I would like to solve the root of the issue rather than implementing an 'except workaround'. Can you let me know what the album id is of your custom uploaded track that is triggering the issue? That might shed some light on this case. |
| except ytmusicapi.exceptions.YTMusicUserError as e: | ||
| if prov_album_id is not None and "must start with MPRE" in str(e): | ||
| logging.getLogger("music_assistant").getChild("YouTube Music").debug("ytmusicapi refused to handle prov_album_id: '%s'", prov_album_id) | ||
| return None |
There was a problem hiding this comment.
Note None is not a normal return path for ytm.get_album() there is no obvious "not-found" result
Understood. As I've pointed out the
Can you explain exactly what information you are after? As described the I do not know where this value came from - presumably from a query of the youtube api elsewhere and/or stored by MA itself from some source. |
|
That's exactly the info I was after. It looks like YTM internally stores this value as the album id for a track that was manually uploaded. Now of course we cannot link this to any album out there, which ultimately causes this error. My suggestion is to prevent this value from ever creeping into MA. So instead of failing on a invalid album id in the |
MarvinSchenkel
left a comment
There was a problem hiding this comment.
Please have a look at my suggestion and mark this PR 'Ready for review' again once you have made the changes.
This is a workaround for the "stalling" aspect of music-assistant/support#4469
MA tries to resolve albums providing the
prov_album_idof the formFEmusic_library_privately_owned_release_detailb_po_<probably private_letters_and_numbers_id>which triggers an exception inytmusic.get_album()as it checks that the ID.startswith('MPRE').The handling of the exception seems to lead to playback stalling in this case. Catching and returning
None(presumably like "not found") instead leads to a warning as follows, but playback doesn't stall.This may not resolve the base issues:
get_album()in that case)Approach:
I preferred to catch the exception rather than check the prefix, in case
ytmusicapiresolves the issue and allows non MPRE prefixes in the future.Since the Exception is a generic
UserErrortype I specifically check the message and propagate any other exceptions..Additionally I removed a duplicate lookup rather than expand the
tryblock further.