get_album_browse_id: fix depreciated escape sequence error && add performance increase

This commit is contained in:
jcbirdwell 2023-12-16 15:55:06 -06:00
commit b9be59de50

View file

@ -332,7 +332,7 @@ class BrowsingMixin:
return user_playlists
def get_album_browse_id(self, audioPlaylistId: str) -> str:
def get_album_browse_id(self, audioPlaylistId: str) -> str | None:
"""
Get an album's browseId based on its audioPlaylistId
@ -341,11 +341,11 @@ class BrowsingMixin:
"""
params = {"list": audioPlaylistId}
response = self._send_get_request(YTM_DOMAIN + "/playlist", params)
matches = re.search(r"\"MPRE.+?\"", response.text.encode("utf8").decode("unicode_escape"))
browse_id = None
if matches:
browse_id = matches.group().strip('"')
return browse_id
if (start := response.text.find('MPREb_')) == -1:
return None
return response.text[start:(response.text.find('"', start) - 1)]
def get_album(self, browseId: str) -> Dict:
"""