Пример #1
0
        public override List <VideoReference> GetVideos()
        {
            List <VideoReference> list = IMDbAPI.GetVideos(this.session, this.ID);

            if (this.Trailer != null)
            {
                // replace the reference with a details version
                int i = list.FindIndex(x => x.ID == this.Trailer.ID);
                if (i > -1)
                {
                    list.RemoveAt(i);
                }

                // put the main trailer on top
                list.Insert(0, this.Trailer);
            }
            else if (this.trailer != null)
            {
                int i = list.FindIndex(x => x.ID == this.trailer);
                if (i > -1)
                {
                    // move the video on top and rename the title
                    VideoReference video = list[i];
                    video.Title = "Main Trailer";
                    list.RemoveAt(i);
                    list.Insert(0, video);
                }
            }

            return(list);
        }
Пример #2
0
        internal virtual void FillFrom(IMDbTitleMobile dto)
        {
            this.ID = dto.URL.Replace("/title/", "").Replace("/", "").Trim();

            IMDbAPI.ParseDisplayStringToTitleBase(this, HttpUtility.HtmlDecode(dto.Title) + " " + dto.Extra);
            this.Image = IMDbAPI.ParseImageUrl(dto.Image.Url);
        }
Пример #3
0
 /// <summary>
 /// Initialize
 /// </summary>
 private void Init()
 {
     // create an IMDb session
     if (apiSession == null)
     {
         apiSession             = IMDbAPI.GetSession();
         apiSession.MakeRequest = doWebRequest;
     }
 }
Пример #4
0
        public VideoDetails GetDetails()
        {
            VideoDetails details = IMDbAPI.GetVideo(this.session, this.ID);

            if (details.Image == null)
            {
                details.Image = this.Image;
            }

            return(details);
        }
Пример #5
0
        public override string GetVideoUrl(VideoInfo video)
        {
            string       videoUrl = string.Empty;
            VideoDetails clip     = video.Other as VideoDetails;

            if (clip == null)
            {
                clip        = IMDbAPI.GetVideo(apiSession, video.VideoUrl);
                video.Other = clip;
            }

            Dictionary <string, string> files = new Dictionary <string, string>();

            foreach (KeyValuePair <VideoFormat, string> file in clip.Files)
            {
                // todo: how can I resolve the actual video url on playback instead of here?
                files[file.Key.ToString()] = IMDbAPI.GetVideoFile(apiSession, file.Value);
            }

            // no files
            if (files.Count == 0)
            {
                return(videoUrl);
            }

            if (AlwaysPlaybackPreferredQuality)
            {
                if (files.Count > 0 && !files.TryGetValue(PreferredVideoQuality.ToString(), out videoUrl))
                {
                    video.PlaybackOptions = files;
                    videoUrl = files.Values.ToArray()[files.Count - 1];
                }
            }
            else
            {
                video.PlaybackOptions = files;
                if (files.Count > 0 && !files.TryGetValue(PreferredVideoQuality.ToString(), out videoUrl))
                {
                    videoUrl = files.Values.ToArray()[files.Count - 1];
                }
            }

            return(videoUrl);
        }
Пример #6
0
        public List <DetailVideoInfo> GetVideoChoices(VideoInfo video)
        {
            List <DetailVideoInfo> clips = new List <DetailVideoInfo>();

            TitleDetails title = IMDbAPI.GetTitle(apiSession, video.VideoUrl as string);

            video.Other       = title;
            video.Title       = title.Title;
            video.Description = title.Plot;
            if (!string.IsNullOrEmpty(title.Image))
            {
                video.Thumb = getResizedImage(title.Image);
            }

            List <VideoReference> videos = title.GetVideos();

            if (videos != null)
            {
                foreach (VideoReference clip in videos)
                {
                    if (clip.Description == null)
                    {
                        clip.Description = video.Description;
                    }

                    DetailVideoInfo vid = new DetailVideoInfo();
                    vid.Other       = clip;
                    vid.Title       = title.Title + " - " + clip.Title;
                    vid.Title2      = clip.Title;
                    vid.Description = clip.Description;

                    vid.Thumb    = clip.Image;
                    vid.VideoUrl = clip.ID;
                    vid.Length   = clip.Duration.ToString();
                    clips.Add(vid);
                }
            }

            return(clips);
        }
Пример #7
0
        public override List <SearchResultItem> Search(string query, string category = null)
        {
            var videos = new List <SearchResultItem>();

            // check if we have an IMDb in the search query
            string id = IMDbAPI.ParseTitleConst(query);

            if (id != null)
            {
                // we found an IMDb id so we do a details request
                TitleDetails title = IMDbAPI.GetTitle(apiSession, id);
                VideoInfo    video = new VideoInfo();
                video.Other       = title;
                video.Title       = title.Title;
                video.Description = title.Plot;
                video.Thumb       = getResizedImage(title.Image);
                video.VideoUrl    = title.ID;

                videos.Add(video);

                // return the result
                return(videos);
            }

            SearchResults results = IMDbAPI.Search(apiSession, query);

            foreach (ResultType key in results.Titles.Keys)
            {
                var titles = results.Titles[key];
                foreach (TitleReference title in titles)
                {
                    VideoInfo video = createVideoInfoFromTitleReference(title);
                    videos.Add(video);
                }
            }

            return(videos);
        }
Пример #8
0
        public override List <VideoInfo> GetVideos(Category category)
        {
            List <VideoInfo> videos = new List <VideoInfo>();

            string catid = category.Other as string;
            List <TitleReference> titles = null;

            switch (catid)
            {
            case "1":
                titles = IMDbAPI.GetComingSoon(apiSession);
                break;

            case "2":
                titles = IMDbAPI.GetTrailersTopHD(apiSession);
                break;

            case "3":
                titles = IMDbAPI.GetTrailersRecent(apiSession, 0);
                break;

            case "4":
                titles = IMDbAPI.GetTrailersPopular(apiSession, 0);
                break;

            case "5":
                titles = IMDbAPI.GetPopularTV(apiSession);
                break;

            case "101":
                titles = IMDbAPI.GetBoxOffice(apiSession);
                break;

            case "102":
                titles = IMDbAPI.GetMovieMeter(apiSession);
                break;

            case "103":
                titles = IMDbAPI.GetTop250(apiSession);
                break;

            case "104":
                titles = IMDbAPI.GetBottom100(apiSession);
                break;

            case "105":
                titles = IMDbAPI.GetBestPictureWinners(apiSession);
                break;

            default:
                if (catid.StartsWith("200"))
                {
                    titles = IMDbAPI.GetFullLengthMovies(apiSession, catid.Substring(3));
                }
                break;
            }

            if (titles != null)
            {
                foreach (TitleReference title in titles)
                {
                    VideoInfo video = createVideoInfoFromTitleReference(title);
                    videos.Add(video);
                }
            }

            return(videos);
        }
Пример #9
0
 public virtual TitleDetails GetDetails()
 {
     return(IMDbAPI.GetTitle(this.session, this.ID));
 }
Пример #10
0
 public virtual List <VideoReference> GetVideos()
 {
     return(IMDbAPI.GetVideos(this.session, this.ID));
 }