mappingsFromLink method
Implementation
Future<Object>? mappingsFromLink(String link) async {
if (token == null) {
throw Exception("Token not set!");
} else {
try {
final response = await _dio
.get('https://kodikapi.com/search?token=$token&player_link=$link');
var data = response.data["results"][0];
return {
"kinopoisk":
data["kinopoisk_id"] ? data["kinopoisk_id"].toInt() : null,
"imdb": data["imdb_id"],
"worldart": data["worldart_link"],
"shikimori":
data["shikimori_id"] ? data["shikimori_id"].toInt() : null
};
} on DioException catch (e) {
if (e.response!.statusCode == 500) {
throw BadDataException("Bad Token or Player URL!");
} else {
throw Exception("An error has occurred");
}
}
}
}