parseArtistSong static method
Implementation
static SongDetailed parseArtistSong(dynamic item, ArtistBasic artistBasic) {
final columns = traverseList(item, ["flexColumns", "runs"])
.expand((e) => e is List ? e : [e])
.toList();
final title = columns.firstWhere(isTitle, orElse: () => null);
final album = columns.firstWhere(isAlbum, orElse: () => null);
final duration = columns.firstWhere(isDuration, orElse: () => null);
final cleanedDuration =
duration?['text']?.replaceAll(RegExp(r'[^0-9:]'), '');
return SongDetailed(
type: "SONG",
videoId: traverseString(item, ["playlistItemData", "videoId"]) ?? '',
name: traverseString(title, ["text"]) ?? '',
artist: artistBasic,
album: album != null
? AlbumBasic(
name: traverseString(album, ["text"]) ?? '',
albumId: traverseString(album, ["browseId"]) ?? '',
)
: null,
duration: Parser.parseDuration(cleanedDuration),
thumbnails: traverseList(item, ["thumbnails"])
.map((item) => ThumbnailFull.fromMap(item))
.toList(),
);
}