コード例 #1
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
 /// <summary>
 /// Load all the data for the series.
 /// </summary>
 /// <param name="instance">The API instance.</param>
 /// <param name="languageCode">The language code.</param>
 public void LoadAllData(TvdbAPI instance, string languageCode)
 {
     LoadDetails(instance, languageCode);
     LoadEpisodes(instance, languageCode);
     LoadActors(instance);
     LoadBanners(instance, languageCode);
 }
コード例 #2
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
        private void loadBanners(TvdbAPI instance, Collection <TvdbBanner> banners, TvdbAPI.ImageType imageType, string languageCode)
        {
            try
            {
                TvdbBannersResult bannersResult = instance.GetSeriesBanners(Identity, imageType, null, languageCode);
                if (bannersResult == null || bannersResult.Banners == null)
                {
                    return;
                }

                foreach (TvdbBanner banner in bannersResult.Banners)
                {
                    banners.Add(banner);
                }
            }
            catch (WebException e)
            {
                HttpWebResponse response = e.Response as HttpWebResponse;
                if (response != null && response.StatusCode == HttpStatusCode.NotFound)
                {
                    return;
                }
                throw e;
            }
        }
コード例 #3
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
        /// <summary>
        /// Load the series banners.
        /// </summary>
        /// <param name="instance">An API instance.</param>
        /// <param name="languageCode">The language code.</param>
        public void LoadBanners(TvdbAPI instance, string languageCode = null)
        {
            if (bannersLoaded)
            {
                return;
            }

            Banners     = new Collection <TvdbBanner>();
            BannersTemp = new Collection <TvdbBanner>();

            loadBanners(instance, BannersTemp, TvdbAPI.ImageType.Poster, languageCode);
            {
                if (BannersTemp.Count == 0)
                {
                    loadBanners(instance, BannersTemp, TvdbAPI.ImageType.Poster, null);
                }
                Banners.AddRange(BannersTemp);
                BannersTemp.Clear();
            }
            loadBanners(instance, BannersTemp, TvdbAPI.ImageType.FanArt, languageCode);
            {
                if (BannersTemp.Count == 0)
                {
                    loadBanners(instance, BannersTemp, TvdbAPI.ImageType.FanArt, null);
                }
                Banners.AddRange(BannersTemp);
                BannersTemp.Clear();
            }
            loadBanners(instance, BannersTemp, TvdbAPI.ImageType.Season, languageCode);
            {
                if (BannersTemp.Count == 0)
                {
                    loadBanners(instance, BannersTemp, TvdbAPI.ImageType.Season, null);
                }
                Banners.AddRange(BannersTemp);
                BannersTemp.Clear();
            }
            loadBanners(instance, BannersTemp, TvdbAPI.ImageType.Series, languageCode);
            {
                if (BannersTemp.Count == 0)
                {
                    loadBanners(instance, BannersTemp, TvdbAPI.ImageType.Series, null);
                }
                Banners.AddRange(BannersTemp);
                BannersTemp.Clear();
            }
            loadBanners(instance, BannersTemp, TvdbAPI.ImageType.SeasonWide, languageCode);
            {
                if (BannersTemp.Count == 0)
                {
                    loadBanners(instance, BannersTemp, TvdbAPI.ImageType.SeasonWide, null);
                }
                Banners.AddRange(BannersTemp);
                BannersTemp.Clear();
            }

            bannersLoaded = true;
        }
コード例 #4
0
        /// <summary>
        /// Get the small episode image.
        /// </summary>
        /// <param name="instance">An API instance.</param>
        /// <param name="fileName">The output filename.</param>
        /// <returns>True if the images is downloaded; false otherwise.</returns>
        public bool GetSmallImage(TvdbAPI instance, string fileName)
        {
            if (string.IsNullOrWhiteSpace(Image))
            {
                return(false);
            }

            return(instance.GetImage(TvdbAPI.ImageType.SmallPoster, Image, 0, fileName));
        }
コード例 #5
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
        /// <summary>
        /// Get the banner image.
        /// </summary>
        /// <param name="instance">The API instance.</param>
        /// <param name="fileName">The name of the output file.</param>
        /// <returns>True if the banner was downloaded; false otherwise.</returns>
        public bool GetBannerImage(TvdbAPI instance, string fileName)
        {
            if (string.IsNullOrWhiteSpace(Banner))
            {
                return(false);
            }

            return(instance.GetImage(TvdbAPI.ImageType.Banner, Banner, 0, fileName));
        }
