/// <summary>
        /// Returns the file extension and file name
        /// </summary>
        /// <param name="destination">The destination file name</param>
        /// <param name="type"></param>
        /// <param name="quality"></param>
        /// <param name="Audioquality"></param>
        /// <returns></returns>
        public static string GetDownloadingFileName(string destination, VideoType type, VideoQuality quality, bool isMP3Conversion, bool isM4A)
        {
            if (string.IsNullOrWhiteSpace(destination) || type == VideoType.NULL)
            {
                return(null);
            }

            destination = destination.Replace(" - YouTube", "");
            char[] escape = @"\/:*?""<>|.'".ToCharArray();
            for (int i = 0; i < escape.Length; i++)
            {
                destination = destination.Replace(escape[i], (char)32);
            }

            string FileExtension = isMP3Conversion ? (isM4A ? ".m4a" : ".mp3") : ("." + type.GetFileExtentionByType());

            if (FileExtension == null || FileExtension == string.Empty)
            {
                return(null);
            }

            destination  = destination.Substring(0, Math.Min(destination.Length, 50));
            destination += "_" + quality.ToString() + FileExtension;

            return(destination);
        }
예제 #2
0
        public override String GetVideoUrl(VideoInfo video)
        {
            video.PlaybackOptions = new Dictionary <string, string>();
            var json = GetWebData <JObject>(video.VideoUrl);

            foreach (var quality in json["videoJsonPlayer"]["VSR"])
            {
                string qualityName = string.Format("{0} | {1} | {2}",
                                                   quality.First.Value <string>("versionShortLibelle").PadRight(3),
                                                   quality.First.Value <string>("mediaType").PadRight(4),
                                                   quality.First.Value <string>("quality"));

                if (quality.First.Value <string>("mediaType") == "rtmp")
                {
                    if (!video.PlaybackOptions.ContainsKey(qualityName))
                    {
                        string host        = quality.First.Value <string>("streamer");
                        string file        = quality.First.Value <string>("url");
                        string playbackUrl = new MPUrlSourceFilter.RtmpUrl(host)
                        {
                            TcUrl = host, PlayPath = "mp4:" + file
                        }.ToString();
                        video.PlaybackOptions.Add(qualityName, playbackUrl);
                    }
                }
                else if (quality.First.Value <string>("mediaType") == "mp4")
                {
                    string file = quality.First.Value <string>("url");
                    video.PlaybackOptions.Add(qualityName, file);
                }
            }
            return(video.PlaybackOptions.FirstOrDefault(q => q.Key.Contains(videoQuality.ToString())).Value);
        }
        /// <summary>
        /// Updates the <see cref="BaseUbiIniGameConfigViewModel{Handler}.ConfigData"/>
        /// </summary>
        /// <returns>The task</returns>
        protected override Task UpdateConfigAsync()
        {
            ConfigData.GLI_Mode = new RayGLI_Mode()
            {
                ColorMode  = IsTextures32Bit ? 32 : 16,
                IsWindowed = !FullscreenMode,
                ResX       = ResX,
                ResY       = ResY
            }.ToString();

            ConfigData.FormattedTriLinear               = TriLinear;
            ConfigData.FormattedTnL                     = TnL;
            ConfigData.FormattedTexturesCompressed      = CompressedTextures;
            ConfigData.Video_WantedQuality              = VideoQuality.ToString();
            ConfigData.FormattedVideo_AutoAdjustQuality = AutoVideoQuality;
            ConfigData.Video_BPP = IsVideo32Bpp ? "32" : "16";
            ConfigData.Language  = CurrentLanguage.ToString();
            ConfigData.FormattedDynamicShadows = DynamicShadows;
            ConfigData.FormattedStaticShadows  = StaticShadows;
            ConfigData.Camera_VerticalAxis     = VerticalAxis.ToString();
            ConfigData.Camera_HorizontalAxis   = HorizontalAxis.ToString();
            ConfigData.TexturesFile            = $"Tex{(IsTextures32Bit ? 32 : 16)}.cnt";

            return(Task.CompletedTask);
        }
예제 #4
0
        /// <summary>
        ///     Used to filter by a given quality.
        /// </summary>
        /// <param name="quality">The quality.</param>
        /// <returns></returns>
        public ListMoviesRequest Quality(VideoQuality quality)
        {
            var suffix = "p";

            if (quality == VideoQuality.Q3D)
            {
                suffix = "";
            }
            return(this.Query("quality", quality.ToString().Replace("Q", "") + suffix));
        }
