Пример #1
0
        public Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var list = new List<RemoteImageInfo>();

            RemoteImageInfo info = null;

            var musicBrainzId = item is MusicAlbum ?
                item.GetProviderId(MetadataProviders.MusicBrainzAlbum) :
                item.GetProviderId(MetadataProviders.MusicBrainzArtist);

            if (!string.IsNullOrEmpty(musicBrainzId))
            {
                var cachePath = Path.Combine(_config.ApplicationPaths.CachePath, "lastfm", musicBrainzId, "image.txt");

                try
                {
                    var parts = File.ReadAllText(cachePath).Split('|');

                    info = GetInfo(parts.FirstOrDefault(), parts.LastOrDefault());
                }
                catch (DirectoryNotFoundException)
                {
                }
                catch (FileNotFoundException)
                {
                }
            }

            if (info ==  null)
            {
                var musicBrainzReleaseGroupId = item.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);

                if (!string.IsNullOrEmpty(musicBrainzReleaseGroupId))
                {
                    var cachePath = Path.Combine(_config.ApplicationPaths.CachePath, "lastfm", musicBrainzReleaseGroupId, "image.txt");

                    try
                    {
                        var parts = File.ReadAllText(cachePath).Split('|');

                        info = GetInfo(parts.FirstOrDefault(), parts.LastOrDefault());
                    }
                    catch (DirectoryNotFoundException)
                    {
                    }
                    catch (FileNotFoundException)
                    {
                    }
                }
            }

            if (info != null)
            {
                list.Add(info);
            }

            // The only info we have is size
            return Task.FromResult<IEnumerable<RemoteImageInfo>>(list.OrderByDescending(i => i.Width ?? 0));
        }
        public Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var list = new List <RemoteImageInfo>();

            RemoteImageInfo info = null;

            var musicBrainzId = item is MusicAlbum?
                                item.GetProviderId(MetadataProviders.MusicBrainzAlbum) :
                                    item.GetProviderId(MetadataProviders.MusicBrainzArtist);

            if (!string.IsNullOrEmpty(musicBrainzId))
            {
                var cachePath = Path.Combine(_config.ApplicationPaths.CachePath, "lastfm", musicBrainzId, "image.txt");

                try
                {
                    var parts = File.ReadAllText(cachePath).Split('|');

                    info = GetInfo(parts.FirstOrDefault(), parts.LastOrDefault());
                }
                catch (DirectoryNotFoundException)
                {
                }
                catch (FileNotFoundException)
                {
                }
            }

            if (info == null)
            {
                var musicBrainzReleaseGroupId = item.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup);

                if (!string.IsNullOrEmpty(musicBrainzReleaseGroupId))
                {
                    var cachePath = Path.Combine(_config.ApplicationPaths.CachePath, "lastfm", musicBrainzReleaseGroupId, "image.txt");

                    try
                    {
                        var parts = File.ReadAllText(cachePath).Split('|');

                        info = GetInfo(parts.FirstOrDefault(), parts.LastOrDefault());
                    }
                    catch (DirectoryNotFoundException)
                    {
                    }
                    catch (FileNotFoundException)
                    {
                    }
                }
            }

            if (info != null)
            {
                list.Add(info);
            }

            // The only info we have is size
            return(Task.FromResult <IEnumerable <RemoteImageInfo> >(list.OrderByDescending(i => i.Width ?? 0)));
        }
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var adeId = item.GetProviderId("AdultDvdEmpire");

            if (!string.IsNullOrEmpty(adeId))
            {
                using (var stream = await ADEMetadataProvider.Current.GetInfo(adeId, cancellationToken).ConfigureAwait(false))
                {
                    var html = stream.ToStringFromStream();

                    return(GetImagesFromHtml(html));
                }
            }

            return(new List <RemoteImageInfo>());
        }
        public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var adeId = item.GetProviderId("AdultDvdEmpire");

            if (!string.IsNullOrEmpty(adeId))
            {
                using (var stream = await ADEMetadataProvider.Current.GetInfo(adeId, cancellationToken).ConfigureAwait(false))
                {
                    var html = stream.ToStringFromStream();

                    return GetImagesFromHtml(html);
                }

            }

            return new List<RemoteImageInfo>();
        }
