예제 #1
0
        public void GrabVideo(string link)
        {
            AddedTag = null;

            Tags = new List <byte[]>();

            var videoInfos = DownloadUrlResolver.GetDownloadUrls(link);
            var video      = videoInfos.First(info => info.VideoType == VideoType.Flash);

            downloader = new VideoDownloader(video, "");
            downloader.Execute(true);
        }
 private void txt_Url_TextChanged(object sender, EventArgs e)
 {
     if (txt_Url.Text.Length > 5)
     {
         lbl_Resolution.Enabled = true;
         cb_Resolution.Enabled  = true;
         IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(txt_Url.Text);
         foreach (VideoInfo videoInfo in videoInfos)
         {
         }
     }
 }
예제 #3
0
        public static IEnumerable <string> RetrieveDownloadOptionsAsString(string youtubeUrl)
        {
            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(youtubeUrl); // seems that this call uses Newtonsoft.Json
            List <string>           videosTypeAndResolutionList = new List <string>();

            foreach (var actualVideo in videoInfos)
            {
                videosTypeAndResolutionList.Add(actualVideo.Resolution + " - " + actualVideo.VideoType);
                //videosTypeAndResolutionList.Add(actualVideo.ToString());
            }
            return(videosTypeAndResolutionList);
        }
예제 #4
0
        static void Download()
        {
            // Disable logging
            Log.setMode(false);

            // YouTube url
            string link = "https://www.youtube.com/watch?v=LN--3zgY5oM";

            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link, false);

            DownloadVideo(videoInfos);
        }
예제 #5
0
        public bool DownloadMethod1(ActionType action, string title, string url, string path)
        {
            try
            {
                /*
                 * Get the available video formats.
                 * We'll work with them in the video and audio download examples.
                 */
                IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(url);

                // Select the first .mp4 video with the highest resolution
                VideoInfo video = videoInfos.First(info =>
                {
                    if (action.Equals(ActionType.Download))
                    {
                        return(info.VideoType == VideoType.Mp4 && (info.Resolution == 720 || info.Resolution == 480 || info.Resolution == 360));
                    }
                    else
                    {
                        return(info.VideoType == VideoType.Mp4 && info.Resolution == 360);
                    }
                });

                //If the video has a decrypted signature, decipher it
                if (video.RequiresDecryption)
                {
                    DownloadUrlResolver.DecryptDownloadUrl(video);
                }

                /*
                 * Create the video downloader.
                 * The first argument is the video to download.
                 * The second argument is the path to save the video file.
                 */
                var videoDownloader = new VideoDownloader(video, Path.Combine(path, video.Title + video.VideoExtension));

                // Register the ProgressChanged event and return current progress to ProgressBar
                // TODO: only use if WPF or implement progress bar for WF
                videoDownloader.DownloadProgressChanged += (sender, args) => EventHandler(this, new ProgressBarEventArgs(args.ProgressPercentage));

                /*
                 * Execute the video downloader.
                 * For GUI applications note, that this method runs synchronously.
                 */
                videoDownloader.Execute();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #6
0
        /// <summary>
        /// Get VideoInfo of a youtube video
        /// </summary>
        /// <param name="youtubeLink">The youtube link of a movie</param>
        /// <param name="qualitySetting">The youtube quality settings</param>
        private async Task <VideoInfo> GetVideoInfoForStreamingAsync(string youtubeLink,
                                                                     Constants.YoutubeStreamingQuality qualitySetting)
        {
            // Get video infos of the requested video
            var videoInfos = await Task.Run(() => DownloadUrlResolver.GetDownloadUrls(youtubeLink, false));

            // We only want video matching criterias : only mp4 and no adaptive
            var filtered = videoInfos
                           .Where(info => info.VideoType == VideoType.Mp4 && !info.Is3D && info.AdaptiveType == AdaptiveType.None);

            return(GetVideoByStreamingQuality(filtered, qualitySetting));
        }
예제 #7
0
        private void toolStart_Click(object sender, EventArgs e)
        {
            if (activityListView.SelectedItems.Count == 1)
            {
                lvi = new ListViewItem();
                lvi = activityListView.SelectedItems[0];
                int index = activityListView.SelectedIndices[0];
                indexThread[index] = index;

                if (!string.IsNullOrEmpty(lvi.SubItems[6].Text))
                {
                    if (lvi.SubItems[3].Text.ToString() != "0%")
                    {
                        for (int i = 0; i < indexThread.Length; i++)
                        {
                            if (threads[i] != null && activityListView.SelectedIndices[0] == indexThread[i] && threads[i].IsAlive)
                            {
                                threads[i].Resume();
                            }
                        }
                    }
                    else
                    {
                        DialogResult dialogResult = MessageBox.Show("The default save location is on Desktop if you want to change press Yes", "", MessageBoxButtons.YesNo);
                        if (dialogResult == DialogResult.Yes)
                        {
                            FolderBrowserDialog fbd = new FolderBrowserDialog();
                            if (fbd.ShowDialog() == DialogResult.OK)
                            {
                                lvi.SubItems[6].Text = fbd.SelectedPath;
                            }
                        }
                        else if (dialogResult == DialogResult.No)
                        {
                        }
                        IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(lvi.SubItems[5].Text);
                        VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4);
                        if (video.RequiresDecryption)
                        {
                            DownloadUrlResolver.DecryptDownloadUrl(video);
                        }
                        VideoDownloader downloader = new VideoDownloader(video, Path.Combine(lvi.SubItems[6].Text + "\\", video.Title + video.VideoExtension));
                        downloader.DownloadProgressChanged += downloader_DownloadProgressChangedTag;
                        threads[index] = new Thread(() => { downloader.Execute(); })
                        {
                            IsBackground = true
                        };
                        threads[index].Start();
                        downloader.DownloadFinished += downloader_DownloadFinshedTag;
                    }
                }
            }
        }
예제 #8
0
 private void btnDownload_Click(object sender, EventArgs e)
 {
     if (searchListView.SelectedItems.Count > 0)
     {
         downloadProgressBar.Minimum      = 0;
         downloadProgressBar.Maximum      = 100;
         resolutionComboBox.SelectedValue = 360;
         IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(downloadUrlTextField.Text);
         try
         {
             VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(resolutionComboBox.Text));
             if (video.RequiresDecryption)
             {
                 DownloadUrlResolver.DecryptDownloadUrl(video);
             }
             VideoDownloader downloader = new VideoDownloader(video, Path.Combine(saveToTextField.Text + "\\", video.Title + video.VideoExtension));
             downloader.DownloadProgressChanged += downloader_DownloadProgressChanged;
             Thread thread = new Thread(() => { downloader.Execute(); })
             {
                 IsBackground = true
             };
             thread.Start();
             downloader.DownloadFinished += downloader_DownloadFinshed;
         }
         catch
         {
             MessageBox.Show("Error! Either download is not allowed or resolution is not supported");
         }
     }
     else if (!string.IsNullOrWhiteSpace(downloadUrlTextField.Text))
     {
         downloadProgressBar.Minimum = 0;
         downloadProgressBar.Maximum = 100;
         IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(downloadUrlTextField.Text);
         VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(resolutionComboBox.Text));
         if (video.RequiresDecryption)
         {
             DownloadUrlResolver.DecryptDownloadUrl(video);
         }
         VideoDownloader downloader = new VideoDownloader(video, Path.Combine(saveToTextField.Text + "\\", video.Title + video.VideoExtension));
         downloader.DownloadProgressChanged += downloader_DownloadProgressChanged;
         Thread thread = new Thread(() => { downloader.Execute(); })
         {
             IsBackground = true
         };
         thread.Start();
         downloader.DownloadFinished += downloader_DownloadFinshed;
     }
     else
     {
         MessageBox.Show("Enter Url!");
     }
 }