예제 #5
0
        /// <summary>
        /// Returns a String.Object that represents the current VideoQuality value
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static string ToTitleString(this VideoQuality self)
        {
            switch (self)
            {
            case VideoQuality.FullHD:
                return("HD 1080p");

            case VideoQuality.HD720:
                return("HD 720p");

            case VideoQuality.HD480:
                return("HD 480p");

            default:
                return(self.ToString());
            }
        }
예제 #6
0
        public static string GetDescription(this VideoQuality value)
        {
            Type   type = value.GetType();
            string Name = Enum.GetName(type, value);

            if (Name != null)
            {
                System.Reflection.FieldInfo field = type.GetField(Name);
                if (field != null)
                {
                    if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attr)
                    {
                        return(attr.Description);
                    }
                }
            }
            return(value.ToString());
        }
예제 #7
0
    protected override Task UpdateConfigAsync()
    {
        ConfigData.GLI_Mode = new RayGLI_Mode()
        {
            ColorMode  = IsTextures32Bit ? 32 : 16,
            IsWindowed = !FullscreenMode,
            ResX       = GraphicsMode.Width,
            ResY       = GraphicsMode.Height,
        }.ToString();

        ConfigData.FormattedTriLinear               = TriLinear;
        ConfigData.FormattedTnL                     = TnL;
        ConfigData.FormattedTexturesCompressed      = CompressedTextures;
        ConfigData.Video_WantedQuality              = VideoQuality.ToString();
        ConfigData.FormattedVideo_AutoAdjustQuality = AutoVideoQuality;
        ConfigData.Video_BPP    = IsVideo32Bpp ? "32" : "16";
        ConfigData.Language     = CurrentLanguage.ToString();
        ConfigData.TexturesFile = $"Tex{(IsTextures32Bit ? 32 : 16)}.cnt";

        return(Task.CompletedTask);
    }
예제 #8
0
        public static string ToTwitchQuality(this VideoQuality videoQuality)
        {
            switch (videoQuality)
            {
            case VideoQuality.Source:
                return("chunked");

            case VideoQuality.High:
                return("high");

            case VideoQuality.Medium:
                return("medium");

            case VideoQuality.Low:
                return("low");

            case VideoQuality.Mobile:
                return("mobile");

            default:
                throw new ApplicationException("Cannot convert enum value '" + videoQuality.ToString() + "' to Twitch quality string!");
            }
        }
 /// <summary>
 /// The video encoding quality (low, medium, high, photo - defaults to medium).
 /// Only works for real devices.
 /// </summary>
 /// <param name="videoQuality"></param>
 /// <returns></returns>
 public IOSStartScreenRecordingOptions WithVideoQuality(VideoQuality videoQuality)
 {
     Parameters["videoQuality"] = videoQuality.ToString().ToLower();
     return(this);
 }
        public async Task DownloadHightQualityAsync(VideoQuality quality, string saveFile)
        {
            System.Windows.MessageBox.Show("Укажите путь к файлу FFMPEG.EXE");

            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter = "EXE file(*.exe)|*.exe";

            openFile.ShowDialog();

            textBoxStatus.Text = "Начинаю загрузку видео! Это может быть долго, ожидайте!";

            var streamInfo = streamManifest.GetVideoOnly().Where(s => s.VideoQuality == quality).WithHighestVideoQuality();

            var streamInfo1 = streamManifest.GetAudioOnly().WithHighestBitrate();

            if (streamInfo != null)
            {
                await youtube.Videos.Streams.DownloadAsync(streamInfo, $"{saveFile}.mp4");
            }

            if (streamInfo != null)
            {
                await youtube.Videos.Streams.DownloadAsync(streamInfo1, $"{saveFile}.mp3");
            }

            string args = $"/c {openFile.FileName} -i \"{saveFile}.mp4\" -i \"{saveFile}.mp3\" -shortest {saveFile}_{quality.ToString()}.mp4";

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.CreateNoWindow   = false;
            startInfo.FileName         = "cmd.exe";
            startInfo.WorkingDirectory = saveFile + ".mp4";
            startInfo.Arguments        = args;

            using (Process exeProcess = Process.Start(startInfo))
            {
                exeProcess.WaitForExit();
            }

            File.Delete(saveFile + ".mp4");
            File.Delete(saveFile + ".mp3");

            textBoxStatus.Text = $"Видео успешно скачано, путь к файлу - > {saveFile}_{quality.ToString()}.mp4";
        }
