Ejemplo n.º 1
0
        private void Callback(PostItem postItem)
        {
            string hTML = postItem.Post.HTML;
            List <YouTubeVideoQuality> youTubeVideoUrls = YouTubeDownloader.GetYouTubeVideoUrls(hTML);

            if (youTubeVideoUrls.Count == 0)
            {
                Thread.Sleep(1000);
                youTubeVideoUrls = YouTubeDownloader.GetYouTubeVideoUrls(hTML);
            }
            if (youTubeVideoUrls.Count > 0)
            {
                int num = 0;
                num = 0;
                while (num < youTubeVideoUrls.Count && !youTubeVideoUrls[num].Extention.Equals("mp4"))
                {
                    num++;
                }
                PostItemVideo postItemVideo = new PostItemVideo(postItem.Post, youTubeVideoUrls[num].DownloadUrl);
                Post          post          = postItem.Post;
                post.Name = string.Concat(post.Name, ".", youTubeVideoUrls[num].Extention);
                postItem.Post.Items.Add(postItemVideo);
                this.AddToDownloadQueue(postItem.Post);
            }
        }
Ejemplo n.º 2
0
        private static string GetTitle(string RssDoc)
        {
            string txtBtwn = YouTubeDownloader.GetTxtBtwn(RssDoc, "'VIDEO_TITLE': '", "'", 0);

            if (txtBtwn == "")
            {
                txtBtwn = YouTubeDownloader.GetTxtBtwn(RssDoc, "\"title\" content=\"", "\"", 0);
            }
            if (txtBtwn == "")
            {
                txtBtwn = YouTubeDownloader.GetTxtBtwn(RssDoc, "&title=", "&", 0);
            }
            txtBtwn = txtBtwn.Replace("\\", "").Replace("'", "&#39;").Replace("\"", "&quot;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("+", " ");
            return(txtBtwn);
        }
Ejemplo n.º 3
0
        public static List <YouTubeVideoQuality> GetYouTubeVideoUrls(string html)
        {
            List <YouTubeVideoQuality> youTubeVideoQualities = new List <YouTubeVideoQuality>();
            string title = YouTubeDownloader.GetTitle(html);

            foreach (string str in YouTubeDownloader.ExtractUrls(html))
            {
                YouTubeVideoQuality youTubeVideoQuality = new YouTubeVideoQuality()
                {
                    VideoTitle  = title,
                    DownloadUrl = string.Concat(str, "&title=", title)
                };
                if (!YouTubeDownloader.getQuality(youTubeVideoQuality, YouTubeDownloader.IsWideScreen(html)))
                {
                    continue;
                }
                youTubeVideoQualities.Add(youTubeVideoQuality);
            }
            return(youTubeVideoQualities);
        }
Ejemplo n.º 4
0
 public static string GetLastTxtBtwn(string input, string start, string end, int startIndex)
 {
     return(YouTubeDownloader.GetTxtBtwn(input, start, end, startIndex, true));
 }
Ejemplo n.º 5
0
        private static List <string> ExtractUrls(string html)
        {
            List <string> strs = new List <string>();
            string        str  = "\"url_encoded_fmt_stream_map\":\\s+\"(.+?)&";

            html = Uri.UnescapeDataString(Regex.Match(html, str, RegexOptions.Singleline).Groups[1].ToString());
            string str1 = html.Substring(0, html.IndexOf('=') + 1);

            string[] strArrays = Regex.Split(html, str1);
            for (int i = 0; i < (int)strArrays.Length; i++)
            {
                strArrays[i] = string.Concat(str1, strArrays[i]);
            }
            string[] strArrays1 = strArrays;
            for (int j = 0; j < (int)strArrays1.Length; j++)
            {
                string str2 = strArrays1[j];
                if (str2.Contains("url="))
                {
                    string txtBtwn = YouTubeDownloader.GetTxtBtwn(str2, "url=", "\\u0026", 0);
                    if (txtBtwn == "")
                    {
                        txtBtwn = YouTubeDownloader.GetTxtBtwn(str2, "url=", ",url", 0);
                    }
                    if (txtBtwn == "")
                    {
                        txtBtwn = YouTubeDownloader.GetTxtBtwn(str2, "url=", "\",", 0);
                    }
                    string txtBtwn1 = YouTubeDownloader.GetTxtBtwn(str2, "sig=", "\\u0026", 0);
                    if (txtBtwn1 == "")
                    {
                        txtBtwn1 = YouTubeDownloader.GetTxtBtwn(str2, "sig=", ",sig", 0);
                    }
                    if (txtBtwn1 == "")
                    {
                        txtBtwn1 = YouTubeDownloader.GetTxtBtwn(str2, "sig=", "\",", 0);
                    }
                    while (true)
                    {
                        if (!txtBtwn.EndsWith(","))
                        {
                            if (!txtBtwn.EndsWith(".") && !txtBtwn.EndsWith("\""))
                            {
                                break;
                            }
                        }
                        txtBtwn = txtBtwn.Remove(txtBtwn.Length - 1, 1);
                    }
                    while (true)
                    {
                        if (!txtBtwn1.EndsWith(","))
                        {
                            if (!txtBtwn1.EndsWith(".") && !txtBtwn1.EndsWith("\""))
                            {
                                break;
                            }
                        }
                        txtBtwn1 = txtBtwn1.Remove(txtBtwn1.Length - 1, 1);
                    }
                    if (!string.IsNullOrEmpty(txtBtwn))
                    {
                        if (!string.IsNullOrEmpty(txtBtwn1))
                        {
                            txtBtwn = string.Concat(txtBtwn, "&signature=", txtBtwn1);
                        }
                        strs.Add(txtBtwn);
                    }
                }
            }
            return(strs);
        }