private void FetchWtvInfo(Video video, InternalMediaInfoResult data) { if (data.format == null || data.format.tags == null) { return; } if (video.Genres.Count == 0) { if (!video.LockedFields.Contains(MetadataFields.Genres)) { var genres = FFProbeHelpers.GetDictionaryValue(data.format.tags, "genre"); if (!string.IsNullOrEmpty(genres)) { video.Genres = genres.Split(new[] { ';', '/', ',' }, StringSplitOptions.RemoveEmptyEntries) .Where(i => !string.IsNullOrWhiteSpace(i)) .Select(i => i.Trim()) .ToList(); } } } if (string.IsNullOrEmpty(video.Overview)) { if (!video.LockedFields.Contains(MetadataFields.Overview)) { var overview = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/SubTitleDescription"); if (!string.IsNullOrWhiteSpace(overview)) { video.Overview = overview; } } } if (string.IsNullOrEmpty(video.OfficialRating)) { var officialRating = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/ParentalRating"); if (!string.IsNullOrWhiteSpace(officialRating)) { if (!video.LockedFields.Contains(MetadataFields.OfficialRating)) { video.OfficialRating = officialRating; } } } if (video.People.Count == 0) { if (!video.LockedFields.Contains(MetadataFields.Cast)) { var people = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/MediaCredits"); if (!string.IsNullOrEmpty(people)) { video.People = people.Split(new[] { ';', '/' }, StringSplitOptions.RemoveEmptyEntries) .Where(i => !string.IsNullOrWhiteSpace(i)) .Select(i => new PersonInfo { Name = i.Trim(), Type = PersonType.Actor }) .ToList(); } } } if (!video.ProductionYear.HasValue) { var year = FFProbeHelpers.GetDictionaryValue(data.format.tags, "WM/OriginalReleaseTime"); if (!string.IsNullOrWhiteSpace(year)) { int val; if (int.TryParse(year, NumberStyles.Integer, _usCulture, out val)) { video.ProductionYear = val; } } } }
/// <summary> /// Fetches data from the tags dictionary /// </summary> /// <param name="audio">The audio.</param> /// <param name="tags">The tags.</param> private void FetchDataFromTags(Audio audio, Dictionary <string, string> tags) { var title = FFProbeHelpers.GetDictionaryValue(tags, "title"); // Only set Name if title was found in the dictionary if (!string.IsNullOrEmpty(title)) { audio.Name = title; } if (!audio.LockedFields.Contains(MetadataFields.Cast)) { audio.People.Clear(); var composer = FFProbeHelpers.GetDictionaryValue(tags, "composer"); if (!string.IsNullOrWhiteSpace(composer)) { foreach (var person in Split(composer, false)) { audio.AddPerson(new PersonInfo { Name = person, Type = PersonType.Composer }); } } } audio.Album = FFProbeHelpers.GetDictionaryValue(tags, "album"); var artists = FFProbeHelpers.GetDictionaryValue(tags, "artists"); if (!string.IsNullOrWhiteSpace(artists)) { audio.Artists = artists.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); } else { var artist = FFProbeHelpers.GetDictionaryValue(tags, "artist"); if (string.IsNullOrWhiteSpace(artist)) { audio.Artists.Clear(); } else { audio.Artists = SplitArtists(artist) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); } } var albumArtist = FFProbeHelpers.GetDictionaryValue(tags, "albumartist"); if (string.IsNullOrWhiteSpace(albumArtist)) { albumArtist = FFProbeHelpers.GetDictionaryValue(tags, "album artist"); } if (string.IsNullOrWhiteSpace(albumArtist)) { albumArtist = FFProbeHelpers.GetDictionaryValue(tags, "album_artist"); } if (string.IsNullOrWhiteSpace(albumArtist)) { audio.AlbumArtists = new List <string>(); } else { audio.AlbumArtists = SplitArtists(albumArtist) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); } // Track number audio.IndexNumber = GetDictionaryDiscValue(tags, "track"); // Disc number audio.ParentIndexNumber = GetDictionaryDiscValue(tags, "disc"); audio.ProductionYear = FFProbeHelpers.GetDictionaryNumericValue(tags, "date"); // Several different forms of retaildate audio.PremiereDate = FFProbeHelpers.GetDictionaryDateTime(tags, "retaildate") ?? FFProbeHelpers.GetDictionaryDateTime(tags, "retail date") ?? FFProbeHelpers.GetDictionaryDateTime(tags, "retail_date") ?? FFProbeHelpers.GetDictionaryDateTime(tags, "date"); // 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)) { FetchGenres(audio, tags); } if (!audio.LockedFields.Contains(MetadataFields.Studios)) { audio.Studios.Clear(); // There's several values in tags may or may not be present FetchStudios(audio, tags, "organization"); FetchStudios(audio, tags, "ensemble"); FetchStudios(audio, tags, "publisher"); } // These support mulitple values, but for now we only store the first. audio.SetProviderId(MetadataProviders.MusicBrainzAlbumArtist, GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Artist Id"))); audio.SetProviderId(MetadataProviders.MusicBrainzArtist, GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Artist Id"))); audio.SetProviderId(MetadataProviders.MusicBrainzAlbum, GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Id"))); audio.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Group Id"))); audio.SetProviderId(MetadataProviders.MusicBrainzTrack, GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Track Id"))); }