コード例 #6
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
        /// <summary>
        /// Load the extended data for the series for a language code.
        /// </summary>
        /// <param name="instance">An API instance.</param>
        /// <param name="languageCode">The language code.</param>
        public void LoadDetails(TvdbAPI instance, string languageCode)
        {
            if (detailsLoaded && languageCodeLoaded == languageCode)
            {
                return;
            }

            try
            {
                TvdbSeriesInfoResult seriesInfo;

                if (languageCode == null)
                {
                    seriesInfo = instance.GetSeriesDetails(Identity, null);
                }
                else
                {
                    seriesInfo = instance.GetSeriesDetails(Identity, null, languageCode);
                }

                Identity      = seriesInfo.Series.Identity;
                SeriesName    = seriesInfo.Series.SeriesName;
                Aliases       = seriesInfo.Series.Aliases;
                Banner        = seriesInfo.Series.Banner;
                SeriesId      = seriesInfo.Series.SeriesId;
                Status        = seriesInfo.Series.Status;
                FirstAired    = seriesInfo.Series.FirstAired;
                Network       = seriesInfo.Series.Network;
                NetworkId     = seriesInfo.Series.NetworkId;
                Runtime       = seriesInfo.Series.Runtime;
                Genres        = seriesInfo.Series.Genres;
                Overview      = seriesInfo.Series.Overview;
                LastUpdated   = seriesInfo.Series.LastUpdated;
                AirsDayOfWeek = seriesInfo.Series.AirsDayOfWeek;
                AirsTime      = seriesInfo.Series.AirsTime;
                ContentRating = seriesInfo.Series.ContentRating;
                ImdbID        = seriesInfo.Series.ImdbID;
                Language      = languageCode;
                Zap2ItID      = seriesInfo.Series.Zap2ItID;
                AddedDate     = seriesInfo.Series.AddedDate;
                AddedBy       = seriesInfo.Series.AddedBy;
                Rating        = seriesInfo.Series.Rating;
                Votes         = seriesInfo.Series.Votes;

                detailsLoaded      = true;
                languageCodeLoaded = languageCode;
            }
            catch (WebException e)
            {
                HttpWebResponse response = e.Response as HttpWebResponse;
                if (response != null && response.StatusCode == HttpStatusCode.NotFound)
                {
                    return;
                }
                throw e;
            }
        }
コード例 #7
0
        /// <summary>
        /// Get the small image for the actor.
        /// </summary>
        /// <param name="instance">An API instance.</param>
        /// <param name="fileName">The name of the file to hold te image.</param>
        /// <returns>True if the image has been downloaded; false otherwise.</returns>
        public bool GetSmallImage(TvdbAPI instance, string fileName)
        {
            if (Image == null || Image.Length == 0)
            {
                return(false);
            }

            instance.GetImage(TvdbAPI.ImageType.SmallActor, Image, 0, fileName);

            return(true);
        }
コード例 #8
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
        /// <summary>
        /// Get a banner image.
        /// </summary>
        /// <param name="instance">The API instance.</param>
        /// <param name="index">The index of the image.</param>
        /// <param name="fileName">The name of the output file.</param>
        /// <param name="languageCode">The language code.</param>
        /// <returns>True if the banner was downloaded; false otherwise.</returns>
        public bool GetBannerImage(TvdbAPI instance, int index, string fileName, string languageCode = null)
        {
            LoadBanners(instance, languageCode);

            if (Banners == null || Banners.Count == 0 || index == -1 || index >= Banners.Count)
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(Banners[index].FileName))
            {
                return(false);
            }

            return(instance.GetImage(TvdbAPI.ImageType.Banner, Banners[index].FileName, 0, fileName));
        }
