getBaseJsUrl method
Extract the URL for the base.js
script from YouTube Music.
Returns URL to base.js
.
TODO this might not work everytime, investigate.
Implementation
Future<String> getBaseJsUrl() async {
final response = await sendGetRequest(YTM_DOMAIN);
final match = RegExp(
r'jsUrl"\s*:\s*"([^"]+)"',
).firstMatch(decodeEscapes(response.data as String));
if (match == null) {
throw Exception('Could not identify the URL for base.js player.');
}
return '$YTM_DOMAIN${match.group(1)}';
}