Пример #5
0
        public Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var imdbId = item.GetProviderId(MetadataProviders.Imdb);

            var list = new List<RemoteImageInfo>();

            if (!string.IsNullOrWhiteSpace(imdbId))
            {
                list.Add(new RemoteImageInfo
                {
                    ProviderName = Name,
                    Url = string.Format("http://img.omdbapi.com/?i={0}&apikey=82e83907", imdbId)
                });
            }

            return Task.FromResult<IEnumerable<RemoteImageInfo>>(list);
        }
Пример #6
0
        public Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var imdbId = item.GetProviderId(MetadataProviders.Imdb);

            var list = new List <RemoteImageInfo>();

            if (!string.IsNullOrWhiteSpace(imdbId))
            {
                list.Add(new RemoteImageInfo
                {
                    ProviderName = Name,
                    Url          = string.Format("http://img.omdbapi.com/?i={0}&apikey=82e83907", imdbId)
                });
            }

            return(Task.FromResult <IEnumerable <RemoteImageInfo> >(list));
        }
        public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var volumeId = item.GetProviderId(ComicVineVolumeExternalId.KeyName);

            var images = new List<RemoteImageInfo>();

            if (!string.IsNullOrEmpty(volumeId))
            {
                var issueNumber = ComicVineMetadataProvider.GetIssueNumberFromName(item.Name).ToString(_usCulture);

                await ComicVineMetadataProvider.Current.EnsureCacheFile(volumeId, issueNumber, cancellationToken).ConfigureAwait(false);

                var cachePath = ComicVineMetadataProvider.Current.GetCacheFilePath(volumeId, issueNumber);

                try
                {
                    var issueInfo = _jsonSerializer.DeserializeFromFile<SearchResult>(cachePath);

                    if (issueInfo.results.Count > 0)
                    {
                        var result = issueInfo.results[0].image;

                        if (!string.IsNullOrEmpty(result.medium_url))
                        {
                            images.Add(new RemoteImageInfo
                            {
                                Url = result.medium_url,
                                ProviderName = Name
                            });
                        }
                    }
                }
                catch (FileNotFoundException)
                {
                }
                catch (DirectoryNotFoundException)
                {
                }
            }

            return images;
        }
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var volumeId = item.GetProviderId(ComicVineVolumeExternalId.KeyName);

            var images = new List <RemoteImageInfo>();

            if (!string.IsNullOrEmpty(volumeId))
            {
                var issueNumber = ComicVineMetadataProvider.GetIssueNumberFromName(item.Name).ToString(_usCulture);

                await ComicVineMetadataProvider.Current.EnsureCacheFile(volumeId, issueNumber, cancellationToken).ConfigureAwait(false);

                var cachePath = ComicVineMetadataProvider.Current.GetCacheFilePath(volumeId, issueNumber);

                try
                {
                    var issueInfo = _jsonSerializer.DeserializeFromFile <SearchResult>(cachePath);

                    if (issueInfo.results.Count > 0)
                    {
                        var result = issueInfo.results[0].image;

                        if (!string.IsNullOrEmpty(result.medium_url))
                        {
                            images.Add(new RemoteImageInfo
                            {
                                Url          = result.medium_url,
                                ProviderName = Name
                            });
                        }
                    }
                }
                catch (FileNotFoundException)
                {
                }
                catch (DirectoryNotFoundException)
                {
                }
            }

            return(images);
        }
        public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var id = item.GetProviderId(MetadataProviders.MusicBrainzArtist);

            if (!string.IsNullOrWhiteSpace(id))
            {
                await AudioDbArtistProvider.Current.EnsureArtistInfo(id, cancellationToken).ConfigureAwait(false);

                var path = AudioDbArtistProvider.GetArtistInfoPath(_config.ApplicationPaths, id);

                var obj = _json.DeserializeFromFile<AudioDbArtistProvider.RootObject>(path);

                if (obj != null && obj.artists != null && obj.artists.Count > 0)
                {
                    return GetImages(obj.artists[0]);
                }
            }

            return new List<RemoteImageInfo>();
        }
        private async Task <string> GetXmlPath(IHasImages item, CancellationToken cancellationToken)
        {
            var id = item.GetProviderId(GamesDbExternalId.KeyName);

            if (string.IsNullOrEmpty(id))
            {
                return(null);
            }

            if (item is Game)
            {
                await GamesDbGameProvider.Current.EnsureCacheFile(id, cancellationToken).ConfigureAwait(false);

                return(GamesDbGameProvider.Current.GetCacheFilePath(id));
            }

            await GamesDbGameSystemProvider.Current.EnsureCacheFile(id, cancellationToken).ConfigureAwait(false);

            return(GamesDbGameSystemProvider.Current.GetCacheFilePath(id));
        }
