public void CacheExtractedItem(Guid extractedItemId, IDictionary <Guid, IList <MediaItemAspect> > extractedAspects)
        {
            CompanyInfo company = new CompanyInfo();

            company.FromMetadata(extractedAspects);
            AddToCache(extractedItemId, company);
        }
        private void ExtractFanArt(Guid mediaItemId, IDictionary <Guid, IList <MediaItemAspect> > aspects, Guid?albumMediaItemId, IDictionary <Guid, string> artistMediaItems)
        {
            if (aspects.ContainsKey(AudioAspect.ASPECT_ID))
            {
                if (BaseInfo.IsVirtualResource(aspects))
                {
                    return;
                }

                TrackInfo trackInfo = new TrackInfo();
                trackInfo.FromMetadata(aspects);
                bool      forceFanart = !trackInfo.IsRefreshed;
                AlbumInfo albumInfo   = trackInfo.CloneBasicInstance <AlbumInfo>();
                ExtractLocalImages(aspects, albumMediaItemId, artistMediaItems, albumInfo.ToString());
                if (!AudioMetadataExtractor.SkipFanArtDownload)
                {
                    OnlineMatcherService.Instance.DownloadAudioFanArt(mediaItemId, trackInfo, forceFanart);
                }

                if (albumMediaItemId.HasValue && !_checkCache.Contains(albumMediaItemId.Value))
                {
                    if (!AudioMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadAudioFanArt(albumMediaItemId.Value, albumInfo, forceFanart);
                    }
                    _checkCache.Add(albumMediaItemId.Value);
                }
            }
            else if (aspects.ContainsKey(PersonAspect.ASPECT_ID))
            {
                PersonInfo personInfo = new PersonInfo();
                personInfo.FromMetadata(aspects);
                if (personInfo.Occupation == PersonAspect.OCCUPATION_ARTIST || personInfo.Occupation == PersonAspect.OCCUPATION_COMPOSER)
                {
                    if (!AudioMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadAudioFanArt(mediaItemId, personInfo, !personInfo.IsRefreshed);
                    }
                }
            }
            else if (aspects.ContainsKey(CompanyAspect.ASPECT_ID))
            {
                CompanyInfo companyInfo = new CompanyInfo();
                companyInfo.FromMetadata(aspects);
                if (companyInfo.Type == CompanyAspect.COMPANY_MUSIC_LABEL)
                {
                    if (!AudioMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadAudioFanArt(mediaItemId, companyInfo, !companyInfo.IsRefreshed);
                    }
                }
            }
        }
Пример #3
0
        public override async Task CollectFanArtAsync(Guid mediaItemId, IDictionary <Guid, IList <MediaItemAspect> > aspects)
        {
            if (aspects.ContainsKey(MovieAspect.ASPECT_ID))
            {
                //Movies also handles movie collection fanart extraction
                await ExtractMovieFanArt(mediaItemId, aspects).ConfigureAwait(false);

                return;
            }

            if (MovieMetadataExtractor.SkipFanArtDownload || !AddToCache(mediaItemId))
            {
                return;
            }

            BaseInfo info = null;

            if (aspects.ContainsKey(PersonAspect.ASPECT_ID))
            {
                PersonInfo personInfo = new PersonInfo();
                personInfo.FromMetadata(aspects);
                if (personInfo.Occupation == PersonAspect.OCCUPATION_ACTOR || personInfo.Occupation == PersonAspect.OCCUPATION_DIRECTOR ||
                    personInfo.Occupation == PersonAspect.OCCUPATION_WRITER)
                {
                    info = personInfo;
                }
            }
            else if (aspects.ContainsKey(CharacterAspect.ASPECT_ID))
            {
                CharacterInfo characterInfo = new CharacterInfo();
                characterInfo.FromMetadata(aspects);
                info = characterInfo;
            }
            else if (aspects.ContainsKey(CompanyAspect.ASPECT_ID))
            {
                CompanyInfo companyInfo = new CompanyInfo();
                companyInfo.FromMetadata(aspects);
                if (companyInfo.Type == CompanyAspect.COMPANY_PRODUCTION)
                {
                    info = companyInfo;
                }
            }

            if (info != null)
            {
                await OnlineMatcherService.Instance.DownloadMovieFanArtAsync(mediaItemId, info).ConfigureAwait(false);
            }
        }
        public override void Update(MediaItem mediaItem)
        {
            base.Update(mediaItem);

            CompanyInfo company = new CompanyInfo();

            if (!company.FromMetadata(mediaItem.Aspects))
            {
                return;
            }

            Name        = company.Name ?? "";
            Description = company.Description.Text ?? "";

            FireChange();
        }
