本文整理汇总了C#中IHasImages.GetPreferredMetadataLanguage方法的典型用法代码示例。如果您正苦于以下问题:C# IHasImages.GetPreferredMetadataLanguage方法的具体用法?C# IHasImages.GetPreferredMetadataLanguage怎么用?C# IHasImages.GetPreferredMetadataLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHasImages
的用法示例。
在下文中一共展示了IHasImages.GetPreferredMetadataLanguage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
if (TvdbSeriesProvider.IsValidSeries(item.ProviderIds))
{
var language = item.GetPreferredMetadataLanguage();
var seriesDataPath = await TvdbSeriesProvider.Current.EnsureSeriesInfo(item.ProviderIds, language, cancellationToken).ConfigureAwait(false);
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
var seriesOffset = TvdbSeriesProvider.GetSeriesOffset(item.ProviderIds);
if (seriesOffset != null && seriesOffset.Value != 0)
return TvdbSeasonImageProvider.GetImages(path, language, seriesOffset.Value + 1, cancellationToken);
return GetImages(path, language, cancellationToken);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
catch (DirectoryNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
return new RemoteImageInfo[] { };
}
示例2: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var season = (Season)item;
var series = season.Series;
if (series != null && season.IndexNumber.HasValue && TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
{
var seriesProviderIds = series.ProviderIds;
var seasonNumber = season.IndexNumber.Value;
var seriesDataPath = await TvdbSeriesProvider.Current.EnsureSeriesInfo(seriesProviderIds, series.GetPreferredMetadataLanguage(), cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrWhiteSpace(seriesDataPath))
{
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
return GetImages(path, item.GetPreferredMetadataLanguage(), seasonNumber, cancellationToken);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
catch (DirectoryNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
}
return new RemoteImageInfo[] { };
}
示例3: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var season = (Season)item;
var series = season.Series;
var identity = season.Identities.OfType<SeasonIdentity>().FirstOrDefault(id => id.Type == MetadataProviders.Tvdb.ToString());
var seriesId = identity != null ? identity.SeriesId : null;
if (!string.IsNullOrEmpty(seriesId) && season.IndexNumber.HasValue)
{
await TvdbSeriesProvider.Current.EnsureSeriesInfo(seriesId, series.GetPreferredMetadataLanguage(), cancellationToken).ConfigureAwait(false);
// Process images
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesId);
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
int seasonNumber = AdjustForSeriesOffset(series, identity.SeasonIndex);
return GetImages(path, item.GetPreferredMetadataLanguage(), seasonNumber, cancellationToken);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
return new RemoteImageInfo[] { };
}
示例4: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var series = (Series)item;
var seriesId = series.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(seriesId))
{
var language = item.GetPreferredMetadataLanguage();
await TvdbSeriesProvider.Current.EnsureSeriesInfo(seriesId, language, cancellationToken).ConfigureAwait(false);
// Process images
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesId);
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
return GetImages(path, language, cancellationToken);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
return new RemoteImageInfo[] { };
}
示例5: GetAllImages
public Task<IEnumerable<RemoteImageInfo>> GetAllImages(IHasImages item, CancellationToken cancellationToken)
{
var series = (Series)item;
var seriesId = series.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(seriesId))
{
// Process images
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesId);
var path = Path.Combine(seriesDataPath, "banners.xml");
try
{
var result = GetImages(path, item.GetPreferredMetadataLanguage(), cancellationToken);
return Task.FromResult(result);
}
catch (FileNotFoundException)
{
// No tvdb data yet. Don't blow up
}
}
return Task.FromResult<IEnumerable<RemoteImageInfo>>(new RemoteImageInfo[] { });
}
示例6: GetAllImages
public Task<IEnumerable<RemoteImageInfo>> GetAllImages(IHasImages item, CancellationToken cancellationToken)
{
var album = (MusicAlbum)item;
var list = new List<RemoteImageInfo>();
var artistMusicBrainzId = album.Parent.GetProviderId(MetadataProviders.Musicbrainz);
if (!string.IsNullOrEmpty(artistMusicBrainzId))
{
var artistXmlPath = FanArtArtistProvider.GetArtistDataPath(_config.CommonApplicationPaths, artistMusicBrainzId);
artistXmlPath = Path.Combine(artistXmlPath, "fanart.xml");
var musicBrainzReleaseGroupId = album.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);
var musicBrainzId = album.GetProviderId(MetadataProviders.Musicbrainz);
try
{
AddImages(list, artistXmlPath, musicBrainzId, musicBrainzReleaseGroupId, cancellationToken);
}
catch (FileNotFoundException)
{
}
}
var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
// Sort first by width to prioritize HD versions
list = list.OrderByDescending(i => i.Width ?? 0)
.ThenByDescending(i =>
{
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
if (!isLanguageEn)
{
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
}
if (string.IsNullOrEmpty(i.Language))
{
return isLanguageEn ? 3 : 2;
}
return 0;
})
.ThenByDescending(i => i.CommunityRating ?? 0)
.ThenByDescending(i => i.VoteCount ?? 0)
.ToList();
return Task.FromResult<IEnumerable<RemoteImageInfo>>(list);
}
示例7: GetAllImages
public Task<IEnumerable<RemoteImageInfo>> GetAllImages(IHasImages item, CancellationToken cancellationToken)
{
var list = new List<RemoteImageInfo>();
var season = (Season)item;
var series = season.Series;
if (series != null)
{
var id = series.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(id) && season.IndexNumber.HasValue)
{
var xmlPath = FanArtTvProvider.Current.GetFanartXmlPath(id);
try
{
AddImages(list, season.IndexNumber.Value, xmlPath, cancellationToken);
}
catch (FileNotFoundException)
{
// No biggie. Don't blow up
}
}
}
var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
// Sort first by width to prioritize HD versions
list = list.OrderByDescending(i => i.Width ?? 0)
.ThenByDescending(i =>
{
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
if (!isLanguageEn)
{
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
}
if (string.IsNullOrEmpty(i.Language))
{
return isLanguageEn ? 3 : 2;
}
return 0;
})
.ThenByDescending(i => i.CommunityRating ?? 0)
.ThenByDescending(i => i.VoteCount ?? 0)
.ToList();
return Task.FromResult<IEnumerable<RemoteImageInfo>>(list);
}
示例8: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var tmdbId = item.GetProviderId(MetadataProviders.Tmdb);
if (!string.IsNullOrEmpty(tmdbId))
{
var language = item.GetPreferredMetadataLanguage();
var mainResult = await MovieDbBoxSetProvider.Current.GetMovieDbResult(tmdbId, null, cancellationToken).ConfigureAwait(false);
if (mainResult != null)
{
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
var tmdbImageUrl = tmdbSettings.images.secure_base_url + "original";
return GetImages(mainResult, language, tmdbImageUrl);
}
}
return new List<RemoteImageInfo>();
}
示例9: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var person = (Person)item;
var id = person.GetProviderId(MetadataProviders.Tmdb);
if (!string.IsNullOrEmpty(id))
{
await MovieDbPersonProvider.Current.EnsurePersonInfo(id, cancellationToken).ConfigureAwait(false);
var dataFilePath = MovieDbPersonProvider.GetPersonDataFilePath(_config.ApplicationPaths, id);
var result = _jsonSerializer.DeserializeFromFile<MovieDbPersonProvider.PersonResult>(dataFilePath);
var images = result.images ?? new MovieDbPersonProvider.Images();
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
var tmdbImageUrl = tmdbSettings.images.base_url + "original";
return GetImages(images, item.GetPreferredMetadataLanguage(), tmdbImageUrl);
}
return new List<RemoteImageInfo>();
}
示例10: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var list = new List<RemoteImageInfo>();
var series = (Series)item;
var id = series.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(id))
{
await EnsureSeriesXml(id, cancellationToken).ConfigureAwait(false);
var xmlPath = GetFanartXmlPath(id);
try
{
AddImages(list, xmlPath, cancellationToken);
}
catch (FileNotFoundException)
{
// No biggie. Don't blow up
}
}
var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
// Sort first by width to prioritize HD versions
return list.OrderByDescending(i => i.Width ?? 0)
.ThenByDescending(i =>
{
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
if (!isLanguageEn)
{
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
}
if (string.IsNullOrEmpty(i.Language))
{
return isLanguageEn ? 3 : 2;
}
return 0;
})
.ThenByDescending(i => i.CommunityRating ?? 0)
.ThenByDescending(i => i.VoteCount ?? 0);
}
示例11: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var artist = (MusicArtist)item;
var list = new List<RemoteImageInfo>();
var artistMusicBrainzId = artist.GetProviderId(MetadataProviders.MusicBrainzArtist);
if (!String.IsNullOrEmpty(artistMusicBrainzId))
{
await EnsureArtistJson(artistMusicBrainzId, cancellationToken).ConfigureAwait(false);
var artistJsonPath = GetArtistJsonPath(_config.CommonApplicationPaths, artistMusicBrainzId);
try
{
AddImages(list, artistJsonPath, cancellationToken);
}
catch (FileNotFoundException)
{
}
catch (DirectoryNotFoundException)
{
}
}
var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = String.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
// Sort first by width to prioritize HD versions
return list.OrderByDescending(i => i.Width ?? 0)
.ThenByDescending(i =>
{
if (String.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
if (!isLanguageEn)
{
if (String.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
}
if (String.IsNullOrEmpty(i.Language))
{
return isLanguageEn ? 3 : 2;
}
return 0;
})
.ThenByDescending(i => i.CommunityRating ?? 0)
.ThenByDescending(i => i.VoteCount ?? 0);
}
示例12: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var list = new List<RemoteImageInfo>();
var results = await FetchImages((BaseItem)item, null, _jsonSerializer, cancellationToken).ConfigureAwait(false);
if (results == null)
{
return list;
}
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
var tmdbImageUrl = tmdbSettings.images.secure_base_url + "original";
var language = item.GetPreferredMetadataLanguage();
list.AddRange(GetPosters(results).Select(i => new RemoteImageInfo
{
Url = tmdbImageUrl + i.file_path,
CommunityRating = i.vote_average,
VoteCount = i.vote_count,
Width = i.width,
Height = i.height,
Language = MovieDbProvider.AdjustImageLanguage(i.iso_639_1, language),
ProviderName = Name,
Type = ImageType.Primary,
RatingType = RatingType.Score
}));
list.AddRange(GetBackdrops(results).Select(i => new RemoteImageInfo
{
Url = tmdbImageUrl + i.file_path,
CommunityRating = i.vote_average,
VoteCount = i.vote_count,
Width = i.width,
Height = i.height,
ProviderName = Name,
Type = ImageType.Backdrop,
RatingType = RatingType.Score
}));
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
return list.OrderByDescending(i =>
{
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
if (!isLanguageEn)
{
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
}
if (string.IsNullOrEmpty(i.Language))
{
return isLanguageEn ? 3 : 2;
}
return 0;
})
.ThenByDescending(i => i.CommunityRating ?? 0)
.ThenByDescending(i => i.VoteCount ?? 0)
.ToList();
}
示例13: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var episode = (Controller.Entities.TV.Episode)item;
var series = episode.Series;
var seriesId = series != null ? series.GetProviderId(MetadataProviders.Tmdb) : null;
var list = new List<RemoteImageInfo>();
if (string.IsNullOrEmpty(seriesId))
{
return list;
}
var seasonNumber = episode.ParentIndexNumber;
var episodeNumber = episode.IndexNumber;
if (!seasonNumber.HasValue || !episodeNumber.HasValue)
{
return list;
}
var language = item.GetPreferredMetadataLanguage();
var response = await GetEpisodeInfo(seriesId, seasonNumber.Value, episodeNumber.Value,
language, cancellationToken).ConfigureAwait(false);
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
var tmdbImageUrl = tmdbSettings.images.secure_base_url + "original";
list.AddRange(GetPosters(response.images).Select(i => new RemoteImageInfo
{
Url = tmdbImageUrl + i.file_path,
CommunityRating = i.vote_average,
VoteCount = i.vote_count,
Width = i.width,
Height = i.height,
Language = MovieDbProvider.AdjustImageLanguage(i.iso_639_1, language),
ProviderName = Name,
Type = ImageType.Primary,
RatingType = RatingType.Score
}));
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
return list.OrderByDescending(i =>
{
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
if (!isLanguageEn)
{
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
}
if (string.IsNullOrEmpty(i.Language))
{
return isLanguageEn ? 3 : 2;
}
return 0;
})
.ThenByDescending(i => i.CommunityRating ?? 0)
.ThenByDescending(i => i.VoteCount ?? 0)
.ToList();
}
示例14: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var baseItem = (BaseItem)item;
var list = new List<RemoteImageInfo>();
var movieId = baseItem.GetProviderId(MetadataProviders.Tmdb);
if (!string.IsNullOrEmpty(movieId))
{
// Bad id entered
try
{
await EnsureMovieJson(movieId, cancellationToken).ConfigureAwait(false);
}
catch (HttpException ex)
{
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
{
throw;
}
}
var path = GetFanartJsonPath(movieId);
try
{
AddImages(list, path, cancellationToken);
}
catch (FileNotFoundException)
{
// No biggie. Don't blow up
}
catch (DirectoryNotFoundException)
{
// No biggie. Don't blow up
}
}
var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
// Sort first by width to prioritize HD versions
return list.OrderByDescending(i => i.Width ?? 0)
.ThenByDescending(i =>
{
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
if (!isLanguageEn)
{
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
}
if (string.IsNullOrEmpty(i.Language))
{
return isLanguageEn ? 3 : 2;
}
return 0;
})
.ThenByDescending(i => i.CommunityRating ?? 0);
}
示例15: GetImages
public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var list = new List<RemoteImageInfo>();
var season = (Season)item;
var series = season.Series;
if (series != null)
{
var id = series.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(id) && season.IndexNumber.HasValue)
{
// Bad id entered
try
{
await FanartSeriesProvider.Current.EnsureSeriesJson(id, cancellationToken).ConfigureAwait(false);
}
catch (HttpException ex)
{
if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
{
throw;
}
}
var path = FanartSeriesProvider.Current.GetFanartJsonPath(id);
try
{
int seasonNumber = AdjustForSeriesOffset(series, season.IndexNumber.Value);
AddImages(list, seasonNumber, path, cancellationToken);
}
catch (FileNotFoundException)
{
// No biggie. Don't blow up
}
catch (DirectoryNotFoundException)
{
// No biggie. Don't blow up
}
}
}
var language = item.GetPreferredMetadataLanguage();
var isLanguageEn = string.Equals(language, "en", StringComparison.OrdinalIgnoreCase);
// Sort first by width to prioritize HD versions
return list.OrderByDescending(i => i.Width ?? 0)
.ThenByDescending(i =>
{
if (string.Equals(language, i.Language, StringComparison.OrdinalIgnoreCase))
{
return 3;
}
if (!isLanguageEn)
{
if (string.Equals("en", i.Language, StringComparison.OrdinalIgnoreCase))
{
return 2;
}
}
if (string.IsNullOrEmpty(i.Language))
{
return isLanguageEn ? 3 : 2;
}
return 0;
})
.ThenByDescending(i => i.CommunityRating ?? 0)
.ThenByDescending(i => i.VoteCount ?? 0);
}