getPlayerResponse method
Implementation
Future<PlayerResponse> getPlayerResponse(VideoId videoId) async {
/// From https://github.com/Tyrrrz/YoutubeExplode:
/// The most optimal client to impersonate is the Android client, because
/// it doesn't require signature deciphering (for both normal and n-parameter signatures).
/// However, the regular Android client has a limitation, preventing it from downloading
/// multiple streams from the same manifest (or the same stream multiple times).
/// As a workaround, we're using ANDROID_TESTSUITE which appears to offer the same
/// functionality, but doesn't impose the aforementioned limitation.
/// https://github.com/Tyrrrz/YoutubeExplode/issues/705
final content = await httpClient.postString(
'https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w&prettyPrint=false',
body: {
..._androidSuiteClient,
'videoId': videoId.value,
},
headers: {
'User-Agent':
'com.google.android.youtube/17.36.4 (Linux; U; Android 12; GB) gzip',
},
);
return PlayerResponse.parse(content);
}