コード例 #9
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
        private TvdbBanner findBanner(TvdbAPI instance, TvdbAPI.ImageType imageType, bool thumbnail, string languageCode = null)
        {
            LoadBanners(instance, languageCode);

            if (Banners == null || Banners.Count == 0)
            {
                return(null);
            }

            TvdbBanner selectedBanner = null;

            foreach (TvdbBanner banner in Banners)
            {
                if (banner.IsType(imageType))
                {
                    if ((!thumbnail && banner.FileName != null) || (thumbnail && banner.ThumbNail != null))
                    {
                        if (selectedBanner == null)
                        {
                            selectedBanner = banner;
                        }
                        else
                        {
                            if (selectedBanner.RatingsInfo != null)
                            {
                                if (selectedBanner.RatingsInfo == null)
                                {
                                    selectedBanner = banner;
                                }
                                else
                                {
                                    if (banner.RatingsInfo.Average > selectedBanner.RatingsInfo.Average)
                                    {
                                        selectedBanner = banner;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(selectedBanner);
        }
コード例 #10
0
        /// <summary>
        /// Get the actors for the episode.
        /// </summary>
        /// <param name="instance">An API instance.</param>
        public void LoadActors(TvdbAPI instance)
        {
            if (actorsLoaded)
            {
                return;
            }

            try
            {
                Actors       = instance.GetEpisodeActors(Identity, null).Actors;
                actorsLoaded = true;
            }
            catch (WebException e)
            {
                HttpWebResponse response = e.Response as HttpWebResponse;
                if (response != null && response.StatusCode == HttpStatusCode.NotFound)
                {
                    return;
                }
                throw e;
            }
        }
コード例 #11
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
        /// <summary>
        /// Get the small fan art image.
        /// </summary>
        /// <param name="instance">An API instance.</param>
        /// <param name="fileName">The output filename.</param>
        /// <returns>True if the image was downloaded; false otherwise.</returns>
        public bool GetSmallFanArtImage(TvdbAPI instance, string fileName)
        {
            TvdbBanner selectedBanner = findBanner(instance, TvdbAPI.ImageType.FanArt, true);

            if (selectedBanner == null)
            {
                return(false);
            }

            try
            {
                return(instance.GetImage(TvdbAPI.ImageType.FanArt, selectedBanner.ThumbNail, 0, fileName));
            }
            catch (WebException e)
            {
                HttpWebResponse response = e.Response as HttpWebResponse;
                if (response != null && response.StatusCode == HttpStatusCode.NotFound)
                {
                    return(false);
                }
                throw e;
            }
        }
コード例 #12
0
ファイル: TvdbApi.cs プロジェクト: lilithfr/mediacompanion
        /// <summary>
        ///  Get all episodes for a series for a language code.
        /// </summary>
        /// <param name="identity">The identity of the series.</param>
        /// <param name="languageCode">The language code.</param>
        /// <param name="completionHandler">The async completion handler. May be null.</param>
        /// <param name="instance"></param>
        /// <param name="alldetails">If True, populate all episode data</param>
        /// <returns>The results object.</returns>
        public Collection <TvdbEpisode> GetSeriesAllEpisodes(int identity, string languageCode, TvdbAsyncHandler completionHandler, TvdbAPI instance, bool alldetails = false)
        {
            Collection <TvdbEpisode> allepisodes = new Collection <TvdbEpisode>();
            TvdbSeriesEpisodesResult episodesinfo;

            if (languageCode == null)
            {
                episodesinfo = GetSeriesEpisodes(identity, null);
            }
            else
            {
                episodesinfo = GetSeriesEpisodes(identity, null, languageCode);
            }

            foreach (TvdbEpisode episode in episodesinfo.Episodes)
            {
                if (alldetails == true)
                {
                    episode.LoadDetails(instance, languageCode);
                }
                addEpisode(episode, allepisodes);
            }

            while (episodesinfo.PageLinks.NextPageNumber != -1)
            {
                if (languageCode == null)
                {
                    episodesinfo = GetSeriesEpisodes(identity, episodesinfo.PageLinks.NextPageNumber, null);
                }
                else
                {
                    episodesinfo = GetSeriesEpisodes(identity, episodesinfo.PageLinks.NextPageNumber, null, languageCode);
                }

                foreach (TvdbEpisode episode in episodesinfo.Episodes)
                {
                    if (alldetails == true)
                    {
                        episode.LoadDetails(instance, languageCode);
                    }
                    addEpisode(episode, allepisodes);
                }
            }
            return(allepisodes);
        }
コード例 #13
0
        /// <summary>
        /// Load the extended data for an episode.
        /// </summary>
        /// <param name="instance">The API instance.</param>
        /// <param name="languageCode">The language code. May be null.</param>
        public void LoadDetails(TvdbAPI instance, string languageCode)
        {
            if (detailsLoaded && languageCodeLoaded == languageCode)
            {
                return;
            }

            try
            {
                TvdbEpisodeInfoResult episodeInfo;

                if (languageCode == null)
                {
                    episodeInfo = instance.GetEpisodeDetails(Identity, null);
                }
                else
                {
                    episodeInfo = instance.GetEpisodeDetails(Identity, null, languageCode);
                }

                Identity          = episodeInfo.Episode.Identity;
                SeasonNumber      = episodeInfo.Episode.SeasonNumber;
                EpisodeNumber     = episodeInfo.Episode.EpisodeNumber;
                EpisodeName       = episodeInfo.Episode.EpisodeName;
                FirstAired        = episodeInfo.Episode.FirstAired;
                GuestStars        = episodeInfo.Episode.GuestStars;
                Directors         = episodeInfo.Episode.Directors;
                Writers           = episodeInfo.Episode.Writers;
                Overview          = episodeInfo.Episode.Overview;
                Language          = episodeInfo.Episode.Language;
                ProductionCode    = episodeInfo.Episode.ProductionCode;
                ShowUrl           = episodeInfo.Episode.ShowUrl;
                LastUpdated       = episodeInfo.Episode.LastUpdated;
                DVDDiscID         = episodeInfo.Episode.DVDDiscID;
                DVDSeason         = episodeInfo.Episode.DVDSeason;
                DVDEpisode        = episodeInfo.Episode.DVDEpisode;
                DVDChapter        = episodeInfo.Episode.DVDChapter;
                AbsoluteNumber    = episodeInfo.Episode.AbsoluteNumber;
                Image             = episodeInfo.Episode.Image;
                SeriesId          = episodeInfo.Episode.SeriesId;
                LastUpdatedBy     = episodeInfo.Episode.LastUpdatedBy;
                AirsAfterSeason   = episodeInfo.Episode.AirsAfterSeason;
                AirsBeforeSeason  = episodeInfo.Episode.AirsBeforeSeason;
                AirsBeforeEpisode = episodeInfo.Episode.AirsBeforeEpisode;
                ThumbAuthor       = episodeInfo.Episode.ThumbAuthor;
                ThumbAdded        = episodeInfo.Episode.ThumbAdded;
                ThumbWidth        = episodeInfo.Episode.ThumbWidth;
                ThumbHeight       = episodeInfo.Episode.ThumbHeight;
                ImdbId            = episodeInfo.Episode.ImdbId;
                Rating            = episodeInfo.Episode.Rating;

                detailsLoaded      = true;
                languageCodeLoaded = languageCode;
            }
            catch (WebException e)
            {
                HttpWebResponse response = e.Response as HttpWebResponse;
                if (response != null && response.StatusCode == HttpStatusCode.NotFound)
                {
                    return;
                }
                throw e;
            }
        }
コード例 #14
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
 /// <summary>
 /// Search for a series in an specific language.
 /// </summary>
 /// <param name="instance">An API instance.</param>
 /// <param name="title">Part or all of the title.</param>
 /// <param name="languageCode">The language code.</param>
 /// <returns>The results object.</returns>
 public static TvdbSeriesSearchResult Search(TvdbAPI instance, string title, string languageCode)
 {
     return(instance.GetSeries(title, null, languageCode));
 }
コード例 #15
0
ファイル: TvdbSeries.cs プロジェクト: lilithfr/mediacompanion
        /// <summary>
        /// Load the episodes in the series.
        /// </summary>
        /// <param name="instance">The API instance.</param>
        /// <param name="languageCode">The language code.</param>
        /// <param name="alldetails">True load complete episode details</param>
        public void LoadEpisodes(TvdbAPI instance, string languageCode, bool alldetails = false)
        {
            if (episodesLoaded && languageCodeLoaded == languageCode)
            {
                return;
            }

            Episodes = new Collection <TvdbEpisode>();

            try
            {
                TvdbSeriesEpisodesResult episodesInfo;

                if (languageCode == null)
                {
                    episodesInfo = instance.GetSeriesEpisodes(Identity, null);
                }
                else
                {
                    episodesInfo = instance.GetSeriesEpisodes(Identity, null, languageCode);
                }

                foreach (TvdbEpisode episode in episodesInfo.Episodes)
                {
                    if (alldetails == true)
                    {
                        episode.LoadDetails(instance, languageCode);
                    }
                    addEpisode(episode, Episodes);
                }

                while (episodesInfo.PageLinks.NextPageNumber != -1)
                {
                    if (languageCode == null)
                    {
                        episodesInfo = instance.GetSeriesEpisodes(Identity, episodesInfo.PageLinks.NextPageNumber, null);
                    }
                    else
                    {
                        episodesInfo = instance.GetSeriesEpisodes(Identity, episodesInfo.PageLinks.NextPageNumber, null, languageCode);
                    }

                    foreach (TvdbEpisode episode in episodesInfo.Episodes)
                    {
                        if (alldetails == true)
                        {
                            episode.LoadDetails(instance, languageCode);
                        }
                        addEpisode(episode, Episodes);
                    }
                }

                episodesLoaded     = true;
                languageCodeLoaded = languageCode;
            }
            catch (WebException e)
            {
                HttpWebResponse response = e.Response as HttpWebResponse;
                if (response != null && response.StatusCode == HttpStatusCode.NotFound)
                {
                    return;
                }
                throw e;
            }
        }