예제 #11
0
 public IosRecordScreenOptions(VideoType videoType, VideoQuality videoQuality)
 {
     VideoQuality = videoQuality.ToString().ToLower();
     VideoType    = videoType.ToString().ToLower();
 }
 public void SetNewQualityPreference(VideoQuality preferredQuality)
 {
     _settingsManager.SaveSetting(VideoQualitySettingName, preferredQuality.ToString());
     _currentQualityPreference = preferredQuality;
 }
예제 #13
0
 /// <summary>
 /// Gets label for given video quality, as displayed on YouTube.
 /// </summary>
 public static string GetVideoQualityLabel(this VideoQuality videoQuality)
 {
     // Convert to string, strip non-digits and add "p"
     return(videoQuality.ToString().StripNonDigit() + "p");
 }
예제 #14
0
        public override String GetVideoUrl(VideoInfo video)
        {
            video.PlaybackOptions = new Dictionary <string, string>();

            var doc   = GetWebData <HtmlDocument>(video.VideoUrl);
            var vpDiv = doc.DocumentNode.Descendants("div").FirstOrDefault(s => !string.IsNullOrEmpty(s.GetAttributeValue("arte_vp_url_oembed", "")));

            if (vpDiv == null)
            {
                throw new OnlineVideosException("Video nicht verfügbar!");
            }

            var          json   = GetWebData <JObject>(vpDiv.GetAttributeValue("arte_vp_url_oembed", ""));
            HtmlDocument iframe = new HtmlAgilityPack.HtmlDocument();

            iframe.LoadHtml(json["html"].ToString());
            json = GetWebData <JObject>(HttpUtility.ParseQueryString(new Uri(iframe.DocumentNode.FirstChild.GetAttributeValue("src", "")).Query)["json_url"]);

            foreach (var quality in json["videoJsonPlayer"]["VSR"])
            {
                string qualityName = string.Format("{0} | {1} | {2} ({3}x{4} - {5} kbps)",
                                                   (quality.First.Value <string>("versionShortLibelle") ?? "").PadRight(3),
                                                   quality.First.Value <string>("mediaType").PadRight(4),
                                                   quality.First.Value <string>("quality"),
                                                   quality.First.Value <string>("width"),
                                                   quality.First.Value <string>("height"),
                                                   quality.First.Value <string>("bitrate"));

                if (quality.First.Value <string>("mediaType") == "rtmp")
                {
                    if (!video.PlaybackOptions.ContainsKey(qualityName))
                    {
                        string host        = quality.First.Value <string>("streamer");
                        string file        = quality.First.Value <string>("url");
                        string playbackUrl = new MPUrlSourceFilter.RtmpUrl(host)
                        {
                            TcUrl = host, PlayPath = "mp4:" + file
                        }.ToString();
                        video.PlaybackOptions.Add(qualityName, playbackUrl);
                    }
                }
                else if (quality.First.Value <string>("mediaType") == "mp4")
                {
                    string file = quality.First.Value <string>("url");
                    video.PlaybackOptions.Add(qualityName, file);
                }

                /*else if (quality.First.Value<string>("mediaType") == "hls")
                 * {
                 *      string file = quality.First.Value<string>("url");
                 *      video.PlaybackOptions.Add(qualityName, file);
                 *      // todo -> resolve m3u8
                 * }*/
            }

            var bestOption = video.PlaybackOptions.FirstOrDefault(q => q.Key.Contains(videoQuality.ToString())).Value;

            if (string.IsNullOrEmpty(bestOption))
            {
                return(video.PlaybackOptions.FirstOrDefault().Value);
            }
            return(bestOption);
        }
 public static string VideoQualityToLabel(VideoQuality quality)
 {
     // Convert to string, strip non-digits and add "p"
     return(quality.ToString().StripNonDigit() + 'p');
 }
        public override String GetVideoUrl(VideoInfo video)
        {
            var cache    = new List <string>();
            var baseDoc  = GetWebData <HtmlDocument>(video.VideoUrl);
            var mediaDiv = baseDoc.DocumentNode.Descendants("div").FirstOrDefault(div => div.GetAttributeValue("data-ctrl-player", "") != "");

            if (mediaDiv != null)
            {
                var configUrl            = new Uri(new Uri(video.VideoUrl), JObject.Parse(HttpUtility.HtmlDecode(mediaDiv.GetAttributeValue("data-ctrl-player", ""))).Value <string>("mcUrl")).AbsoluteUri;
                var mediaString          = GetWebData <string>(configUrl);
                var mediaJson            = JsonConvert.DeserializeObject <JsonResponse>(mediaString);
                var playbackOptionsByUrl = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                int qualityNumber;
                foreach (var media in mediaJson.MediaArray.SelectMany(m => m.MediaStreamArray).Select(streamArray => new
                {
                    Quality = int.TryParse(streamArray.Quality, out qualityNumber) ? ((VideoQuality)qualityNumber).ToString() : "HD",
                    Url = streamArray.Stream is JArray ? ((JArray)streamArray.Stream).Values <string>().OrderByDescending(item => item, StringComparer.OrdinalIgnoreCase).First() : streamArray.Stream as string,
                    Server = streamArray.Server
                }).Distinct())
                {
                    string url = media.Url;
                    cache.Add(url);
                    if (url.EndsWith(".smil"))
                    {
                        url = GetStreamUrlFromSmil(url);
                    }

                    if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
                    {
                        if (Uri.IsWellFormedUriString(url, UriKind.Relative))
                        {
                            var absoluteUri = new Uri(new Uri(video.VideoUrl), url);
                            url = absoluteUri.ToString();
                        }

                        if (url.Contains("master.m3u8"))
                        {
                            var m3u8Data = GetWebData(url);
                            foreach (Match match in Regex.Matches(m3u8Data, m3u8Regex2))
                            {
                                playbackOptionsByUrl[match.Groups["url"].Value] =
                                    string.Format("HLS - {0} - {1} kbps", match.Groups["resolution"].Value, int.Parse(match.Groups["bitrate"].Value) / 1000);
                                cache.Add(match.Groups["url"].Value);
                            }

                            foreach (Match match in Regex.Matches(m3u8Data, m3u8Regex1))
                            {
                                playbackOptionsByUrl[match.Groups["url"].Value] =
                                    string.Format("HLS - {0} - {1} kbps", match.Groups["codecs"].Value, int.Parse(match.Groups["bitrate"].Value) / 1000);
                                cache.Add(match.Groups["url"].Value);
                            }
                        }
                        else if (url.EndsWith("f4m"))
                        {
                            url += "?g=" + Helpers.StringUtils.GetRandomLetters(12) + "&hdcore=3.8.0";
                            playbackOptionsByUrl[url] = media.Quality;
                        }
                        else
                        {
                            playbackOptionsByUrl[url] = media.Quality;
                        }
                    }
                    else if (mediaJson.IsLive)
                    {
                        url = string.Empty;
                        if (string.IsNullOrEmpty(media.Url))
                        {
                            string guessedStream = media.Server.Substring(media.Server.LastIndexOf('/') + 1);
                            url = new MPUrlSourceFilter.RtmpUrl(media.Server)
                            {
                                Live = true, LiveStream = true, Subscribe = guessedStream, PageUrl = video.VideoUrl
                            }.ToString();
                        }
                        else if (media.Url.Contains('?'))
                        {
                            var tcUrl    = media.Server.TrimEnd('/') + media.Url.Substring(media.Url.IndexOf('?'));
                            var app      = new Uri(media.Server).AbsolutePath.Trim('/') + media.Url.Substring(media.Url.IndexOf('?'));
                            var playPath = media.Url;
                            url = new MPUrlSourceFilter.RtmpUrl(tcUrl)
                            {
                                App = app, PlayPath = playPath, Live = true, PageUrl = video.VideoUrl, Subscribe = playPath
                            }.ToString();
                        }
                        else
                        {
                            url = new MPUrlSourceFilter.RtmpUrl(media.Server + "/" + media.Url)
                            {
                                Live = true, LiveStream = true, Subscribe = media.Url, PageUrl = video.VideoUrl
                            }.ToString();
                        }

                        playbackOptionsByUrl[url] = media.Quality;
                    }
                }

                video.PlaybackOptions = new Dictionary <string, string>();
                foreach (var lookup in playbackOptionsByUrl.ToLookup(kvp => kvp.Value))
                {
                    var i = 0;
                    foreach (var optionByUrl in lookup)
                    {
                        video.PlaybackOptions.Add(string.Format("{0} - {1}", optionByUrl.Value, i++), optionByUrl.Key);
                    }
                }
            }

            string qualitytoMatch = videoQuality.ToString();
            string firstUrl       = video.PlaybackOptions.FirstOrDefault(p => p.Key.Contains(qualitytoMatch)).Value;

            return(!string.IsNullOrEmpty(firstUrl) ? firstUrl : video.PlaybackOptions.Select(kvp => kvp.Value).LastOrDefault());
        }
