getArtistInfo static method

Future<Artist> getArtistInfo({
  1. required dynamic artist,
})

Implementation

static Future<Artist> getArtistInfo({required dynamic artist}) async {
  String? artistUrl = (artist is! String) ? (artist as Artist).url : artist;
  String url = 'https://ncs.io$artistUrl';
  var document = await Chaleno().load(url);

  Result? infoElement = document?.querySelector('.details .info');
  String? name = infoElement?.querySelector('h5')?.innerHTML;
  List<String>? genres =
      infoElement?.querySelector('.tags')?.innerHTML?.split(', ');
  String? image = document
      ?.querySelector('div.img')
      .attr('style')
      ?.trim()
      .replaceAll("url('", '')
      .replaceAll("')", '')
      .replaceAll('background-image: ', '');
  // Result? songsElement = document?.querySelector('.table tbody');
  // List<Song> songs = JustParser.parseTable(table: songsElement);
  return Artist(
    name: name,
    url: artistUrl,
    genres: genres,
    img: image,
    // songs: songs,
  );
}