diff --git a/tests/test.py b/tests/test.py index 7d7199c..fab1746 100644 --- a/tests/test.py +++ b/tests/test.py @@ -237,6 +237,11 @@ class TestYTMusic(unittest.TestCase): def test_get_album_browse_id(self): browse_id = self.yt.get_album_browse_id("OLAK5uy_nMr9h2VlS-2PULNz3M3XVXQj_P3C2bqaY") self.assertEqual(browse_id, sample_album) + with self.subTest(): + escaped_browse_id = self.yt.get_album_browse_id( + "OLAK5uy_nbMYyrfeg5ZgknoOsOGBL268hGxtcbnDM") + # general length, I believe 17 is standard, but unsure if edge cases exist + self.assertLess(len(escaped_browse_id), 24) def test_get_album(self): results = self.yt_auth.get_album(sample_album) @@ -505,6 +510,7 @@ class TestYTMusic(unittest.TestCase): self.assertEqual(response, "STATUS_SUCCEEDED", "Playlist edit failed") # end to end test adding playlist, adding item, deleting item, deleting playlist + # @unittest.skip('You are creating too many playlists. Please wait a bit...') def test_end2end(self): playlist_id = self.yt_brand.create_playlist( "test", diff --git a/ytmusicapi/mixins/browsing.py b/ytmusicapi/mixins/browsing.py index fe4dbf2..4c644e1 100644 --- a/ytmusicapi/mixins/browsing.py +++ b/ytmusicapi/mixins/browsing.py @@ -342,10 +342,11 @@ class BrowsingMixin: params = {"list": audioPlaylistId} response = self._send_get_request(YTM_DOMAIN + "/playlist", params) - if (start := response.text.find('MPREb_')) == -1: - return None - - return response.text[start:(response.text.find('"', start) - 1)] + 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 def get_album(self, browseId: str) -> Dict: """