Пример #1
0
        private void FetchPeople(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions options)
        {
            var isFullRefresh = options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh;

            if (!video.IsLocked && !video.LockedFields.Contains(MetadataFields.Cast))
            {
                if (isFullRefresh || _libraryManager.GetPeople(video).Count == 0)
                {
                    var people = new List <PersonInfo>();

                    foreach (var person in data.People)
                    {
                        PeopleHelper.AddPerson(people, new PersonInfo
                        {
                            Name = person.Name,
                            Type = person.Type,
                            Role = person.Role
                        });
                    }

                    _libraryManager.UpdatePeople(video, people);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Fetches data from the tags dictionary
        /// </summary>
        /// <param name="audio">The audio.</param>
        /// <param name="data">The data.</param>
        private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo data)
        {
            // Only set Name if title was found in the dictionary
            if (!string.IsNullOrEmpty(data.Name))
            {
                audio.Name = data.Name;
            }

            if (!audio.LockedFields.Contains(MetadataFields.Cast))
            {
                var people = new List <PersonInfo>();

                foreach (var person in data.People)
                {
                    PeopleHelper.AddPerson(people, new PersonInfo
                    {
                        Name = person.Name,
                        Type = person.Type,
                        Role = person.Role
                    });
                }

                await _libraryManager.UpdatePeople(audio, people).ConfigureAwait(false);
            }

            audio.Album             = data.Album;
            audio.Artists           = data.Artists;
            audio.AlbumArtists      = data.AlbumArtists;
            audio.IndexNumber       = data.IndexNumber;
            audio.ParentIndexNumber = data.ParentIndexNumber;
            audio.ProductionYear    = data.ProductionYear;
            audio.PremiereDate      = data.PremiereDate;

            // If we don't have a ProductionYear try and get it from PremiereDate
            if (audio.PremiereDate.HasValue && !audio.ProductionYear.HasValue)
            {
                audio.ProductionYear = audio.PremiereDate.Value.ToLocalTime().Year;
            }

            if (!audio.LockedFields.Contains(MetadataFields.Genres))
            {
                audio.Genres.Clear();

                foreach (var genre in data.Genres)
                {
                    audio.AddGenre(genre);
                }
            }

            if (!audio.LockedFields.Contains(MetadataFields.Studios))
            {
                audio.Studios.Clear();

                foreach (var studio in data.Studios)
                {
                    audio.AddStudio(studio);
                }
            }

            audio.SetProviderId(MetadataProviders.MusicBrainzAlbumArtist, data.GetProviderId(MetadataProviders.MusicBrainzAlbumArtist));
            audio.SetProviderId(MetadataProviders.MusicBrainzArtist, data.GetProviderId(MetadataProviders.MusicBrainzArtist));
            audio.SetProviderId(MetadataProviders.MusicBrainzAlbum, data.GetProviderId(MetadataProviders.MusicBrainzAlbum));
            audio.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, data.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup));
            audio.SetProviderId(MetadataProviders.MusicBrainzTrack, data.GetProviderId(MetadataProviders.MusicBrainzTrack));
        }
