Example #1
0
        public override string GetVideoUrl(VideoInfo video)
        {
            string videoUrl = string.Empty;

            Video clip = video.Other as Video;

            if (clip == null)
            {
                clip        = apiSession.Get <Video>(video.VideoUrl);
                video.Other = clip;
            }
            else if (!string.IsNullOrEmpty(video.VideoUrl) && !video.VideoUrl.StartsWith("file://"))             // todo : test with favorites!
            {
                clip = apiSession.Get <Video>(video.VideoUrl);
            }

            NodeResult result = clip.Update();

            if (clip.State != NodeState.Complete)
            {
                return(videoUrl);
            }

            video.Length = clip.Duration.ToString();

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

            foreach (var file in clip.Files)
            {
                var uri = new OnlineVideos.MPUrlSourceFilter.HttpUrl(file.Value);
                uri.UserAgent = QuickTimeUserAgent;
                files[file.Key.ToTitleString()] = uri.ToString();
            }

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

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

            return(videoUrl);
        }
Example #2
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);
        }