예제 #9
0
파일: YouTube.cs 프로젝트: DubeyAnkur/HR
        public void DownloadAudio(string link)
        {
            // Our test youtube link
            //string link = "insert youtube link";

            /*
             * Get the available video formats.
             * We'll work with them in the video and audio download examples.
             */
            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link);

            /*
             * We want the first extractable video with the highest audio quality.
             */
            VideoInfo video = videoInfos
                              .Where(info => info.CanExtractAudio)
                              .OrderByDescending(info => info.AudioBitrate)
                              .First();

            /*
             * If the video has a decrypted signature, decipher it
             */
            if (video.RequiresDecryption)
            {
                DownloadUrlResolver.DecryptDownloadUrl(video);
            }

            /*
             * Create the audio downloader.
             * The first argument is the video where the audio should be extracted from.
             * The second argument is the path to save the audio file.
             */
            string fileName = video.Title;

            fileName = Regex.Replace(fileName, @"[^\w\.@-]", "", RegexOptions.None, TimeSpan.FromSeconds(1.5));
            var audioDownloader = new AudioDownloader(video, Path.Combine(downloadLocation, fileName + video.AudioExtension));


            // Register the progress events. We treat the download progress as 85% of the progress and the extraction progress only as 15% of the progress,
            // because the download will take much longer than the audio extraction.
            audioDownloader.DownloadProgressChanged        += (sender, args) => Console.WriteLine(args.ProgressPercentage * 0.85);
            audioDownloader.AudioExtractionProgressChanged += (sender, args) => Console.WriteLine(85 + args.ProgressPercentage * 0.15);

            if (!File.Exists(Path.Combine(downloadLocation, fileName + video.AudioExtension)))
            {
                /*
                 * Execute the audio downloader.
                 * For GUI applications note, that this method runs synchronously.
                 */
                audioDownloader.Execute();
            }
        }
예제 #10
0
        private void VideoDownload(string linkAdress)
        {
            progressBar.Minimum = 0;
            progressBar.Maximum = 100;
            VideoInfo video;

            videoSize     = 0;
            downloaded    = 0;
            downloadSpeed = 0;


            try
            {
                IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(linkAdress);
                video = videos.First(p => p.VideoType == VideoType.Mp4 && p.Resolution == Convert.ToInt32(resBox.Text));


                if (video.RequiresDecryption)
                {
                    DownloadUrlResolver.DecryptDownloadUrl(video);
                }


                title         = checkIllegal(video.Title);
                ext           = video.VideoExtension;
                link          = urlText.Text;
                resolution    = resBox.Text;
                titleLbl.Text = title;
                extText.Text  = ext;

                VideoDownloader downloader =
                    new VideoDownloader(video, Path.Combine(path, title + video.VideoExtension));

                VDcopy = downloader;
                downloader.DownloadProgressChanged += Downloader_DownloadProgressChanged;


                Thread thread = new Thread(() => { try { downloader.Execute(); } catch (IOException ex) { } })
                {
                    IsBackground = true
                };
                thread.Start();
                watch.Start();
                ins = thread;
            }
            catch (FileLoadException ex)
            {
                error er = new error();
                er.Show();
                resBox.SelectedIndex = 2;
            }
        }
예제 #11
0
파일: hit.cs 프로젝트: piopy/hit
        private void d_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (directoryPath.Equals(""))
                {
                    MessageBox.Show("Cannot download into the void, man");
                }
                else if (URLS.Items.Count == 0)
                {
                    MessageBox.Show("Cannot download the void, man");
                }
                else
                {
                    count = URLS.Items.Count;
                    MessageBox.Show("Have a sit and take a coffee, man");
                    foreach (YoutubeVideo item in URLS.Items)
                    {
                        string link = item.Url;

                        IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link, false);

                        VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4); // youtube gives always mp4

                        /* if (video.RequiresDecryption)
                         * {
                         *   DownloadUrlResolver.DecryptDownloadUrl(video);
                         * }*/
                        //DownloadAudio(videoInfos, directoryPath, progress);

                        WebClient wc    = new WebClient();
                        string    tempF = directoryPath + "\\Downloaded\\";
                        if (!Directory.Exists(tempF))
                        {
                            Directory.CreateDirectory(tempF);
                        }

                        wc.DownloadProgressChanged += gestoreBarra;
                        wc.DownloadFileCompleted   += decreasecount;
                        //string nome = tempF + video.Title.Normalize();
                        string nome = tempF + RemoveIllegalPathCharacters(video.Title);

                        wc.DownloadFileAsync(new Uri(string.Format("http://www.youtubeinmp3.com/fetch/?video={0}", link)), nome + ".mp3");
                    }
                    //MessageBox.Show("Download finished, man");
                }
            }catch
            {
                MessageBox.Show("Invalid URL, man");
            }
            URLS.Items.Clear();
        }
예제 #12
0
        public static Client.Audio DownloadAudioWithProgress(YoutubeParser.YoutubeVidDetail detail, Client.Message message)
        {
            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(detail.URL);
            VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);

            if (video.RequiresDecryption)
            {
                DownloadUrlResolver.DecryptDownloadUrl(video);
            }

            message.Reply("Found!");

            string filename        = string.Join("", video.Title.Split(Path.GetInvalidFileNameChars()));
            var    videoDownloader = new VideoDownloader(video, Path.GetFullPath(Path.Combine("ffmpeg", filename + video.VideoExtension)));

            int prev = 1;
            int mul  = 125;

            videoDownloader.DownloadProgressChanged += (sender, argss) =>
            {
                int prog = (int)Math.Round(argss.ProgressPercentage);
                if (prog >= prev * mul)
                {
                    message.Reply((mul * prev) + "%");
                    prev++;
                }
            };

            videoDownloader.Execute();
            //message.Reply("Converting!");
            Convert(filename);

            File.Delete(Path.Combine("ffmpeg", filename + video.VideoExtension));

            FileStream   fstream = new FileStream(Path.Combine("ffmpeg", filename + ".mp3"), System.IO.FileMode.Open);
            MemoryStream mstream = new MemoryStream();

            fstream.CopyTo(mstream);
            fstream.Close();

            Mp3FileReader reader   = new Mp3FileReader(Path.Combine("ffmpeg", filename + ".mp3"));
            TimeSpan      duration = reader.TotalTime;

            reader.Close();

            File.Delete(Path.Combine("ffmpeg", filename + ".mp3"));
            message.Reply("Success!");

            System.Diagnostics.Debug.WriteLine("\n\nTitle: " + video.Title + "Duration: " + (int)duration.TotalSeconds);

            return(new Client.Audio(filename, detail.Channel, (int)duration.TotalSeconds, mstream, "mp3"));
        }
예제 #13
0
        private void Download_Click(object sender, EventArgs e)
        {
            IEnumerable <VideoInfo> _video = DownloadUrlResolver.GetDownloadUrls(txtAddress.Text);
            VideoInfo _myVideo             = _video.First(vid => vid.VideoType == VideoType.Mp4);

            if (_myVideo.RequiresDecryption)
            {
                DownloadUrlResolver.DecryptDownloadUrl(_myVideo);
            }
            VideoDownloader _downloader = new VideoDownloader(_myVideo, @"video.mp4");

            _downloader.Execute();
        }
예제 #14
0
        static VideoInfo getVideoInfo(string videoLink)
        {
            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(videoLink);

            if (videoInfos.Count <VideoInfo>() == 0)
            {
                return(null);
            }
            VideoInfo video = videoInfos
                              .FirstOrDefault(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);

            return(video);
        }
예제 #15
0
        private void Button1_Click(object sender, EventArgs e)
        {
            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(textBox1.Text.Replace("player_", "player-"), false);

            listView1.Items.Clear();
            foreach (var item in videoInfos.OrderByDescending(z => z.Resolution))
            {
                listView1.Items.Add(new ListViewItem(new string[] { item.ToString(), item.Resolution + "", item.VideoExtension + "", item.AudioType.ToString() })
                {
                    Tag = item
                });
            }
        }
예제 #16
0
        internal static string DLAudio(string ytlink)
        {
            // Our test youtube link
            string link = ytlink;

            /*
             * Get the available video formats.
             * We'll work with them in the video and audio download examples.
             */
            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link, false);

            return(DownloadAudio(videoInfos));
        }
예제 #17
0
        private void button_PlayClick(object sender, RoutedEventArgs e)
        {
            // Direktlink
            // myControl.MediaPlayer.Play(new Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi"));

            string link = "https://www.youtube.com/watch?v=0sB3Fjw3Uvc";
            //string link = "https://www.youtube.com/watch?v=0sB3Fjw3Uvc";

            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link);
            VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);

            myControl.MediaPlayer.Play(new Uri(video.DownloadUrl));
        }
