Initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import '../../core/contracts/library.dart';
|
||||
import '../../core/contracts/tmdb.dart';
|
||||
import '../mappers/tmdb_image_url.dart';
|
||||
|
||||
|
||||
int? seasonNumberFrom(EmbyRawSeason season) {
|
||||
final indexNumber = season.IndexNumber;
|
||||
if (indexNumber != null) return indexNumber;
|
||||
final name = season.Name.trim().toLowerCase();
|
||||
if (name == 'specials' || name == '特别篇' || name == 'sp') return 0;
|
||||
final match = RegExp(r'\d+').firstMatch(season.Name);
|
||||
if (match == null) return null;
|
||||
return int.tryParse(match.group(0)!);
|
||||
}
|
||||
|
||||
|
||||
Map<int, String> tmdbStillUrlsByEpisode(
|
||||
TmdbSeasonDetail? season,
|
||||
String? imageBaseUrl,
|
||||
) {
|
||||
if (season == null || imageBaseUrl == null || imageBaseUrl.isEmpty) {
|
||||
return const {};
|
||||
}
|
||||
final urls = <int, String>{};
|
||||
for (final episode in season.episodes) {
|
||||
final url = TmdbImageUrl.still(
|
||||
imageBaseUrl,
|
||||
episode.stillPath,
|
||||
size: 'w500',
|
||||
);
|
||||
if (url != null && url.isNotEmpty) {
|
||||
urls[episode.episodeNumber] = url;
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
}
|
||||
Reference in New Issue
Block a user