getSong method

Future<SongFull> getSong(
  1. String videoId
)

Retrieves detailed information about a song given its video ID.

Implementation

Future<SongFull> getSong(String videoId) async {
  if (!RegExp(r"^[a-zA-Z0-9-_]{11}$").hasMatch(videoId)) {
    throw Exception("Invalid videoId");
  }

  final data = await constructRequest("player", body: {"videoId": videoId});

  final song = SongParser.parse(data);
  if (song.videoId != videoId) {
    throw Exception("Invalid videoId");
  }
  return song;
}