Пример #11
0
        private async Task<string> GetXmlPath(IHasImages item, CancellationToken cancellationToken)
        {
            var id = item.GetProviderId(GamesDbExternalId.KeyName);

            if (string.IsNullOrEmpty(id))
            {
                return null;
            }

            if (item is Game)
            {
                await GamesDbGameProvider.Current.EnsureCacheFile(id, cancellationToken).ConfigureAwait(false);

                return GamesDbGameProvider.Current.GetCacheFilePath(id);
            }

            await GamesDbGameSystemProvider.Current.EnsureCacheFile(id, cancellationToken).ConfigureAwait(false);

            return GamesDbGameSystemProvider.Current.GetCacheFilePath(id);
        }
Пример #12
0
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var id = item.GetProviderId(MetadataProviders.MusicBrainzArtist);

            if (!string.IsNullOrWhiteSpace(id))
            {
                await AudioDbArtistProvider.Current.EnsureArtistInfo(id, cancellationToken).ConfigureAwait(false);

                var path = AudioDbArtistProvider.GetArtistInfoPath(_config.ApplicationPaths, id);

                var obj = _json.DeserializeFromFile <AudioDbArtistProvider.RootObject>(path);

                if (obj != null && obj.artists != null && obj.artists.Count > 0)
                {
                    return(GetImages(obj.artists[0]));
                }
            }

            return(new List <RemoteImageInfo>());
        }
        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.base_url + "original";

                    return(GetImages(mainResult, language, tmdbImageUrl));
                }
            }

            return(new List <RemoteImageInfo>());
        }
Пример #14
0
        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>();
        }
Пример #15
0
        public async Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var imdbId = item.GetProviderId(MetadataProviders.Imdb);

            var list = new List<RemoteImageInfo>();

            var provider = new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager);

            if (!string.IsNullOrWhiteSpace(imdbId))
            {
                OmdbProvider.RootObject rootObject = await provider.GetRootObject(imdbId, cancellationToken).ConfigureAwait(false);

                if (!string.IsNullOrEmpty(rootObject.Poster))
                {
                    list.Add(new RemoteImageInfo
                    {
                        ProviderName = Name,
                        Url = string.Format("https://img.omdbapi.com/?i={0}&apikey=82e83907", imdbId)
                    });
                }
            }

            return list;
        }
Пример #16
0
        public async Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var imdbId = item.GetProviderId(MetadataProviders.Imdb);

            var list = new List <RemoteImageInfo>();

            var provider = new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager);

            if (!string.IsNullOrWhiteSpace(imdbId))
            {
                OmdbProvider.RootObject rootObject = await provider.GetRootObject(imdbId, cancellationToken).ConfigureAwait(false);

                if (!string.IsNullOrEmpty(rootObject.Poster))
                {
                    list.Add(new RemoteImageInfo
                    {
                        ProviderName = Name,
                        Url          = string.Format("https://img.omdbapi.com/?i={0}&apikey=82e83907", imdbId)
                    });
                }
            }

            return(list);
        }
        public Task <IEnumerable <RemoteImageInfo> > GetImages(IHasImages item, CancellationToken cancellationToken)
        {
            var seriesId = item.GetProviderId(ProviderNames.AniList);

            return(GetImages(seriesId, cancellationToken));
        }