private bool DownloadImage(string serverPath, string title, int season, int episode) { string apiKey = ConfigurationManager.AppSettings["tvdb.API.key"]; if (string.IsNullOrWhiteSpace(apiKey)) { return(false); } var handler = new TvdbHandler(apiKey); var downloader = new TvdbDownloader(apiKey); var searchResult = handler.SearchSeries(title); if (searchResult != null && searchResult.Count > 0) { var result = searchResult.First(); int sId = result.Id; var banner = GetLoadedBanner(downloader, sId, season, episode, result.Banner); if (banner == null) { return(false); } banner.BannerImage.Save(serverPath); return(true); } return(false); }
private TvdbBanner GetLoadedBanner(TvdbDownloader downloader, int sId, int season, int episode, TvdbBanner fallback) { TvdbBanner result = GetEpisodeBanner(downloader, sId, season, episode); if (result != null && TryLoadBanner(result)) { return(result); } var bannerHits = downloader.DownloadBanners(sId); result = GetSeasonBanner(bannerHits, season); if (result != null && TryLoadBanner(result)) { return(result); } result = GetSeriesBanner(bannerHits); if (result != null && TryLoadBanner(result)) { return(result); } if (fallback != null && TryLoadBanner(fallback)) { return(fallback); } return(null); }
public Tvdb(ICacheProvider _cacheProvider, String _apiKey) { m_apiKey = _apiKey; //store api key m_cacheProvider = _cacheProvider; //store given cache provider m_loadedData = new TvdbData(); m_loadedData.Mirrors = new List <TvdbMirror>(); m_loadedData.SeriesList = new List <TvdbSeries>(); m_loadedData.LanguageList = new List <TvdbLanguage>(); TvdbLinks.ActiveMirror = new TvdbMirror(0, new Uri(TvdbLinks.BASE_SERVER), 7); m_downloader = new TvdbDownloader(m_apiKey); }
private TvdbBanner GetEpisodeBanner(TvdbDownloader downloader, int seriesId, int season, int episode) { try { var tvEpisode = downloader.DownloadEpisode(seriesId, season, episode, TvdbEpisode.EpisodeOrdering.DefaultOrder, TvdbLanguage.DefaultLanguage); return(tvEpisode.Banner); } catch (Exception ex) { return(null); } }
private void cmdTestGetSeriesByExternalId_Click(object sender, EventArgs e) { TvdbDownloader downloader = new TvdbDownloader(File.ReadAllText("api_key.txt")); TvdbSearchResult s = downloader.DownloadSeriesSearchByExternalId(ExternalId.ImdbId, txtExternalId.Text); }