Exemple #1
0
        private void button_file_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            string openpath = Settings.Default.openpath;

            if (!string.IsNullOrEmpty(openpath) && !ClassHelp.MyDirectoryExists(openpath, 4000))
            {
                openpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\";
            }

            using (OpenFileDialog openFileDialog1 = new OpenFileDialog())
            {
                openFileDialog1.InitialDirectory = openpath;
                openFileDialog1.RestoreDirectory = false;

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Settings.Default.startfile = openFileDialog1.FileName;
                    textBox_start.Text         = openFileDialog1.FileName;
                }
                else  //cancel
                {
                    return;
                }

                Settings.Default.openpath = Path.GetDirectoryName(openFileDialog1.FileName);
                Settings.Default.Save();
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #2
0
        public static async Task Run(string link)
        {
            string kodiIP   = Properties.Settings.Default.rpi;
            string kodiUser = Properties.Settings.Default.username;
            string kodiPort = Properties.Settings.Default.port;

            //  string kodiPass = Properties.Settings.Default.password; https://stackoverflow.com/questions/12657792/how-to-securely-save-username-password-local
            byte[] plaintext = null;
            string kodiPass  = "";

            if (Properties.Settings.Default.cipher != null && Properties.Settings.Default.entropy != null)
            {
                plaintext = ProtectedData.Unprotect(Properties.Settings.Default.cipher, Properties.Settings.Default.entropy,
                                                    DataProtectionScope.CurrentUser);
                kodiPass = ClassHelp.ByteArrayToString(plaintext);
            }



            var values = new Dictionary <string, string>
            {
                { kodiUser, kodiPass }
            };

            string url = "http://" + kodiIP + ":" + kodiPort + "/jsonrpc?request=";


            //url = "http://192.168.178.91:8080/jsonrpc"; //?request=";

            try
            {
                var response = await Request(HttpMethod.Post, url, link, values);

                string responseText = await response.Content.ReadAsStringAsync();

                if (responseText.Contains("OK") /*&& link.Contains("Playlist.Add")*/)
                {
                    ClassHelp.PopupForm("Kodi response: OK", "green", 1800);
#if DEBUG
                    MessageBox.Show(responseText);
                    Console.WriteLine(responseText);
                    Console.ReadLine();
#endif
                }
                else if (responseText.Contains("error") /*&& link.Contains("Playlist.Add")*/)
                {
                    ClassHelp.PopupForm("Kodi response: ERROR", "red", 1300);
                }

                kodiPass = "";  //to be safe
            }
            catch (Exception ex)
            {
                MessageBox.Show("Kodi not responding. " + ex.Message, "Play", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #3
0
        public settings()
        {
            InitializeComponent();

            textBox2.Text         = Settings.Default.rpi;
            textBox_Port.Text     = Settings.Default.port;
            textBox_Username.Text = Settings.Default.username;

            checkBox_vlc.Checked = Settings.Default.vlc_fullsreen;
            checkBox_F2.Checked  = Settings.Default.F2_edit;

            textBox3.Text = Settings.Default.timeout.ToString();

            comboBox1.SelectedIndex       = Settings.Default.colSearch;
            comboBox2.SelectedIndex       = Settings.Default.colDupli;
            comboBoxSpeech.SelectedIndex  = Settings.Default.cobSpeech;
            comboBox_result.SelectedIndex = Settings.Default.findresult;
            textBox1.Text              = "0";
            textBox_userAgent.Text     = Settings.Default.user_agent;
            textBox_start.Text         = Settings.Default.startfile;
            checkBox_start.Checked     = Settings.Default.filestart;
            checkBox_autostart.Checked = Settings.Default.autoplayer;
            checkBox_hotkey.Checked    = Settings.Default.hotkey_enable;
            checkBox_scroll.Checked    = Settings.Default.scrollbar;

            double oopc = Settings.Default.opacity * 100.0;

            numericUpDown1.Value = (decimal)oopc;

            if (Settings.Default.Error403 == Color.LightSalmon)
            {
                comboBox_403.SelectedIndex = 0;
            }
            else
            {
                comboBox_403.SelectedIndex = 1;
            }

            nMaxThread.Value = Settings.Default.maxthread;

            //password
            if (Settings.Default.cipher != null && Settings.Default.entropy != null)
            {
                byte[] plaintext = ProtectedData.Unprotect(Settings.Default.cipher, Settings.Default.entropy,
                                                           DataProtectionScope.CurrentUser);
                textBox_Password.Text = ClassHelp.ByteArrayToString(plaintext);
            }
            else
            {
                textBox_Password.Text = "";
            }


            textBox_hot.Text = hotText;
            setHotkeyInt();
        }
Exemple #4
0
        public settings()
        {
            InitializeComponent();

            textBox2.Text         = Settings.Default.rpi;
            textBox_Port.Text     = Settings.Default.port;
            textBox_Username.Text = Settings.Default.username;

            checkBox_vlc.Checked = Settings.Default.vlc_fullsreen;
            checkBox_F2.Checked  = Settings.Default.F2_edit;

            // checkBox_plugin.Checked = Settings.Default.user_agent;

            comboBox1.SelectedIndex       = Settings.Default.colSearch;
            comboBox2.SelectedIndex       = Settings.Default.colDupli;
            comboBox_result.SelectedIndex = Settings.Default.findresult;
            textBox1.Text              = "0";
            textBox_userAgent.Text     = Settings.Default.user_agent;
            textBox_start.Text         = Settings.Default.startfile;
            checkBox_start.Checked     = Settings.Default.filestart;
            checkBox_autostart.Checked = Settings.Default.autoplayer;
            checkBox_hotkey.Checked    = Settings.Default.hotkey_enable;

            double oopc = Settings.Default.opacity * 100.0;

            //  textBox_opacity.Text = oopc.ToString();
            numericUpDown1.Value = (decimal)oopc;

            //double.TryParse(textBox_opacity.Text, out double opc);
            //Settings.Default.opacity = opc * 0.01;
            //textBox_opacity.Text = (Settings.Default.opacity * 100).ToString();

            //password
            if (Settings.Default.cipher != null && Settings.Default.entropy != null)
            {
                byte[] plaintext = ProtectedData.Unprotect(Settings.Default.cipher, Settings.Default.entropy,
                                                           DataProtectionScope.CurrentUser);
                textBox_Password.Text = ClassHelp.ByteArrayToString(plaintext);
            }
            else
            {
                textBox_Password.Text = "";
            }


            textBox_hot.Text = hotText;
            setHotkeyInt();
        }
        /// <summary>
        /// get name of downloaded video file
        /// </summary>
        /// <param name="output"></param>
        /// <param name="namecell"></param>
        /// <returns>full name of videofile with ext and path</returns>
        static string GetDownloadFileName(string output, string namecell)
        {
            string        fullName = "";
            DirectoryInfo hdDirectoryInWhichToSearch = new DirectoryInfo(output);

            FileInfo[] filesInDir = hdDirectoryInWhichToSearch.GetFiles("*.*");

            foreach (FileInfo foundFile in filesInDir)
            {
                if (ClassHelp.CalculateSimilarity(namecell, foundFile.Name) > 0.8) //compare only filename with youtube videoname
                {
                    fullName = foundFile.FullName;                                 //return filename with path
                    break;
                }
            }

            return(fullName);
        }
Exemple #6
0
        public settings()
        {
            InitializeComponent();

            textBox2.Text         = Settings.Default.rpi;
            textBox_Port.Text     = Settings.Default.port;
            textBox_Username.Text = Settings.Default.username;

            checkBox_vlc.Checked = Settings.Default.vlc_fullsreen;
            checkBox_F2.Checked  = Settings.Default.F2_edit;

            // checkBox_plugin.Checked = Settings.Default.user_agent;

            comboBox1.SelectedIndex    = Settings.Default.colSearch;
            comboBox2.SelectedIndex    = Settings.Default.colDupli;
            textBox1.Text              = "0";
            textBox_userAgent.Text     = Settings.Default.user_agent;
            textBox_start.Text         = Settings.Default.startfile;
            checkBox_start.Checked     = Settings.Default.filestart;
            checkBox_autostart.Checked = Settings.Default.autoplayer;



            //password
            if (Settings.Default.cipher != null && Settings.Default.entropy != null)
            {
                byte[] plaintext = ProtectedData.Unprotect(Settings.Default.cipher, Settings.Default.entropy,
                                                           DataProtectionScope.CurrentUser);
                textBox_Password.Text = ClassHelp.ByteArrayToString(plaintext);
            }
            else
            {
                textBox_Password.Text = "";
            }


            textBox_hot.Text = hotText;
            setHotkeyInt();
        }
        public static async Task <bool> Run2(string link)
        {
            string kodiIP   = Settings.Default.rpi;
            string kodiUser = Settings.Default.username.Trim();
            string kodiPort = Settings.Default.port;

            //  string kodiPass = Properties.Settings.Default.password; https://stackoverflow.com/questions/12657792/how-to-securely-save-username-password-local
            byte[] plaintext = null;
            string kodiPass  = "";

            if (Settings.Default.cipher != null && Settings.Default.entropy != null)
            {
                plaintext = ProtectedData.Unprotect(Settings.Default.cipher, Settings.Default.entropy,
                                                    DataProtectionScope.CurrentUser);
                kodiPass = ClassHelp.ByteArrayToString(plaintext);
            }

            kodiPass = kodiPass.Trim();

            var values = new Dictionary <string, string>
            {
                { kodiUser, kodiPass }
            };

            string url = "http://" + kodiIP + ":" + kodiPort + "/jsonrpc?request=";


            //url = "http://192.168.178.91:8080/jsonrpc"; //?request=";

            try
            {
                using (var webClient = new WebClient())
                {
                    // Required to prevent HTTP 401: Unauthorized messages
                    webClient.Credentials = new NetworkCredential(kodiUser, kodiPass);
                    // API Doc: http://kodi.wiki/view/JSON-RPC_API/v6
                    //  var json = "{\"jsonrpc\":\"2.0\",\"method\":\"GUI.ShowNotification\",\"params\":{\"title\":\"This is the title of the message\",\"message\":\"This is the body of the message\"},\"id\":1}";
                    string response = webClient.UploadString($"http://{kodiIP}:{kodiPort}/jsonrpc", "POST", link);

                    if (response.Contains("OK") /*&& link.Contains("Playlist.Add")*/)
                    {
                        ClassHelp.PopupForm("Kodi response: OK", "ok", 1300);

#if DEBUG
                        MessageBox.Show(response);
                        Console.WriteLine(response);
                        Console.ReadLine();
#endif
                    }
                    else if (response.Contains("error") /*&& link.Contains("Playlist.Add")*/)
                    {
                        ClassHelp.PopupForm("Kodi response: ERROR", "error", 1300);
                        return(false);
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Kodi not responding. " + ex.Message, "Play", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
        }
Exemple #8
0
        public settings()
        {
            InitializeComponent();

            textBox1.Text         = Settings.Default.server;
            textBox2.Text         = Settings.Default.rpi;
            textBox_Port.Text     = Settings.Default.port;
            textBox_Username.Text = Settings.Default.username;
            tBQuery.Text          = Settings.Default.SearchQuery;
            //textBox_output.Text = Properties.Settings.Default.output;

            //if (!string.IsNullOrEmpty(NativeMethods.GetFullPathFromWindows("youtube-dl.exe")) ||
            //  File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\youtube-dl.exe"))
            //{
            //    _youtube_dl = true; // File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\youtube-dl.exe");

            //}

            //password
            if (Settings.Default.cipher != null && Settings.Default.entropy != null)
            {
                byte[] plaintext = ProtectedData.Unprotect(Settings.Default.cipher, Settings.Default.entropy,
                                                           DataProtectionScope.CurrentUser);
                textBox_Password.Text = ClassHelp.ByteArrayToString(plaintext);
            }
            else
            {
                textBox_Password.Text = "";
            }


            // textBox_Password.Text = Properties.Settings.Default.password;
            // string vlcpath = Properties.Settings.Default.vlcpath;

            //if (!string.IsNullOrEmpty(vlcpath))
            //{
            //    tabPage4.Visible = true;  //vlc page
            //}
            //else if (string.IsNullOrEmpty(vlcpath))  //first run
            //{
            //    vlcpath = ClassHelp.GetVlcPath();
            //    if (string.IsNullOrEmpty(vlcpath)) tabPage4.Visible = false; //no vlc installed
            //}

            // _youtube_dl = ClassHelp.YT_dl();
            button_update.Visible = false;

            //if (_youtube_dl)
            //{
            //    button_update.Visible = true;
            //}
            //else
            //{
            //    button_update.Visible = false;
            //}



            comboBox1.SelectedIndex    = Settings.Default.colSearch;
            comboBox2.SelectedIndex    = Settings.Default.colDupli;
            comboBox_res.SelectedIndex = Settings.Default.maxres;
            //comboBox_audio.SelectedIndex = Properties.Settings.Default.comboaudio;
            //comboBox_video.SelectedIndex = Properties.Settings.Default.combovideo;
            checkBox_kodi.Checked = Settings.Default.kodi_hotkey;


            checkBox3.Checked = Settings.Default.useDash;
            //   if (!_youtube_dl) checkBox3.Checked = false;
            checkBox2.Checked = Settings.Default.replaceDrive;
            //  checkBox_verb.Checked = Properties.Settings.Default.verbose;

            comboBox_download.Items.Clear();

            foreach (object item in Settings.Default.combopathlist)
            {
                comboBox_download.Items.Add(item);
            }

            comboBox_download.SelectedIndex = 0;


            textBox_hot.Text  = hotText;
            textBox_hot2.Text = hotText2;
            setHotkeyInt();
        }
        /// <summary>
        /// opens cmd window and downloads video
        /// </summary>
        /// <param name="videolink">YT video link</param>
        /// <param name="NewPath">folder whee to write</param>
        /// <param name="videofilename">filename of downloaded video</param>
        /// <returns>filename of video in folder</returns>
        public static string DownloadYTLink(string videolink, string NewPath, string fpsValue, out string videofilename)
        {
            string[] height     = { "2160", "1440", "1080", "720", "480", "360" };
            string[] combovideo = { "", ",ext!=webm", ",ext=mp4", ",ext=mkv", "novideo" };
            string[] comboaudio = { "", "[ext=m4a]", "[ext=acc]", "[ext=ogg]" };

            int  maxres   = Settings.Default.maxres;
            int  cvideo   = Settings.Default.combovideo;
            int  caudio   = Settings.Default.comboaudio;
            bool _highfps = Settings.Default.fps;

            bool _verbose = Settings.Default.verbose;
            bool _formats = Settings.Default.showFormats;
            bool _allsubs = Settings.Default.allsubs;

            string output = Settings.Default.output;

            string highfps;

            if (_highfps)
            {
                highfps = "[fps" + fpsValue.Trim() + "]";
            }
            else
            {
                highfps = "";
            }


            if (string.IsNullOrEmpty(output) && string.IsNullOrEmpty(NewPath))
            {
                output = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            }
            else if (!string.IsNullOrEmpty(NewPath))
            {
                output = NewPath;
            }

            string filename = NativeMethods.GetFullPathFromWindows("youtube-dl.exe");

            if (string.IsNullOrEmpty(filename) /* && string.IsNullOrEmpty(NewPath)*/)
            {
                filename = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\youtube-dl.exe";
            }


            //  File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\youtube-dl.exe"))
            // _youtube_dl = true; // File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\youtube-dl.exe");



            string location = output + "\\%(title)s.%(ext)s";

            ////no cmd window
            ProcessStartInfo ps = new ProcessStartInfo();

            ps.ErrorDialog = false;

            if (!_verbose && !_formats)
            {
                ps.FileName = filename;
                if (cvideo == 4)                                                                                                //novideo
                {
                    ps.Arguments = " -f \"bestaudio" + comboaudio[caudio] + "\" \"" + videolink + "\" -o \"" + location + "\""; //-f "bestvideo[height<=720]+bestaudio" -g 2FcRM-p4koo
                }
                else
                {
                    //  --restrict-filenames  ??
                    ps.Arguments = " -f \"bestvideo[height<=" + height[maxres] + combovideo[cvideo] + "]" + highfps + "+bestaudio" + comboaudio[caudio] + "/best" + comboaudio[caudio] + "/best\" \"" + videolink + "\" -o \"" + location + "\"";  //-f "bestvideo[height<=720]+bestaudio" -g 2FcRM-p4koo
                    if (_allsubs)
                    {
                        ps.Arguments += " --all-subs --write-auto-sub --sub-lang en";
                    }
                }
            }
            else if (_verbose)
            {
                ps.FileName = "CMD";
                // filename = filename.Replace(@"\\", @"\");
                // ps.Arguments = "/K youtube-dl.exe -f \"bestvideo[height<=" + height[maxres] + "]+bestaudio[ext=m4a]/best[ext=mp4]/best\" " + videolink + " -o \"" + output + "\"";
                // ps.Arguments = "/K \""+filename.Replace(@"\\", @"\") + "\" -f \"bestvideo[height<=" + height[maxres] + combovideo[cvideo] + "]+bestaudio" + comboaudio[caudio] + "/best" + comboaudio[caudio] + "/best\" \"" + videolink + "\" -o \"" + output + "\" --verbose";  //-f "bestvideo[height<=720]+bestaudio" -g 2FcRM-p4koo
                if (cvideo == 4)                                                                                                                 //novideo
                {
                    ps.Arguments = "/K youtube-dl.exe -f \"bestaudio" + comboaudio[caudio] + "\" \"" + videolink + "\" -o \"" + location + "\""; //-f "bestvideo[height<=720]+bestaudio" -g 2FcRM-p4koo
                }
                else
                {
                    ps.Arguments = "/K youtube-dl.exe -f \"bestvideo[height<=" + height[maxres] + combovideo[cvideo] + "]" + highfps + "+bestaudio" + comboaudio[caudio] + "/best" + comboaudio[caudio] + "/best\" \"" + videolink + "\" -o \"" + location + "\" --verbose"; //-f "bestvideo[height<=720]+bestaudio" -g 2FcRM-p4koo
                    if (_allsubs)
                    {
                        ps.Arguments += " --write-subs --write-auto-sub --sub-lang en";
                    }
                }
            }
            else if (_formats)
            {
                ps.FileName  = "CMD";
                ps.Arguments = "/K youtube-dl.exe --list-formats " + videolink; //-f "bestvideo[height<=720]+bestaudio" -g 2FcRM-p4koo
                // if (_allsubs) ps.Arguments += " --list-subs";
                ps.CreateNoWindow         = false;                              //false; // comment this out
                ps.UseShellExecute        = false;                              // true
                ps.RedirectStandardOutput = false;                              // false
                ps.RedirectStandardError  = false;

                using (Process proc = new Process())
                {
                    proc.StartInfo = ps;
                    proc.Start();
                    proc.WaitForExit();
                }

                return(videofilename = "false");
            }

            ps.CreateNoWindow         = false; //false; // comment this out
            ps.UseShellExecute        = false; // true
            ps.RedirectStandardOutput = false; // false
            ps.RedirectStandardError  = false;

            using (Process proc = new Process())
            {
                proc.StartInfo = ps;
                proc.Start();
                //  proc.BeginOutputReadLine();
                //    if (proc != null && !proc.HasExited)
                proc.WaitForExit();
                //    //proc.BeginOutputReadLine(); // Comment this out
            }


            return(videofilename = GetDownloadFileName(output, ClassHelp.GetTitle_html(videolink)));
        }