예제 #18
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool validator = false;

            label11.Text = "";
            label12.Text = "";
            if (string.IsNullOrWhiteSpace(textBox1.Text))
            {
                label11.Text = "Mandatory";
                validator    = true;
            }

            if (string.IsNullOrWhiteSpace(label4.Text))
            {
                label12.Text = "Mandatory";
                validator    = true;
            }

            if (validator)
            {
                return;
            }

            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(textBox1.Text);

            VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == Convert.ToInt32(comboBox1.SelectedItem.ToString()));

            /*
             * If the video has a decrypted signature, decipher it
             */
            if (video.RequiresDecryption)
            {
                DownloadUrlResolver.DecryptDownloadUrl(video);
            }

            /*
             * Create the video downloader.
             * The first argument is the video to download.
             * The second argument is the path to save the video file.
             */
            var videoDownloader = new VideoDownloader(video, Path.Combine(label4.Text, string.IsNullOrWhiteSpace(textBox2.Text) ? video.Title + video.VideoExtension : textBox2.Text + video.VideoExtension));

            // Register the ProgressChanged event and print the current progress
            videoDownloader.DownloadProgressChanged += (s, args) => valueChange(args.ProgressPercentage);

            /*
             * Execute the video downloader.
             * For GUI applications note, that this method runs synchronously.
             */
            videoDownloader.Execute();
        }
예제 #19
0
        public static ObservableCollection <VideoExtensionType> getVideoExtensionType(string url, bool custome = true)
        {
            var list = new ObservableCollection <VideoExtensionType>();

            //int _index = 0;

            try
            {
                IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(url);
                if (!custome)
                {
                    videos = videos.Where(a => a.VideoType == VideoType.Mp4)
                             .OrderByDescending(a => a.Resolution)
                             .Take(1);
                }

                var videosDistinct = videos.Select(w => new {
                    w.VideoType
                    ,
                    w.Title
                    ,
                    w.Resolution
                    ,
                    w.VideoExtension
                })
                                     .Distinct()
                                     .OrderBy(w => w.VideoType)
                                     .ThenByDescending(w => w.Resolution)
                                     .ToList();

                videosDistinct.ToList().ForEach(v =>
                {
                    list.Add(new VideoExtensionType()
                    {
                        //Index = _index,
                        Resolution     = v.Resolution,
                        VideoExtension = v.VideoExtension,
                        VideoType      = v.VideoType.ToString(),
                        Titel          = "Video Type:" + v.VideoType.ToString() +
                                         new string(' ', 10 - v.VideoType.ToString().Length) +
                                         "Resolution: " + v.Resolution.ToString()
                    });

                    // _index++;
                });
            }
            catch (Exception)
            { }

            return(list);
        }
예제 #20
0
        private static void RunInfo(string url)
        {
            var videoInfos = DownloadUrlResolver.GetDownloadUrls(url, false);
            var filtered   = videoInfos
                             .Where(it => !(it.VideoType == VideoType.Unknown && it.AudioType == AudioType.Unknown && it.Resolution == 0))
                             .OrderBy(it => it.VideoType)
                             .ThenBy(it => it.Resolution);

            foreach (var info in filtered)
            {
                var str = $"{info.Resolution.ToString().PadLeft(6, ' ')}{info.VideoType.ToString().PadLeft(6, ' ')}{info.AudioType.ToString().PadLeft(9, ' ')}  '{info.Title}'";
                Console.WriteLine(str);
            }
        }
예제 #21
0
        /// <summary>
        /// Загрузка записи в определенную директорию.
        /// </summary>
        private void DownloadRecord(string link, string path, string name, YouTubeRecord record)
        {
            var tempFile = "";

            name = name.Replace('/', '-');
            try
            {
                BeginInvoke(new Action(() =>
                {
                    PublishEvent($"[{name}] - try to download...");
                }));

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                var videoInfos = DownloadUrlResolver.GetDownloadUrls(link, false);
                var video      = videoInfos.First();

                var finalFile = Path.Combine(path, ReplaceIllegalPathCharacters(name) + video.VideoExtension);

                if (!File.Exists(finalFile))
                {
                    tempFile = Path.Combine(path, ReplaceIllegalPathCharacters(name) + ".tmp");
                    var videoDownloader = new VideoDownloaderEx(video, tempFile, record);
                    videoDownloader.DownloadProgressChanged += VideoDownloader_DownloadProgressChanged;
                    videoDownloader.Execute();
                    RenameFile(tempFile, finalFile);
                }
                record.ProgressPercentage = 100;

                BeginInvoke(new Action(() =>
                {
                    PublishEvent($"[{name}] - was downloaded successfully");
                }));
            }
            catch (Exception ex)
            {
                BeginInvoke(new Action(() =>
                {
                    PublishEvent($"{ex.Source} - {ex.Message}");
                }));

                if (!string.IsNullOrEmpty(tempFile))
                {
                    DeleteFile(tempFile);
                }
            }
        }
        /// <summary>
        /// Gets the video information (title, encodings, resolutions).
        /// </summary>
        /// <param name="videoUrl">Source video to retrieve information of.</param>
        /// <returns>
        /// An enumeration of video information objects.
        /// </returns>
        public IEnumerable <ytgify.Models.VideoInfo> GetVideoInfos(Uri videoUrl)
        {
            var videoInfos = DownloadUrlResolver.GetDownloadUrls(videoUrl.ToString()).ToList();

            foreach (var videoInfo in videoInfos)
            {
                if (videoInfo.RequiresDecryption)
                {
                    DownloadUrlResolver.DecryptDownloadUrl(videoInfo);
                }
            }

            return(videoInfos.Select(v => v.ToContract(videoUrl)));
        }
