get_album_browse_id: fix depreciated escape sequence error && add performance increase
This commit is contained in:
parent
e21492b7d3
commit
b9be59de50
1 changed files with 6 additions and 6 deletions
|
|
@ -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:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue