public static void AdHelpInfo()
        {
            Console.Clear();

            Console.WriteLine("------------------------------------------------------\nYoutube Ad Help\n------------------------------------------------------");
            Console.WriteLine("When a video AD plays. \nRight click on it and select 'Copy debug info' then add it to a .txt file and drop it in the console!");
            Console.WriteLine("------------------------------------------------------\nPress Any Key To Continue . . .");

            Console.ReadKey();

            ProgramRestart.Restart();
        }
Example #2
0
        public static void YoutubeDownloaderStart()
        {
            try
            {
                IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(YoutubeOpener.youtubeLink);

                /*
                 * Select the first .mp4 video
                 */



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

                /*
                 * 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(downloadsPath, video.Title + video.VideoExtension));

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

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

                Console.WriteLine($"File downloaded at: { downloadsPath }");
                Console.WriteLine("Press Any Key To Continue . . .");

                Console.ReadKey();

                ProgramRestart.Restart();
            }
            catch (Exception)
            {
                Console.Clear();
                Console.WriteLine("Looks like this quality cannot be downloaded or the video is listed or private.\nTry another quality option!");
                YoutubeDownloader();
            }
        }
Example #3
0
        public static void OpenQuestion()
        {
            Console.WriteLine("Do you want to open the video in your default browser? 'y' or 'n'");
            string questionAnswer = Console.ReadLine().ToString();

            if (questionAnswer.ToLower().Trim(' ') == "y")
            {
                Open();
            }
            else if (questionAnswer.ToLower().Trim(' ') == "n")
            {
                YoutubeDownloaderClass.YoutubeDownloader();
            }
            else
            {
                ProgramRestart.Restart();
            }
        }
Example #4
0
        public static void YoutubeDownloader()
        {
            Console.WriteLine("Do you wish to download that video? 'y' or 'n' ");
            string downloadVideoAnswer = Convert.ToString(Console.ReadLine());

            if (downloadVideoAnswer.ToLower() == "y")
            {
                Console.WriteLine("Type the download quality '360', '480', '720', '1080'");
                downloadVideoQualityAnswer = Console.ReadLine().ToString();

                YoutubeDownloaderStart();
            }
            else if (downloadVideoAnswer.ToLower() == "n")
            {
                ProgramRestart.Restart();
            }
            else
            {
                ProgramRestart.Restart();
            }

            Console.ReadKey();
        }
        public static void FindingAdID()
        {
            try
            {
                // Removes Previous StringBuilder's characters. If its not removed it only plays 1 video no matter the ID.
                adDocIdStringBuilder.Remove(0, adDocIdStringBuilder.Length);

                // Asking for a file
                Console.WriteLine("Drop in the console the txt file with the debug info for the ad! Type 'Help' for more info!\nType 'Exit', 'Close' or 'Quit' to exit the program!");
                writtenPath = Console.ReadLine().ToString();


                // Checking for Ad Help
                if (writtenPath.ToLower() == "help")
                {
                    YoutubeAdHelp.AdHelpInfo();
                }

                // Checking for blank space input
                else if (writtenPath.Trim(' ') == "")
                {
                    ProgramRestart.Restart();
                }

                // Checking for "Exit" input
                else if (writtenPath.ToLower() == "quit" || writtenPath.ToLower() == "close" || writtenPath.ToLower() == "exit")
                {
                    Environment.Exit(0);
                }

                // Part of checking if the file extention is incorrect ".exe"
                writtenPathExtentionCheckInt    = writtenPath.LastIndexOf('.');
                writtenPathExtentionCheckString = writtenPath.Substring(writtenPathExtentionCheckInt);

                //Checking for exe extention
                if (writtenPathExtentionCheckString.ToLower().Trim(' ', '.', '"') == "exe" || writtenPathExtentionCheckString.ToLower().Trim(' ', '.', '"') == ".exe")
                {
                    throw new ArgumentOutOfRangeException();
                }


                // Reading File
                string debugInfo = File.ReadAllText($@"{ writtenPath.Trim('"') }");

                // Getting "ad_docid"
                int debugInfoIndexOf = debugInfo.IndexOf("ad_docid");
                string adDocIdLine = debugInfo.Substring(debugInfoIndexOf, 24);

                // Seperator
                char[] seperator = new char[]
                {
                ' ', '"', ':'
                };

                // String Split
                string[] adDocIdSplit = adDocIdLine.Split(seperator, StringSplitOptions.RemoveEmptyEntries);


                // StringBuilder Time

                for (int i = 1; i < adDocIdSplit.Length; i++)
                {
                    adDocIdStringBuilder.Append(adDocIdSplit[i]);
                }


                Console.Clear();

                // Printing the StringBuilder/ID
                Console.WriteLine($"ID: {adDocIdStringBuilder.ToString()}");

                //Opening Youtube Video
                YoutubeOpener.OpenQuestion();

                // Downloading video

                YoutubeDownloaderClass.YoutubeDownloader();

                // Reseting Program after opening/downloading video
                ProgramRestart.Restart();
            }

            // Catching exceptions
            catch (FileNotFoundException)
            {
                Console.Clear();
                Console.WriteLine("The file is not found please try again!\nPress Any Key To Continue . . .");
                Console.ReadKey();
            }
            catch (NotSupportedException)
            {
                Console.Clear();
                Console.WriteLine("The file is not found please try again!\nPress Any Key To Continue . . .");
                Console.ReadKey();
            }
            catch (ArgumentOutOfRangeException)
            {
                Console.Clear();
                Console.WriteLine("The path is not valid or the file does not contain an AD ID or is a wrong extention.\nMake sure you drop the right file!\nPress Any Key To Continue . . .");
                Console.ReadKey();
            }
            catch (ArgumentException)
            {
                Console.Clear();
                Console.WriteLine("You typed something wrong please try again!\nPress Any Key To Continue . . .");
                Console.ReadKey();
            }
            catch (Exception)
            {
                Console.Clear();
                Console.WriteLine("The path is not valid or the file does not contain an AD ID or is a wrong extention.\nMake sure you drop the right file!\nPress Any Key To Continue . . .");
                Console.ReadKey();
            }
            finally
            {
                ProgramRestart.Restart();
            }
        }