Пример #3
0
        /// <summary>
        /// Processes the main info.
        /// </summary>
        /// <param name="resultItem">The result item.</param>
        /// <param name="preferredCountryCode">The preferred country code.</param>
        /// <param name="movieData">The movie data.</param>
        private void ProcessMainInfo(MetadataResult <T> resultItem, string preferredCountryCode, MovieDbProvider.CompleteMovieData movieData)
        {
            var movie = resultItem.Item;

            movie.Name = movieData.GetTitle() ?? movie.Name;

            var hasOriginalTitle = movie as IHasOriginalTitle;

            if (hasOriginalTitle != null)
            {
                hasOriginalTitle.OriginalTitle = movieData.GetOriginalTitle();
            }

            // 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);
                }
            }

            if (movieData.production_countries != null)
            {
                var hasProductionLocations = movie as IHasProductionLocations;
                if (hasProductionLocations != null)
                {
                    hasProductionLocations.ProductionLocations = movieData
                                                                 .production_countries
                                                                 .Select(i => i.name)
                                                                 .ToList();
                }
            }

            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;
                }
            }

            float  rating;
            string voteAvg = movieData.vote_average.ToString(CultureInfo.InvariantCulture);

            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(preferredCountryCode, StringComparison.OrdinalIgnoreCase)) ?? new MovieDbProvider.Country();
                var usRelease      = movieData.releases.countries.FirstOrDefault(c => c.iso_3166_1.Equals("US", StringComparison.OrdinalIgnoreCase)) ?? new MovieDbProvider.Country();
                var minimunRelease = movieData.releases.countries.OrderBy(c => c.release_date).FirstOrDefault() ?? new MovieDbProvider.Country();

                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 (!string.IsNullOrWhiteSpace(movieData.release_date))
            {
                DateTime r;

                // These dates are always in this exact format
                if (DateTime.TryParse(movieData.release_date, _usCulture, DateTimeStyles.None, out r))
                {
                    movie.PremiereDate   = r.ToUniversalTime();
                    movie.ProductionYear = movie.PremiereDate.Value.Year;
                }
            }

            //studios
            if (movieData.production_companies != null)
            {
                movie.Studios.Clear();

                foreach (var studio in movieData.production_companies.Select(c => c.name))
                {
                    movie.AddStudio(studio);
                }
            }

            // genres
            // Movies get this from imdb
            var genres = movieData.genres ?? new List <MovieDbProvider.GenreItem>();

            foreach (var genre in genres.Select(g => g.name))
            {
                movie.AddGenre(genre);
            }

            //Actors, Directors, Writers - all in People
            //actors come from cast
            if (movieData.casts != null && movieData.casts.cast != null)
            {
                foreach (var actor in movieData.casts.cast.OrderBy(a => a.order))
                {
                    PeopleHelper.AddPerson(resultItem.People, new PersonInfo {
                        Name = actor.name.Trim(), Role = actor.character, Type = PersonType.Actor, SortOrder = actor.order
                    });
                }
            }

            //and the rest from crew
            if (movieData.casts != null && movieData.casts.crew != null)
            {
                foreach (var person in movieData.casts.crew)
                {
                    PeopleHelper.AddPerson(resultItem.People, new PersonInfo {
                        Name = person.name.Trim(), Role = person.job, Type = person.department
                    });
                }
            }

            if (movieData.keywords != null && movieData.keywords.keywords != null)
            {
                var hasTags = movie as IHasKeywords;
                if (hasTags != null)
                {
                    hasTags.Keywords = movieData.keywords.keywords.Select(i => i.name).ToList();
                }
            }

            if (movieData.trailers != null && movieData.trailers.youtube != null &&
                movieData.trailers.youtube.Count > 0)
            {
                var hasTrailers = movie as IHasTrailers;
                if (hasTrailers != null)
                {
                    hasTrailers.RemoteTrailers = movieData.trailers.youtube.Select(i => new MediaUrl
                    {
                        Url       = string.Format("http://www.youtube.com/watch?v={0}", i.source),
                        Name      = i.name,
                        VideoSize = string.Equals("hd", i.size, StringComparison.OrdinalIgnoreCase) ? VideoSize.HighDefinition : VideoSize.StandardDefinition
                    }).ToList();
                }
            }
        }
