Retreive streaming data for 256 kbps AAC

Adding the parameters c=WEB_REMIX and cver=0.1 to the get_video_info
request in get_song() returns a streamingData adaptiveFormat of itag
141, audioQuality of AUDIO_QUALITY_HIGH, a 256 kbps AAC m4a for
authenticated requests from YouTube Music Premium subscribers.

Unfortunately, these parameters result in
player_response['videoDetails']['shortDescription'] not being returned,
the information in which contains useful song metadata.

player_response['microformat']['microformatDataRenderer']['description']
is returned, but it seems to be a truncated version of shortDescription,
so the metadata parsing in get_song() does not work on that response.

Therefore, a second get_video_info request is made with the updated
parameters and the metadata in song_meta is copied in to the new
player_response['videoDetails'], which is returned from get_song()
instead of song_meta.
This commit is contained in:
Cory Marshall 2020-11-24 09:45:01 -04:00 • committed by sigma67
commit 839703c034
No known key found for this signature in database
GPG key ID: 1545A01D4474BAF0

View file

@ -550,4 +550,15 @@ class BrowsingMixin:
except (KeyError, IndexError):
pass
song_meta['streamingData'] = player_response['streamingData']
return song_meta
params.update({"c": "WEB_REMIX", "cver": "0.1"})
response = requests.get(endpoint, params, headers=self.headers, proxies=self.proxies)
text = parse_qs(response.text)
if 'player_response' not in text:
return text
player_response = json.loads(text['player_response'][0])
player_response['videoDetails']['provider'] = song_meta['provider']
player_response['videoDetails']['artists'] = song_meta['artists']
player_response['videoDetails']['copyright'] = song_meta['copyright']
player_response['videoDetails']['release'] = song_meta['release']
player_response['videoDetails']['production'] = song_meta['production']
return player_response