本文整理汇总了C#中BaseItem.SetProviderId方法的典型用法代码示例。如果您正苦于以下问题:C# BaseItem.SetProviderId方法的具体用法?C# BaseItem.SetProviderId怎么用?C# BaseItem.SetProviderId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseItem
的用法示例。
在下文中一共展示了BaseItem.SetProviderId方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FetchAsync
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{
var releaseId = item.GetProviderId(MetadataProviders.Musicbrainz);
var releaseGroupId = item.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);
if (string.IsNullOrEmpty(releaseId))
{
var result = await GetReleaseResult((MusicAlbum)item, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(result.ReleaseId))
{
releaseId = result.ReleaseId;
item.SetProviderId(MetadataProviders.Musicbrainz, releaseId);
}
if (!string.IsNullOrEmpty(result.ReleaseGroupId))
{
releaseGroupId = result.ReleaseGroupId;
item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, releaseGroupId);
}
}
// If we have a release Id but not a release group Id...
if (!string.IsNullOrEmpty(releaseId) && string.IsNullOrEmpty(releaseGroupId))
{
releaseGroupId = await GetReleaseGroupId(releaseId, cancellationToken).ConfigureAwait(false);
item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, releaseGroupId);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
}
示例2: ProcessAlbumData
public static void ProcessAlbumData(BaseItem item, LastfmAlbum data)
{
if (!string.IsNullOrWhiteSpace(data.mbid)) item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid);
var overview = data.wiki != null ? data.wiki.content : null;
item.Overview = overview;
DateTime release;
DateTime.TryParse(data.releasedate, out release);
item.PremiereDate = release;
item.ProductionYear = release.Year;
if (data.toptags != null)
{
AddTags(item, data.toptags);
}
}
示例3: FetchAsync
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LastfmHelper.LocalArtistMetaFileName));
if (entry != null)
{
// read in our saved meta and pass to processing function
var data = JsonSerializer.DeserializeFromFile<LastfmArtist>(entry.FullName);
cancellationToken.ThrowIfCancellationRequested();
LastfmHelper.ProcessArtistData(item, data);
item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid);
SetLastRefreshed(item, DateTime.UtcNow);
return TrueTaskResult;
}
return FalseTaskResult;
}
示例4: ProcessMainInfo
/// <summary>
/// Processes the main info.
/// </summary>
/// <param name="movie">The movie.</param>
/// <param name="movieData">The movie data.</param>
protected virtual void ProcessMainInfo(BaseItem movie, CompleteMovieData movieData)
{
if (movie != null && movieData != null)
{
if (!movie.LockedFields.Contains(MetadataFields.Name))
{
movie.Name = movieData.title ?? movieData.original_title ?? movie.Name;
}
if (!movie.LockedFields.Contains(MetadataFields.Overview))
{
movie.Overview = WebUtility.HtmlDecode(movieData.overview);
}
movie.Overview = movie.Overview != null ? movie.Overview.Replace("\n\n", "\n") : null;
movie.HomePageUrl = movieData.homepage;
movie.Budget = movieData.budget;
movie.Revenue = movieData.revenue;
if (!string.IsNullOrEmpty(movieData.tagline))
{
movie.Taglines.Clear();
movie.AddTagline(movieData.tagline);
}
movie.SetProviderId(MetadataProviders.Imdb, movieData.imdb_id);
if (movieData.belongs_to_collection != null)
{
movie.SetProviderId(MetadataProviders.TmdbCollection, movieData.belongs_to_collection.id.ToString(CultureInfo.InvariantCulture));
}
float rating;
string voteAvg = movieData.vote_average.ToString(CultureInfo.InvariantCulture);
//tmdb appears to have unified their numbers to always report "7.3" regardless of country
// so I removed the culture-specific processing here because it was not working for other countries -ebr
if (float.TryParse(voteAvg, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out rating))
movie.CommunityRating = rating;
movie.VoteCount = movieData.vote_count;
//release date and certification are retrieved based on configured country and we fall back on US if not there and to minimun release date if still no match
if (movieData.releases != null && movieData.releases.countries != null)
{
var ourRelease = movieData.releases.countries.FirstOrDefault(c => c.iso_3166_1.Equals(ConfigurationManager.Configuration.MetadataCountryCode, StringComparison.OrdinalIgnoreCase)) ?? new Country();
var usRelease = movieData.releases.countries.FirstOrDefault(c => c.iso_3166_1.Equals("US", StringComparison.OrdinalIgnoreCase)) ?? new Country();
var minimunRelease = movieData.releases.countries.OrderBy(c => c.release_date).FirstOrDefault() ?? new Country();
var ratingPrefix = ConfigurationManager.Configuration.MetadataCountryCode.Equals("us", StringComparison.OrdinalIgnoreCase) ? "" : ConfigurationManager.Configuration.MetadataCountryCode + "-";
movie.OfficialRating = !string.IsNullOrEmpty(ourRelease.certification)
? ratingPrefix + ourRelease.certification
: !string.IsNullOrEmpty(usRelease.certification)
? usRelease.certification
: !string.IsNullOrEmpty(minimunRelease.certification)
? minimunRelease.iso_3166_1 + "-" + minimunRelease.certification
: null;
if (ourRelease.release_date != default(DateTime))
{
if (ourRelease.release_date.Year != 1)
{
movie.PremiereDate = ourRelease.release_date.ToUniversalTime();
movie.ProductionYear = ourRelease.release_date.Year;
}
}
else if (usRelease.release_date != default(DateTime))
{
if (usRelease.release_date.Year != 1)
{
movie.PremiereDate = usRelease.release_date.ToUniversalTime();
movie.ProductionYear = usRelease.release_date.Year;
}
}
else if (minimunRelease.release_date != default(DateTime))
{
if (minimunRelease.release_date.Year != 1)
{
movie.PremiereDate = minimunRelease.release_date.ToUniversalTime();
movie.ProductionYear = minimunRelease.release_date.Year;
}
}
}
else
{
if (movieData.release_date.Year != 1)
{
//no specific country release info at all
movie.PremiereDate = movieData.release_date.ToUniversalTime();
movie.ProductionYear = movieData.release_date.Year;
}
}
//if that didn't find a rating and we are a boxset, use the one from our first child
if (movie.OfficialRating == null && movie is BoxSet)
{
var boxset = movie as BoxSet;
//.........这里部分代码省略.........
示例5: FetchMovieData
/// <summary>
/// Fetches the movie data.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="id">The id.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>Task.</returns>
protected async Task FetchMovieData(BaseItem item, string id, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (String.IsNullOrEmpty(id))
{
Logger.Info("MoviedbProvider: Ignoring " + item.Name + " because ID forced blank.");
return;
}
item.SetProviderId(MetadataProviders.Tmdb, id);
var mainResult = await FetchMainResult(item, id, cancellationToken).ConfigureAwait(false);
if (mainResult == null) return;
ProcessMainInfo(item, mainResult);
}
示例6: Fetch
public async Task Fetch(BaseItem item, string imdbId, string language, CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(imdbId))
{
throw new ArgumentNullException("imdbId");
}
var imdbParam = imdbId.StartsWith("tt", StringComparison.OrdinalIgnoreCase) ? imdbId : "tt" + imdbId;
var url = string.Format("http://www.omdbapi.com/?i={0}&tomatoes=true", imdbParam);
using (var stream = await _httpClient.Get(new HttpRequestOptions
{
Url = url,
ResourcePool = ResourcePool,
CancellationToken = cancellationToken,
CacheMode = CacheMode.Unconditional,
CacheLength = TimeSpan.FromDays(7)
}).ConfigureAwait(false))
{
var result = _jsonSerializer.DeserializeFromStream<RootObject>(stream);
// Only take the name if the user's language is set to english, since Omdb has no localization
if (string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
{
item.Name = result.Title;
}
int year;
if (!string.IsNullOrEmpty(result.Year)
&& int.TryParse(result.Year, NumberStyles.Number, _usCulture, out year)
&& year >= 0)
{
item.ProductionYear = year;
}
item.OfficialRating = result.Rated;
var hasCriticRating = item as IHasCriticRating;
if (hasCriticRating != null)
{
// Seeing some bogus RT data on omdb for series, so filter it out here
// RT doesn't even have tv series
int tomatoMeter;
if (!string.IsNullOrEmpty(result.tomatoMeter)
&& int.TryParse(result.tomatoMeter, NumberStyles.Integer, _usCulture, out tomatoMeter)
&& tomatoMeter >= 0)
{
hasCriticRating.CriticRating = tomatoMeter;
}
if (!string.IsNullOrEmpty(result.tomatoConsensus)
&& !string.Equals(result.tomatoConsensus, "n/a", StringComparison.OrdinalIgnoreCase)
&& !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase))
{
hasCriticRating.CriticRatingSummary = WebUtility.HtmlDecode(result.tomatoConsensus);
}
}
int voteCount;
if (!string.IsNullOrEmpty(result.imdbVotes)
&& int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount)
&& voteCount >= 0)
{
item.VoteCount = voteCount;
}
float imdbRating;
if (!string.IsNullOrEmpty(result.imdbRating)
&& float.TryParse(result.imdbRating, NumberStyles.Any, _usCulture, out imdbRating)
&& imdbRating >= 0)
{
item.CommunityRating = imdbRating;
}
if (!string.IsNullOrEmpty(result.Website)
&& !string.Equals(result.Website, "n/a", StringComparison.OrdinalIgnoreCase))
{
item.HomePageUrl = result.Website;
}
if (!string.IsNullOrWhiteSpace(result.imdbID)
&& !string.Equals(result.imdbID, "n/a", StringComparison.OrdinalIgnoreCase))
{
item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
}
ParseAdditionalMetadata(item, result);
}
}
示例7: ProcessAlbumData
public static void ProcessAlbumData(BaseItem item, LastfmAlbum data)
{
if (!string.IsNullOrWhiteSpace(data.mbid)) item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid);
var overview = data.wiki != null ? data.wiki.content : null;
if (!item.LockedFields.Contains(MetadataFields.Overview))
{
item.Overview = overview;
}
DateTime release;
if (DateTime.TryParse(data.releasedate, out release) && release.Year != 1901)
{
item.PremiereDate = release;
item.ProductionYear = release.Year;
}
if (data.toptags != null && !item.LockedFields.Contains(MetadataFields.Tags))
{
AddTags(item, data.toptags);
}
var album = (MusicAlbum)item;
string imageSize;
album.LastFmImageUrl = GetImageUrl(data, out imageSize);
album.LastFmImageSize = imageSize;
}
示例8: FetchData
/// <summary>
/// Fetches the items data.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="cancellationToken"></param>
/// <returns>Task.</returns>
protected virtual async Task FetchData(BaseItem item, bool force, CancellationToken cancellationToken)
{
var id = item.GetProviderId(MetadataProviders.Musicbrainz) ?? await FindId(item, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrWhiteSpace(id))
{
Logger.Debug("LastfmProvider - getting info for {0}", item.Name);
cancellationToken.ThrowIfCancellationRequested();
item.SetProviderId(MetadataProviders.Musicbrainz, id);
await FetchLastfmData(item, id, force, cancellationToken).ConfigureAwait(false);
}
else
{
Logger.Info("LastfmProvider could not find " + item.Name + ". Check name on Last.fm.");
}
}
示例9: FetchAsync
/// <summary>
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
/// </summary>
/// <param name="item">The item.</param>
/// <param name="force">if set to <c>true</c> [force].</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>Task{System.Boolean}.</returns>
public override async Task<bool> FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var id = item.GetProviderId(MetadataProviders.Musicbrainz) ?? await FindId(item, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrWhiteSpace(id))
{
cancellationToken.ThrowIfCancellationRequested();
item.SetProviderId(MetadataProviders.Musicbrainz, id);
await FetchLastfmData(item, id, force, cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
return true;
}
示例10: FetchMovieData
/// <summary>
/// Fetches the movie data.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="id">The id.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>Task.</returns>
protected async Task FetchMovieData(BaseItem item, string id, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
if (String.IsNullOrEmpty(id))
{
Logger.Info("MoviedbProvider: Ignoring " + item.Name + " because ID forced blank.");
return;
}
if (item.GetProviderId(MetadataProviders.Tmdb) == null) item.SetProviderId(MetadataProviders.Tmdb, id);
var mainResult = await FetchMainResult(item, id, cancellationToken).ConfigureAwait(false);
if (mainResult == null) return;
ProcessMainInfo(item, mainResult);
cancellationToken.ThrowIfCancellationRequested();
//and save locally
if (ConfigurationManager.Configuration.SaveLocalMeta && item.LocationType == LocationType.FileSystem)
{
var ms = new MemoryStream();
JsonSerializer.SerializeToStream(mainResult, ms);
cancellationToken.ThrowIfCancellationRequested();
await ProviderManager.SaveToLibraryFilesystem(item, Path.Combine(item.MetaLocation, LocalMetaFileName), ms, cancellationToken).ConfigureAwait(false);
}
}
示例11: ProcessMainInfo
/// <summary>
/// Processes the main info.
/// </summary>
/// <param name="movie">The movie.</param>
/// <param name="movieData">The movie data.</param>
private void ProcessMainInfo(BaseItem movie, CompleteMovieData movieData)
{
if (!movie.LockedFields.Contains(MetadataFields.Name))
{
movie.Name = movieData.title ?? movieData.original_title ?? movieData.name ?? movie.Name;
}
if (!movie.LockedFields.Contains(MetadataFields.Overview))
{
// Bug in Mono: WebUtility.HtmlDecode should return null if the string is null but in Mono it generate an System.ArgumentNullException.
movie.Overview = movieData.overview != null ? WebUtility.HtmlDecode(movieData.overview) : null;
movie.Overview = movie.Overview != null ? movie.Overview.Replace("\n\n", "\n") : null;
}
movie.HomePageUrl = movieData.homepage;
var hasBudget = movie as IHasBudget;
if (hasBudget != null)
{
hasBudget.Budget = movieData.budget;
hasBudget.Revenue = movieData.revenue;
}
if (!string.IsNullOrEmpty(movieData.tagline))
{
var hasTagline = movie as IHasTaglines;
if (hasTagline != null)
{
hasTagline.Taglines.Clear();
hasTagline.AddTagline(movieData.tagline);
}
}
movie.SetProviderId(MetadataProviders.Tmdb, movieData.id.ToString(_usCulture));
movie.SetProviderId(MetadataProviders.Imdb, movieData.imdb_id);
if (movieData.belongs_to_collection != null)
{
movie.SetProviderId(MetadataProviders.TmdbCollection,
movieData.belongs_to_collection.id.ToString(CultureInfo.InvariantCulture));
var movieItem = movie as Movie;
if (movieItem != null)
{
movieItem.TmdbCollectionName = movieData.belongs_to_collection.name;
}
}
else
{
movie.SetProviderId(MetadataProviders.TmdbCollection, null); // clear out any old entry
}
float rating;
string voteAvg = movieData.vote_average.ToString(CultureInfo.InvariantCulture);
// tmdb appears to have unified their numbers to always report "7.3" regardless of country
// so I removed the culture-specific processing here because it was not working for other countries -ebr
// Movies get this from imdb
if (!(movie is Movie) && float.TryParse(voteAvg, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out rating))
{
movie.CommunityRating = rating;
}
// Movies get this from imdb
if (!(movie is Movie))
{
movie.VoteCount = movieData.vote_count;
}
var preferredCountryCode = movie.GetPreferredMetadataCountryCode();
//release date and certification are retrieved based on configured country and we fall back on US if not there and to minimun release date if still no match
if (movieData.releases != null && movieData.releases.countries != null)
{
var ourRelease = movieData.releases.countries.FirstOrDefault(c => c.iso_3166_1.Equals(preferredCountryCode, StringComparison.OrdinalIgnoreCase)) ?? new Country();
var usRelease = movieData.releases.countries.FirstOrDefault(c => c.iso_3166_1.Equals("US", StringComparison.OrdinalIgnoreCase)) ?? new Country();
var minimunRelease = movieData.releases.countries.OrderBy(c => c.release_date).FirstOrDefault() ?? new Country();
if (!movie.LockedFields.Contains(MetadataFields.OfficialRating))
{
var ratingPrefix = string.Equals(preferredCountryCode, "us", StringComparison.OrdinalIgnoreCase) ? "" : preferredCountryCode + "-";
movie.OfficialRating = !string.IsNullOrEmpty(ourRelease.certification)
? ratingPrefix + ourRelease.certification
: !string.IsNullOrEmpty(usRelease.certification)
? usRelease.certification
: !string.IsNullOrEmpty(minimunRelease.certification)
? minimunRelease.iso_3166_1 + "-" + minimunRelease.certification
: null;
}
}
if (movieData.release_date.Year != 1)
{
//no specific country release info at all
movie.PremiereDate = movieData.release_date.ToUniversalTime();
movie.ProductionYear = movieData.release_date.Year;
//.........这里部分代码省略.........
示例12: FetchRottenTomatoesId
private async Task FetchRottenTomatoesId(BaseItem item, string apiKey, CancellationToken cancellationToken)
{
var imdbId = item.GetProviderId(MetadataProviders.Imdb);
RequestHistory.Add(DateTime.UtcNow);
// Have IMDB Id
using (var stream = await _httpClient.Get(new HttpRequestOptions
{
Url = GetMovieImdbUrl(imdbId, apiKey),
ResourcePool = _rottenTomatoesResourcePool,
CancellationToken = cancellationToken
}).ConfigureAwait(false))
{
var hit = _jsonSerializer.DeserializeFromStream<RTMovieSearchResult>(stream);
if (!string.IsNullOrEmpty(hit.id))
{
// Got a result
item.CriticRatingSummary = hit.critics_consensus;
var rating = float.Parse(hit.ratings.critics_score);
if (rating > 0)
{
item.CriticRating = rating;
}
item.SetProviderId(RottenTomatoesExternalId.KeyName, hit.id);
}
}
}
示例13: DeserializeProviderIds
private void DeserializeProviderIds(string value, BaseItem item)
{
if (string.IsNullOrWhiteSpace(value))
{
return;
}
if (item.ProviderIds.Count > 0)
{
return;
}
var parts = value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var part in parts)
{
var idParts = part.Split('=');
item.SetProviderId(idParts[0], idParts[1]);
}
}
示例14: FetchAsync
/// <summary>
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
/// </summary>
/// <param name="item">The item.</param>
/// <param name="force">if set to <c>true</c> [force].</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>Task{System.Boolean}.</returns>
public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
var id = item.GetProviderId(MetadataProviders.Tmdb);
if (string.IsNullOrEmpty(id))
{
id = item.GetProviderId(MetadataProviders.Imdb);
}
if (string.IsNullOrEmpty(id))
{
id = await FindId(item, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(id))
{
item.SetProviderId(MetadataProviders.Tmdb, id);
}
}
if (!string.IsNullOrEmpty(id))
{
cancellationToken.ThrowIfCancellationRequested();
await FetchMovieData(item, id, force, cancellationToken).ConfigureAwait(false);
}
SetLastRefreshed(item, DateTime.UtcNow);
return true;
}