예제 #23
0
        /// <summary>
        /// Gets the MRLS.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <returns></returns>
        public static IEnumerable <string> GetMrls(string url)
        {
            var normalizedUrl = string.Empty;

            if (DownloadUrlResolver.TryNormalizeYoutubeUrl(url, out normalizedUrl))
            {
                var videoInfos = DownloadUrlResolver.GetDownloadUrls(normalizedUrl);

                foreach (var item in videoInfos)
                {
                    yield return(item.DownloadUrl);
                }
            }
        }
예제 #24
0
        public async Task LoadContextMenu()
        {
            this.IsLoadingContextMenu = true;

            IEnumerable <VideoInfo> infos = await Task.Run(() => DownloadUrlResolver.GetDownloadUrls(this.Path, false).ToList());

            this.VideosToDownload = infos.Where(x => x.AdaptiveType == AdaptiveType.None && x.VideoType != VideoType.Unknown)
                                    .OrderBy(x => x.VideoType)
                                    .ThenByDescending(x => x.Resolution)
                                    .ToList();
            this.AudioToDownload = infos.Where(x => x.CanExtractAudio).OrderByDescending(x => x.AudioBitrate).ToList();

            this.IsLoadingContextMenu = false;
        }
예제 #25
0
        void DownloadAudioFrom(Downloadable InVideo, int count)
        {
            InVideo.Preparing = true;
            ListDelegate ld = new ListDelegate(Program.frm.UpdateList);

            Program.frm.Invoke(ld);

            string link        = InVideo.Url;
            string countPrefix = count.ToString();

            countPrefix = countPrefix.PadLeft(padLeft, '0');

            VideoInfo video = DownloadUrlResolver.GetDownloadUrls(link);

            if (video.RequiresDecryption)
            {
                DownloadUrlResolver.DecryptDownloadUrl(video);
            }

            char[] legalTitleArray = video.Title.ToCharArray();
            string legalTitle      = "";

            foreach (char c in legalTitleArray)
            {
                if (!(c == '/' || c == '\\' || c == ':' || c == '*' || c == '?' || c == '"' || c == '<' || c == '>' || c == '|'))
                {
                    legalTitle += c;
                }
            }

            if (incremental)
            {
                var audioDownloader = new AudioDownloader(video, savePath + @"\" + countPrefix + " " + legalTitle + video.AudioExtension);
                audioDownloader.DownloadProgressChanged        += (sender, _args) => DownloadProgress(_args.ProgressPercentage, InVideo);
                audioDownloader.AudioExtractionProgressChanged += (sender, _args) => ExtractionProgress(_args.ProgressPercentage, InVideo);
                audioDownloader.Execute();
            }
            else
            {
                var audioDownloader = new AudioDownloader(video, savePath + @"\" + legalTitle + video.AudioExtension);
                audioDownloader.DownloadProgressChanged        += (sender, _args) => DownloadProgress(_args.ProgressPercentage, InVideo);
                audioDownloader.AudioExtractionProgressChanged += (sender, _args) => ExtractionProgress(_args.ProgressPercentage, InVideo);
                audioDownloader.Execute();
            }

            lock (threadLocker)
            {
                Program.frm.remaining--;
            }
        }
예제 #26
0
        static void CompileThis()
        {
            AdaptiveType a = AdaptiveType.Audio;

            a = AdaptiveType.None;
            a = AdaptiveType.Video;

            AudioExtractionException b = new AudioExtractionException(default(string));

            AudioType c = AudioType.Aac;

            c = AudioType.Mp3;
            c = AudioType.Unknown;
            c = AudioType.Vorbis;

            DownloadUrlResolver.DecryptDownloadUrl(default(VideoInfo));
            IEnumerable <VideoInfo> d = DownloadUrlResolver.GetDownloadUrls(default(string));

            d = DownloadUrlResolver.GetDownloadUrls(default(string), default(bool));
            string e = default(string);
            bool   f = DownloadUrlResolver.TryNormalizeYoutubeUrl(e, out e);

            VideoInfo    g = default(VideoInfo);
            AdaptiveType h = g.AdaptiveType;
            int          i = g.AudioBitrate;
            string       j = g.AudioExtension;
            AudioType    k = g.AudioType;
            bool         l = g.CanExtractAudio;
            string       m = g.DownloadUrl;
            int          n = g.FormatCode;
            bool         o = g.Is3D;
            bool         p = g.RequiresDecryption;
            int          q = g.Resolution;
            string       r = g.Title;
            string       s = g.VideoExtension;
            VideoType    t = g.VideoType;

            VideoNotAvailableException u = new VideoNotAvailableException();

            u = new VideoNotAvailableException(default(string));

            VideoType v = VideoType.Flash;

            v = VideoType.Mobile;
            v = VideoType.Mp4;
            v = VideoType.Unknown;
            v = VideoType.WebM;

            YoutubeParseException w = new YoutubeParseException(default(string), default(Exception));
        }
예제 #27
0
        private void videoinfobtn_click(object sender, EventArgs e)
        {
            videoinfobtn.Enabled = false;
            int xx;

            string link = urltext.Text;

            try
            {
                IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link, false);

                int[] arr = new int[3] {
                    360, 720, 1080
                };
                for (xx = 0; xx < 3; xx++)
                {
                    try
                    {
                        VideoInfo video = videoInfos
                                          .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == arr[xx]);
                        if (xx == 0)
                        {
                            radiobtn360p.Enabled = true;
                        }
                        else if (xx == 1)
                        {
                            radiobtn720p.Enabled = true;
                        }
                        else if (xx == 2)
                        {
                            radiobtn1080p.Enabled = true;
                        }
                    }
                    catch (Exception st)
                    {
                    }
                }
                downloadvideobtn.Visible = true;
                downloadaudiobtn.Visible = true;
                videoinfobtn.Visible     = false;
                //   button6.Visible = false;
                VideoInfo vid = videoInfos.First();
                label3.Text = vid.Title;
            }
            catch (Exception exx)
            {
                MessageBox.Show("Invalid link");
                Application.Restart();
            }
        }
