コード例 #1
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);
            }
        }
コード例 #2
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();
        }
コード例 #3
0
ファイル: settings.cs プロジェクト: mkuriel/PlaylistEditorTV
        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();
        }
コード例 #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;
            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();
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
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();
        }