예제 #17
0
        /// <summary>
        /// The default streaming from laola1.tv
        ///
        /// The stream starts correctly, but fails after some time for an unknown reason.
        /// </summary>
        /// <param name="video">Video object</param>
        /// <param name="playkey1">Playkey1 for this video</param>
        /// <param name="playkey2">Playkey2 for this video</param>
        /// <returns>Url for streaming</returns>
        private string GetDefaultStreamingUrl(VideoInfo video, string data)
        {
            Match c = regEx_GetPlaykeys.Match(data);

            if (c.Success)
            {
                String playkey1     = c.Groups["playkey1"].Value;
                String playkey2     = c.Groups["playkey2"].Value;
                String flashPlayer  = c.Groups["flashplayer"].Value + ".swf";
                String flashVersion = c.Groups["flashversion"].Value;

                String playData          = GetWebData(String.Format(PLAYDATA_URL, playkey1, playkey2));
                Match  c2                = regEx_GetVideoInfo.Match(playData);
                bool   videoQualityFound = false;
                while (c2.Success)
                {
                    String server        = c2.Groups["server"].Value;
                    String path          = c2.Groups["path"].Value;
                    String streamQuality = c2.Groups["quality"].Value.Trim();

                    if (String.Compare(streamQuality, videoQuality.ToString(), true) == 0)
                    {
                        videoQualityFound = false;
                        String accessData = GetWebData(String.Format(ACCESSDATA_URL_LIVE, playkey1, streamQuality));
                        Match  c3         = regEx_GetAuthLive.Match(accessData);
                        String servertype = c2.Groups["servertype"].Value;;
                        String auth       = null;
                        String aifp       = null;
                        String stream     = null;
                        String url        = null;
                        if (c3.Success)
                        {
                            auth   = c3.Groups["auth"].Value;
                            auth   = auth.Replace("amp;", "");
                            aifp   = c3.Groups["aifp"].Value;
                            stream = c3.Groups["stream"].Value;
                            url    = c3.Groups["url"].Value;
                            c3     = c3.NextMatch();
                        }
                        else
                        {
                            Log.Warn("Couldn't parse " + accessData);
                        }

                        String ip        = null;
                        String identData = GetWebData(String.Format(IDENT_URL, server));
                        Match  c4        = regEx_GetIp.Match(identData);
                        if (c4.Success)
                        {
                            ip = c4.Groups["ip"].Value;
                            c4 = c4.NextMatch();
                        }
                        else
                        {
                            Log.Warn("Couldn't parse " + identData);
                        }

                        String rtmpUrl = String.Format("rtmp://{0}:1935/{1}?_fcs_vhost={2}/{3}?auth={4}&p=1&e={5}&u=&t=livevideo&l=&a=&aifp={6}", ip, servertype, url, stream, auth, playkey1, aifp);
                        MPUrlSourceFilter.RtmpUrl resultUrl = new MPUrlSourceFilter.RtmpUrl(rtmpUrl);
                        //resultUrl.FlashVersion = flashVersion;
                        resultUrl.Live    = true;
                        resultUrl.PageUrl = video.VideoUrl;
                        resultUrl.SwfUrl  = flashPlayer;
                        //TODO: I need the mp4, otherwise the stream isn't found, check if there are other formats than mp4 on laola1.tv
                        resultUrl.PlayPath = "mp4:" + stream;
                        //Log.Info("Playback Url: " + playpath);

                        return(resultUrl.ToString());
                    }
                    c2 = c2.NextMatch();
                }
                if (!videoQualityFound)
                {
                    //this shouldn't happen, maybe the site has added/removed video qualities
                    Log.Warn("Couldn't find the video stream with quality " + videoQuality.ToString());
                }
            }
            return(null);
        }