예제 #28
0
        private static void Main()
        {
            // Our test youtube link
            const string link = "https://www.youtube.com/watch?v=YQHsXMglC9A";

            /*
             * Get the available video formats.
             * We'll work with them in the video and audio download examples.
             */
            IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link, false);

            //DownloadAudio(videoInfos);
            DownloadVideo(videoInfos);
        }
예제 #29
0
        public string GetVideoUrl(string title)       //Получение названия видеоролика
        {
            string videotitle = null;

            try
            {
                Thread.Sleep(3000);
                IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls("https://youtube.com" + title);
                VideoInfo video = videoInfos
                                  .First(info => info.VideoType == VideoType.Mp4 && info.Resolution == resolution);
                videotitle = video.Title.Replace('|', '_').Replace('[', '_').Replace(']', '_').Replace(':', '_').Replace('+', '_') + video.VideoExtension + "|" + video.DownloadUrl;
            }
            catch (YoutubeParseException) { }
            return(videotitle);
        }
예제 #30
0
        private bool check(string link)
        {
            try
            {
                IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(link);
                VideoInfo video = videos.First(p => p.VideoType == VideoType.Mp4);
            }
            catch (Exception)
            {
                MessageBox.Show("Link Not Available", "Alert", MessageBoxButtons.OK);
                return(false);
            }

            return(true);
        }