get_album_browse_id: fix DeprecationWarning on Python 3.12

This commit is contained in:
sigma67 2024-02-04 15:58:01 +01:00 • committed by sigma67
commit c8af65d643

View file

@ -1,4 +1,5 @@
import re
import warnings
from typing import Any, Dict, List, Optional
from ytmusicapi.continuations import (
@ -423,7 +424,10 @@ class BrowsingMixin(MixinProtocol):
params = {"list": audioPlaylistId}
response = self._send_get_request(YTM_DOMAIN + "/playlist", params)
matches = re.search(r"\"MPRE.+?\"", response.text.encode("utf8").decode("unicode_escape"))
with warnings.catch_warnings(action="ignore", category=DeprecationWarning):
decoded = response.text.encode("utf8").decode("unicode_escape")
matches = re.search(r"\"MPRE.+?\"", decoded)
browse_id = None
if matches:
browse_id = matches.group().strip('"')