Пример #5
0
        public bool TryMatch(IDictionary <Guid, IList <MediaItemAspect> > extractedAspects, IDictionary <Guid, IList <MediaItemAspect> > existingAspects)
        {
            if (!existingAspects.ContainsKey(CompanyAspect.ASPECT_ID))
            {
                return(false);
            }

            CompanyInfo linkedCompany = new CompanyInfo();

            if (!linkedCompany.FromMetadata(extractedAspects))
            {
                return(false);
            }

            CompanyInfo existingCompany = new CompanyInfo();

            if (!existingCompany.FromMetadata(existingAspects))
            {
                return(false);
            }

            return(linkedCompany.Equals(existingCompany));
        }
Пример #6
0
 protected bool TryGetOnlineInfo(Guid mediaItemId, IDictionary <Guid, IList <MediaItemAspect> > aspects, out BaseInfo onlineInfo)
 {
     onlineInfo = null;
     if (aspects.ContainsKey(PersonAspect.ASPECT_ID))
     {
         PersonInfo personInfo = new PersonInfo();
         personInfo.FromMetadata(aspects);
         if (personInfo.Occupation == PersonAspect.OCCUPATION_ARTIST || personInfo.Occupation == PersonAspect.OCCUPATION_COMPOSER)
         {
             onlineInfo = personInfo;
         }
     }
     else if (aspects.ContainsKey(CompanyAspect.ASPECT_ID))
     {
         CompanyInfo companyInfo = new CompanyInfo();
         companyInfo.FromMetadata(aspects);
         if (companyInfo.Type == CompanyAspect.COMPANY_MUSIC_LABEL)
         {
             onlineInfo = companyInfo;
         }
     }
     return(onlineInfo != null);
 }
