get_streaming_data: handle unplayable videos

This commit is contained in:
sigma67 2020-11-26 15:03:58 +01:00
commit 063af84a5f
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0
2 changed files with 6 additions and 3 deletions

View file

@ -84,7 +84,7 @@ class TestYTMusic(unittest.TestCase):
self.assertGreaterEqual(len(song), 16)
def test_get_streaming_data(self):
streaming_data = youtube.get_streaming_data("NRUVdGLf2GI")
streaming_data = youtube_auth.get_streaming_data("ZrOKjDZOtkA")
self.assertEqual(len(streaming_data), 3)
###############

View file

@ -620,6 +620,9 @@ class BrowsingMixin:
text = parse_qs(response.text)
if 'player_response' not in text:
return text
player_response = json.loads(text['player_response'][0])
streaming_data = player_response['streamingData']
return streaming_data
if 'streamingData' not in player_response:
raise Exception('This video is not playable.')
return player_response['streamingData']