示例#1
0
        //private void DisplayHelpToolTip()
        //{
        //    Label_Help.ToolTip =
        //        Properties.Resources.Help_AudioBitrate +
        //        "\n\n----------\n\n" +
        //        Properties.Resources.Help_RetrieveContent;
        //}

        private void HandleDrop(DragEventArgs e)
        {
            try
            {
                if (IOMethods.DropType_isFile(e))
                {
                    FileInfo fileInfo = new FileInfo(((string[])e.Data.GetData(DataFormats.FileDrop))[0]);
                    if (IOMethods.ValidateFileExtension(fileInfo))
                    {
                        TextBox_url.Text = fileInfo.FullName;
                        return;
                    }
                    MessageBox.Show("Erreur : Fichier non supporté.");
                    return;
                }

                if (IOMethods.DropType_isURL(e))
                {
                    TextBox_url.Text = e.Data.GetData(DataFormats.UnicodeText).ToString();
                    return;
                }
                MessageBox.Show("Erreur : Doit être spécifié soit l'URL d'une vidéo Youtube, soit le lien complet vers un fichier vidéo.");
            }
            catch (Exception ex)
            {
                IOMethods.WriteToLog("Erreur dans HandleDrop(DragEventArgs e). Exception =\n" + ex.ToString());
            }
        }
        public static string VideoDownload_BuildCLI_With(string url)
        {
            string commandLine = "";

            try
            {
                string rootDirPath   = Properties.Settings.Default["RootDirPath"].ToString();
                string downloadedDir = rootDirPath + @"\Downloaded";
                string youtubeDlDir  = rootDirPath + @"\resources\youtube-dl";

                // youtube-dl parameters :
                // -o                   -> Output filename template
                // -q                   -> Quiet mode
                // --console-title      -> Display progression as windows title

                // In cmd.exe, the command line would be :
                // start "" "path/to/youtube-dl.exe" [-option] "path/as/destination/nom.extension" <youtube video url>

                commandLine = String.Format(
                    "/c start \"\" \"{0}\\youtube-dl.exe\" --console-title -o \"{1}\\InProgress\\%(title)s.%(ext)s\" {2}", // -q
                    youtubeDlDir,
                    downloadedDir,
                    url
                    );

                IOMethods.WriteToLog("Command line (video) :\n" + commandLine);
            }
            catch (Exception ex)
            {
                IOMethods.WriteToLog("Erreur dans VideoDownload_BuildCLI_From(string url). Exception =\n" + ex.ToString());
            }

            return(commandLine);
        }
示例#3
0
        private void SetAudioQuality(int bitrate)
        {
            try
            {
                switch (bitrate)
                {
                case 128000:
                    RadioButton_mp3_128.IsChecked = true;
                    break;

                case 256000:
                    RadioButton_mp3_256.IsChecked = true;
                    break;

                case 320000:
                    RadioButton_mp3_320.IsChecked = true;
                    break;

                default:
                    return;
                }
            }
            catch (Exception ex)
            {
                IOMethods.WriteToLog("Erreur dans SetAudioQuality(int bitrate). Exception =\n" + ex.ToString());
            }
        }
示例#4
0
        private void LoadSettings()
        {
            try
            {
                Properties.Settings.Default["RootDirPath"] = IOMethods.GetRootDirPath();

                bool isReadOnly = Convert.ToBoolean(Properties.Settings.Default["TextBox_readonly"]);
                SetTextBoxReadOnly(isReadOnly);

                int audioBitrate = Convert.ToInt32(Properties.Settings.Default["AudioBitrate"]);
                SetAudioQuality(audioBitrate);
            }
            catch (Exception ex)
            {
                IOMethods.WriteToLog("Erreur dans LoadSettings(). Exception =\n" + ex.ToString());
            }
        }
 public static ProcessStartInfo PrepareProcess(string cli)
 {
     try
     {
         return(new ProcessStartInfo("cmd.exe")
         {
             Arguments = cli,
             CreateNoWindow = true,
             RedirectStandardOutput = true,
             RedirectStandardError = true,
             UseShellExecute = false
         });
     }
     catch (Exception ex)
     {
         IOMethods.WriteToLog("Erreur dans ExecuteCLI_With(string cli). Exception =\n" + ex.ToString());
         return(null);
     }
 }
示例#6
0
 private void SetTextBoxReadOnly(bool readOnly)
 {
     try
     {
         if (readOnly)
         {
             TextBox_url.IsReadOnly = true;
             TextBox_url.Cursor     = Cursors.Arrow;
             TextBox_url.Background = (Brush) new BrushConverter().ConvertFrom("#F2F2F2");
         }
         else
         {
             TextBox_url.IsReadOnly = false;
             TextBox_url.Cursor     = Cursors.IBeam;
             TextBox_url.Background = new SolidColorBrush(Colors.Transparent);
         }
     }
     catch (Exception ex)
     {
         IOMethods.WriteToLog("Erreur dans SetReadOnly(bool flag). Exception =\n" + ex.ToString());
     }
 }
        //public static List<string> Audio_BuildCLI_WithTEST(string filepath)
        //{
        //    List<string> ls = new List<string>();


        //}



        public static string AudioExtraction_BuildCLI_With(string filepath)
        {
            string commandLine = "";

            try
            {
                FileInfo fileInfo             = new FileInfo(filepath);
                string   filename             = fileInfo.Name;
                string   filename_noExtension = filename.Substring(0, filename.Length - fileInfo.Extension.Length);
                string   ffmpegDir            = Properties.Settings.Default["RootDirPath"].ToString() + @"\resources\ffmpeg";

                // FFmpeg parameters :
                // -i         -> ignore error
                // -f         -> output format
                // -ab        -> audio bitrate
                // -vn        -> don't include video

                // In cmd.exe, the command line would be :
                // start "" "path/to/youtube-dl.exe" [-options] "path/as/destination/name.extension" <youtube video url>

                commandLine = String.Format(
                    "/c start \"\" \"{0}\\bin\\ffmpeg.exe\" -i \"{1}\" -f mp3 -ab {2} -vn \"{3}\\Downloaded\\Audio\\{4}.mp3\"",
                    ffmpegDir,
                    filepath,
                    Properties.Settings.Default["AudioBitrate"].ToString(),
                    Properties.Settings.Default["RootDirPath"].ToString(),
                    filename_noExtension
                    );
                IOMethods.WriteToLog("Command line (audio) :\n" + commandLine);
            }
            catch (Exception ex)
            {
                IOMethods.WriteToLog("Erreur dans AudioExtraction_BuildCLI_From(string filepath). Exception =\n" + ex.ToString());
            }

            return(commandLine); // TODO : return filename too ?
        }