Пример #7
0
        private void ExtractFanArt(Guid mediaItemId, IDictionary <Guid, IList <MediaItemAspect> > aspects, Guid?collectionMediaItemId, IDictionary <Guid, string> actorMediaItems)
        {
            if (aspects.ContainsKey(MovieAspect.ASPECT_ID))
            {
                if (BaseInfo.IsVirtualResource(aspects))
                {
                    return;
                }

                MovieInfo movieInfo = new MovieInfo();
                movieInfo.FromMetadata(aspects);
                bool forceFanart = !movieInfo.IsRefreshed;
                MovieCollectionInfo collectionInfo = movieInfo.CloneBasicInstance <MovieCollectionInfo>();
                ExtractLocalImages(aspects, mediaItemId, collectionMediaItemId, movieInfo.ToString(), collectionInfo.ToString(), actorMediaItems);
                if (!MovieMetadataExtractor.SkipFanArtDownload)
                {
                    OnlineMatcherService.Instance.DownloadMovieFanArt(mediaItemId, movieInfo, forceFanart);
                }

                //Take advantage of the movie language being known and download collection too
                if (collectionMediaItemId.HasValue && !_checkCache.Contains(collectionMediaItemId.Value))
                {
                    if (!MovieMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadMovieFanArt(collectionMediaItemId.Value, collectionInfo, forceFanart);
                    }
                    _checkCache.Add(collectionMediaItemId.Value);
                }
            }
            else if (aspects.ContainsKey(PersonAspect.ASPECT_ID))
            {
                PersonInfo personInfo = new PersonInfo();
                personInfo.FromMetadata(aspects);
                if (personInfo.Occupation == PersonAspect.OCCUPATION_ACTOR || personInfo.Occupation == PersonAspect.OCCUPATION_DIRECTOR ||
                    personInfo.Occupation == PersonAspect.OCCUPATION_WRITER)
                {
                    if (!MovieMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadMovieFanArt(mediaItemId, personInfo, !personInfo.IsRefreshed);
                    }
                }
            }
            else if (aspects.ContainsKey(CharacterAspect.ASPECT_ID))
            {
                CharacterInfo characterInfo = new CharacterInfo();
                characterInfo.FromMetadata(aspects);
                if (!MovieMetadataExtractor.SkipFanArtDownload)
                {
                    OnlineMatcherService.Instance.DownloadMovieFanArt(mediaItemId, characterInfo, !characterInfo.IsRefreshed);
                }
            }
            else if (aspects.ContainsKey(CompanyAspect.ASPECT_ID))
            {
                CompanyInfo companyInfo = new CompanyInfo();
                companyInfo.FromMetadata(aspects);
                if (companyInfo.Type == CompanyAspect.COMPANY_PRODUCTION)
                {
                    if (!MovieMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadMovieFanArt(mediaItemId, companyInfo, !companyInfo.IsRefreshed);
                    }
                }
            }
        }
        private void ExtractFanArt(Guid mediaItemId, IDictionary <Guid, IList <MediaItemAspect> > aspects, Guid?seriesMediaItemId, Guid?seasonMediaItemId, IDictionary <Guid, string> actorMediaItems)
        {
            if (aspects.ContainsKey(EpisodeAspect.ASPECT_ID))
            {
                if (BaseInfo.IsVirtualResource(aspects))
                {
                    return;
                }

                EpisodeInfo episodeInfo = new EpisodeInfo();
                episodeInfo.FromMetadata(aspects);
                bool       forceFanart = !episodeInfo.IsRefreshed;
                SeasonInfo seasonInfo  = episodeInfo.CloneBasicInstance <SeasonInfo>();
                SeriesInfo seriesInfo  = episodeInfo.CloneBasicInstance <SeriesInfo>();
                ExtractLocalImages(aspects, mediaItemId, seriesMediaItemId, seasonMediaItemId, episodeInfo, seriesInfo, seasonInfo, actorMediaItems);
                if (!SeriesMetadataExtractor.SkipFanArtDownload)
                {
                    OnlineMatcherService.Instance.DownloadSeriesFanArt(mediaItemId, episodeInfo, forceFanart);
                }

                //Take advantage of the audio language being known and download season and series too
                if (seasonMediaItemId.HasValue && !_checkCache.Contains(seasonMediaItemId.Value))
                {
                    _checkCache.Add(seasonMediaItemId.Value);
                    if (!SeriesMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadSeriesFanArt(seasonMediaItemId.Value, seasonInfo, forceFanart);
                    }
                }
                if (seriesMediaItemId.HasValue && !_checkCache.Contains(seriesMediaItemId.Value))
                {
                    _checkCache.Add(seriesMediaItemId.Value);
                    if (!SeriesMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadSeriesFanArt(seriesMediaItemId.Value, seriesInfo, forceFanart);
                    }
                }
            }
            else if (aspects.ContainsKey(PersonAspect.ASPECT_ID))
            {
                PersonInfo personInfo = new PersonInfo();
                personInfo.FromMetadata(aspects);
                if (personInfo.Occupation == PersonAspect.OCCUPATION_ACTOR || personInfo.Occupation == PersonAspect.OCCUPATION_DIRECTOR ||
                    personInfo.Occupation == PersonAspect.OCCUPATION_WRITER)
                {
                    if (!SeriesMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadSeriesFanArt(mediaItemId, personInfo, !personInfo.IsRefreshed);
                    }
                }
            }
            else if (aspects.ContainsKey(CharacterAspect.ASPECT_ID))
            {
                CharacterInfo characterInfo = new CharacterInfo();
                characterInfo.FromMetadata(aspects);
                if (!SeriesMetadataExtractor.SkipFanArtDownload)
                {
                    OnlineMatcherService.Instance.DownloadSeriesFanArt(mediaItemId, characterInfo, !characterInfo.IsRefreshed);
                }
            }
            else if (aspects.ContainsKey(CompanyAspect.ASPECT_ID))
            {
                CompanyInfo companyInfo = new CompanyInfo();
                companyInfo.FromMetadata(aspects);
                if (companyInfo.Type == CompanyAspect.COMPANY_PRODUCTION || companyInfo.Type == CompanyAspect.COMPANY_TV_NETWORK)
                {
                    if (!SeriesMetadataExtractor.SkipFanArtDownload)
                    {
                        OnlineMatcherService.Instance.DownloadSeriesFanArt(mediaItemId, companyInfo, !companyInfo.IsRefreshed);
                    }
                }
            }
        }