Пример #4
0
        protected virtual void FetchDataFromXmlNode(XmlReader reader, LocalMetadataResult <T> itemResult)
        {
            var item = itemResult.Item;

            var userDataUserId = _config.GetNfoConfiguration().UserId;

            switch (reader.Name)
            {
            // DateCreated
            case "dateadded":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    DateTime added;
                    if (DateTime.TryParse(val, out added))
                    {
                        item.DateCreated = added.ToUniversalTime();
                    }
                    else
                    {
                        Logger.Warn("Invalid Added value found: " + val);
                    }
                }
                break;
            }

            case "originaltitle":
            {
                var val = reader.ReadElementContentAsString();

                var hasOriginalTitle = item as IHasOriginalTitle;
                if (hasOriginalTitle != null)
                {
                    if (!string.IsNullOrEmpty(hasOriginalTitle.OriginalTitle))
                    {
                        hasOriginalTitle.OriginalTitle = val;
                    }
                }
                break;
            }

            case "type":
                item.DisplayMediaType = reader.ReadElementContentAsString();
                break;

            case "title":
            case "localtitle":
                item.Name = reader.ReadElementContentAsString();
                break;

            case "criticrating":
            {
                var text = reader.ReadElementContentAsString();

                var hasCriticRating = item as IHasCriticRating;

                if (hasCriticRating != null && !string.IsNullOrEmpty(text))
                {
                    float value;
                    if (float.TryParse(text, NumberStyles.Any, _usCulture, out value))
                    {
                        hasCriticRating.CriticRating = value;
                    }
                }

                break;
            }

            case "budget":
            {
                var text      = reader.ReadElementContentAsString();
                var hasBudget = item as IHasBudget;
                if (hasBudget != null)
                {
                    double value;
                    if (double.TryParse(text, NumberStyles.Any, _usCulture, out value))
                    {
                        hasBudget.Budget = value;
                    }
                }

                break;
            }

            case "revenue":
            {
                var text      = reader.ReadElementContentAsString();
                var hasBudget = item as IHasBudget;
                if (hasBudget != null)
                {
                    double value;
                    if (double.TryParse(text, NumberStyles.Any, _usCulture, out value))
                    {
                        hasBudget.Revenue = value;
                    }
                }

                break;
            }

            case "metascore":
            {
                var text         = reader.ReadElementContentAsString();
                var hasMetascore = item as IHasMetascore;
                if (hasMetascore != null)
                {
                    float value;
                    if (float.TryParse(text, NumberStyles.Any, _usCulture, out value))
                    {
                        hasMetascore.Metascore = value;
                    }
                }

                break;
            }

            case "awardsummary":
            {
                var text      = reader.ReadElementContentAsString();
                var hasAwards = item as IHasAwards;
                if (hasAwards != null)
                {
                    if (!string.IsNullOrWhiteSpace(text))
                    {
                        hasAwards.AwardSummary = text;
                    }
                }

                break;
            }

            case "sorttitle":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    item.ForcedSortName = val;
                }
                break;
            }

            case "outline":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    var hasShortOverview = item as IHasShortOverview;

                    if (hasShortOverview != null)
                    {
                        hasShortOverview.ShortOverview = val;
                    }
                }
                break;
            }

            case "biography":
            case "plot":
            case "review":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    item.Overview = val;
                }

                break;
            }

            case "criticratingsummary":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    var hasCriticRating = item as IHasCriticRating;

                    if (hasCriticRating != null)
                    {
                        hasCriticRating.CriticRatingSummary = val;
                    }
                }

                break;
            }

            case "language":
            {
                var val = reader.ReadElementContentAsString();

                var hasLanguage = item as IHasPreferredMetadataLanguage;
                if (hasLanguage != null)
                {
                    hasLanguage.PreferredMetadataLanguage = val;
                }

                break;
            }

            case "countrycode":
            {
                var val = reader.ReadElementContentAsString();

                var hasLanguage = item as IHasPreferredMetadataLanguage;
                if (hasLanguage != null)
                {
                    hasLanguage.PreferredMetadataCountryCode = val;
                }

                break;
            }

            case "website":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    item.HomePageUrl = val;
                }

                break;
            }

            case "lockedfields":
            {
                var fields = new List <MetadataFields>();

                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    var list = val.Split('|').Select(i =>
                        {
                            MetadataFields field;

                            if (Enum.TryParse <MetadataFields>(i, true, out field))
                            {
                                return((MetadataFields?)field);
                            }

                            return(null);
                        }).Where(i => i.HasValue).Select(i => i.Value);

                    fields.AddRange(list);
                }

                item.LockedFields = fields;

                break;
            }

            case "tagline":
            {
                var val = reader.ReadElementContentAsString();

                var hasTagline = item as IHasTaglines;
                if (hasTagline != null)
                {
                    if (!string.IsNullOrWhiteSpace(val))
                    {
                        hasTagline.AddTagline(val);
                    }
                }
                break;
            }

            case "country":
            {
                var val = reader.ReadElementContentAsString();

                var hasProductionLocations = item as IHasProductionLocations;
                if (hasProductionLocations != null)
                {
                    if (!string.IsNullOrWhiteSpace(val))
                    {
                        var parts = val.Split('/')
                                    .Select(i => i.Trim())
                                    .Where(i => !string.IsNullOrWhiteSpace(i));

                        foreach (var p in parts)
                        {
                            hasProductionLocations.AddProductionLocation(p);
                        }
                    }
                }
                break;
            }

            case "mpaa":
            {
                var rating = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(rating))
                {
                    item.OfficialRating = rating;
                }
                break;
            }

            case "mpaadescription":
            {
                var rating = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(rating))
                {
                    item.OfficialRatingDescription = rating;
                }
                break;
            }

            case "customrating":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    item.CustomRating = val;
                }
                break;
            }

            case "runtime":
            {
                var text = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(text))
                {
                    int runtime;
                    if (int.TryParse(text.Split(' ')[0], NumberStyles.Integer, _usCulture, out runtime))
                    {
                        item.RunTimeTicks = TimeSpan.FromMinutes(runtime).Ticks;
                    }
                }
                break;
            }

            case "aspectratio":
            {
                var val = reader.ReadElementContentAsString();

                var hasAspectRatio = item as IHasAspectRatio;
                if (!string.IsNullOrWhiteSpace(val) && hasAspectRatio != null)
                {
                    hasAspectRatio.AspectRatio = val;
                }
                break;
            }

            case "lockdata":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    item.IsLocked = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
                }
                break;
            }

            case "studio":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    var parts = val.Split('/')
                                .Select(i => i.Trim())
                                .Where(i => !string.IsNullOrWhiteSpace(i));

                    foreach (var p in parts)
                    {
                        item.AddStudio(p);
                    }
                }
                break;
            }

            case "director":
            {
                foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo {
                        Name = v.Trim(), Type = PersonType.Director
                    }))
                {
                    if (string.IsNullOrWhiteSpace(p.Name))
                    {
                        continue;
                    }
                    PeopleHelper.AddPerson(itemResult.People, p);
                }
                break;
            }

            case "credits":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    var parts = val.Split('/').Select(i => i.Trim())
                                .Where(i => !string.IsNullOrEmpty(i));

                    foreach (var p in parts.Select(v => new PersonInfo {
                            Name = v.Trim(), Type = PersonType.Writer
                        }))
                    {
                        if (string.IsNullOrWhiteSpace(p.Name))
                        {
                            continue;
                        }
                        PeopleHelper.AddPerson(itemResult.People, p);
                    }
                }
                break;
            }

            case "writer":
            {
                foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo {
                        Name = v.Trim(), Type = PersonType.Writer
                    }))
                {
                    if (string.IsNullOrWhiteSpace(p.Name))
                    {
                        continue;
                    }
                    PeopleHelper.AddPerson(itemResult.People, p);
                }
                break;
            }

            case "actor":
            {
                using (var subtree = reader.ReadSubtree())
                {
                    var person = GetPersonFromXmlNode(subtree);

                    PeopleHelper.AddPerson(itemResult.People, person);
                }
                break;
            }

            case "trailer":
            {
                var val = reader.ReadElementContentAsString();

                var hasTrailer = item as IHasTrailers;
                if (hasTrailer != null)
                {
                    if (!string.IsNullOrWhiteSpace(val))
                    {
                        val = val.Replace("plugin://plugin.video.youtube/?action=play_video&videoid=", "http://www.youtube.com/watch?v=", StringComparison.OrdinalIgnoreCase);

                        hasTrailer.AddTrailerUrl(val, false);
                    }
                }
                break;
            }

            case "displayorder":
            {
                var val = reader.ReadElementContentAsString();

                var hasDisplayOrder = item as IHasDisplayOrder;
                if (hasDisplayOrder != null)
                {
                    if (!string.IsNullOrWhiteSpace(val))
                    {
                        hasDisplayOrder.DisplayOrder = val;
                    }
                }
                break;
            }

            case "year":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    int productionYear;
                    if (int.TryParse(val, out productionYear) && productionYear > 1850)
                    {
                        item.ProductionYear = productionYear;
                    }
                }

                break;
            }

            case "rating":
            {
                var rating = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(rating))
                {
                    float val;
                    // All external meta is saving this as '.' for decimal I believe...but just to be sure
                    if (float.TryParse(rating.Replace(',', '.'), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out val))
                    {
                        item.CommunityRating = val;
                    }
                }
                break;
            }

            case "aired":
            case "formed":
            case "premiered":
            case "releasedate":
            {
                var formatString = _config.GetNfoConfiguration().ReleaseDateFormat;

                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    DateTime date;

                    if (DateTime.TryParseExact(val, formatString, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out date) && date.Year > 1850)
                    {
                        item.PremiereDate   = date.ToUniversalTime();
                        item.ProductionYear = date.Year;
                    }
                }

                break;
            }

            case "enddate":
            {
                var formatString = _config.GetNfoConfiguration().ReleaseDateFormat;

                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    DateTime date;

                    if (DateTime.TryParseExact(val, formatString, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out date) && date.Year > 1850)
                    {
                        item.EndDate = date.ToUniversalTime();
                    }
                }

                break;
            }

            case "tvdbid":
                var tvdbId = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(tvdbId))
                {
                    item.SetProviderId(MetadataProviders.Tvdb, tvdbId);
                }
                break;

            case "votes":
            {
                var val = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(val))
                {
                    int num;

                    if (int.TryParse(val, NumberStyles.Integer, _usCulture, out num))
                    {
                        item.VoteCount = num;
                    }
                }
                break;
            }

            case "musicbrainzalbumid":
            {
                var mbz = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(mbz))
                {
                    item.SetProviderId(MetadataProviders.MusicBrainzAlbum, mbz);
                }
                break;
            }

            case "musicbrainzalbumartistid":
            {
                var mbz = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(mbz))
                {
                    item.SetProviderId(MetadataProviders.MusicBrainzAlbumArtist, mbz);
                }
                break;
            }

            case "musicbrainzartistid":
            {
                var mbz = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(mbz))
                {
                    item.SetProviderId(MetadataProviders.MusicBrainzArtist, mbz);
                }
                break;
            }

            case "musicbrainzreleasegroupid":
            {
                var mbz = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(mbz))
                {
                    item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, mbz);
                }
                break;
            }

            case "tvrageid":
            {
                var id = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(id))
                {
                    item.SetProviderId(MetadataProviders.TvRage, id);
                }
                break;
            }

            case "audiodbartistid":
            {
                var id = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(id))
                {
                    item.SetProviderId(MetadataProviders.AudioDbArtist, id);
                }
                break;
            }

            case "audiodbalbumid":
            {
                var id = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(id))
                {
                    item.SetProviderId(MetadataProviders.AudioDbAlbum, id);
                }
                break;
            }

            case "rottentomatoesid":
                var rtId = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(rtId))
                {
                    item.SetProviderId(MetadataProviders.RottenTomatoes, rtId);
                }
                break;

            case "tmdbid":
                var tmdb = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(tmdb))
                {
                    item.SetProviderId(MetadataProviders.Tmdb, tmdb);
                }
                break;

            case "collectionnumber":
                var tmdbCollection = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(tmdbCollection))
                {
                    item.SetProviderId(MetadataProviders.TmdbCollection, tmdbCollection);
                }
                break;

            case "tvcomid":
                var TVcomId = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(TVcomId))
                {
                    item.SetProviderId(MetadataProviders.Tvcom, TVcomId);
                }
                break;

            case "zap2itid":
                var zap2ItId = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(zap2ItId))
                {
                    item.SetProviderId(MetadataProviders.Zap2It, zap2ItId);
                }
                break;

            case "imdb_id":
            case "imdbid":
                var imDbId = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(imDbId))
                {
                    item.SetProviderId(MetadataProviders.Imdb, imDbId);
                }
                break;

            case "genre":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    var parts = val.Split('/')
                                .Select(i => i.Trim())
                                .Where(i => !string.IsNullOrWhiteSpace(i));

                    foreach (var p in parts)
                    {
                        item.AddGenre(p);
                    }
                }
                break;
            }

            case "style":
            case "tag":
            {
                var val = reader.ReadElementContentAsString();
                if (!string.IsNullOrWhiteSpace(val))
                {
                    var hasTags = item as IHasTags;
                    if (hasTags != null)
                    {
                        hasTags.AddTag(val);
                    }
                }
                break;
            }

            case "plotkeyword":
            {
                var val = reader.ReadElementContentAsString();

                var hasKeywords = item as IHasKeywords;
                if (hasKeywords != null)
                {
                    if (!string.IsNullOrWhiteSpace(val))
                    {
                        hasKeywords.AddKeyword(val);
                    }
                }
                break;
            }

            case "fileinfo":
            {
                using (var subtree = reader.ReadSubtree())
                {
                    FetchFromFileInfoNode(subtree, item);
                }
                break;
            }

            case "watched":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    bool parsedValue;
                    if (bool.TryParse(val, out parsedValue))
                    {
                        if (!string.IsNullOrWhiteSpace(userDataUserId))
                        {
                            var userData = GetOrAdd(itemResult.UserDataLIst, userDataUserId);

                            userData.Played = parsedValue;
                        }
                    }
                }
                break;
            }

            case "playcount":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    int parsedValue;
                    if (int.TryParse(val, NumberStyles.Integer, _usCulture, out parsedValue))
                    {
                        if (!string.IsNullOrWhiteSpace(userDataUserId))
                        {
                            var userData = GetOrAdd(itemResult.UserDataLIst, userDataUserId);

                            userData.PlayCount = parsedValue;

                            if (parsedValue > 0)
                            {
                                userData.Played = true;
                            }
                        }
                    }
                }
                break;
            }

            case "lastplayed":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    DateTime parsedValue;
                    if (DateTime.TryParseExact(val, "yyyy-MM-dd HH:mm:ss", _usCulture, DateTimeStyles.None, out parsedValue))
                    {
                        if (!string.IsNullOrWhiteSpace(userDataUserId))
                        {
                            var userData = GetOrAdd(itemResult.UserDataLIst, userDataUserId);

                            userData.LastPlayedDate = parsedValue;
                        }
                    }
                }
                break;
            }

            case "resume":
            {
                using (var subtree = reader.ReadSubtree())
                {
                    if (!string.IsNullOrWhiteSpace(userDataUserId))
                    {
                        var userData = GetOrAdd(itemResult.UserDataLIst, userDataUserId);

                        FetchFromResumeNode(subtree, item, userData);
                    }
                }
                break;
            }

            case "isuserfavorite":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    bool parsedValue;
                    if (bool.TryParse(val, out parsedValue))
                    {
                        if (!string.IsNullOrWhiteSpace(userDataUserId))
                        {
                            var userData = GetOrAdd(itemResult.UserDataLIst, userDataUserId);

                            userData.IsFavorite = parsedValue;
                        }
                    }
                }
                break;
            }

            case "userrating":
            {
                var val = reader.ReadElementContentAsString();

                if (!string.IsNullOrWhiteSpace(val))
                {
                    double parsedValue;
                    if (double.TryParse(val, NumberStyles.Any, _usCulture, out parsedValue))
                    {
                        if (!string.IsNullOrWhiteSpace(userDataUserId))
                        {
                            var userData = GetOrAdd(itemResult.UserDataLIst, userDataUserId);

                            userData.Rating = parsedValue;
                        }
                    }
                }
                break;
            }

            default:
                reader.Skip();
                break;
            }
        }