Exemplo n.º 1
0
        static private void doLoginFromCLI(WebClient wc, RootFormInterface rfi)
        {
            var args = rfi.GetLaunchArgs();

            wc.Credentials = new NetworkCredential(args["username"], args["password"]);
            wc.Headers[HttpRequestHeader.Authorization] = string.Format(
                "Basic {0}",
                Convert.ToBase64String(Encoding.ASCII.GetBytes(args["username"] + ":" + args["password"]))
                );
            rfi.SetRefreshMethod(RefreshMethod.LoginCLI);
        }
Exemplo n.º 2
0
        public static string doMetaLogin(RootFormInterface rfi)
        {
            var args = rfi.GetLaunchArgs();

            using (WebClient wc = new System.Net.WebClient())
            {
                string  parseME = null;
                Boolean fail    = false;
                do
                {
                    try
                    {
                        if (!fail && args.ContainsKey("username") && args.ContainsKey("password"))
                        {
                            doLoginFromCLI(wc, rfi);
                        }
                        else
                        {
                            Login loginform = new Login();
                            loginform.ShowDialog();
                            if (loginform.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                            {
                                rfi.CloseForm();
                                return(parseME);
                            }
                            if (loginform.XmlUri == null)
                            {
                                wc.Credentials = loginform.creds;
                                wc.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", loginform.headerAuth);
                                rfi.SetRefreshMethod(RefreshMethod.Login);
                            }
                            else
                            {
                                return(doServerXmlLogin(loginform.XmlUri, rfi));
                            }
                        }
                        parseME = wc.DownloadString("https://plex.tv/pms/servers.xml");
                        wc.Headers["X-Plex-Client-Identifier"] = Descriptor.GUID;
                        Descriptor.myToken = parseLogin(wc.UploadString("https://plex.tv/users/sign_in.xml", String.Empty));
                        fail = false;
                    }
                    catch (Exception)
                    {
                        fail = true;
                    }
                } while (fail);
                return(parseME);
            }
        }
Exemplo n.º 3
0
 static public string doTokenLogin(string token, RootFormInterface rfi)
 {
     using (WebClient wc = new System.Net.WebClient())
     {
         string result;
         Descriptor.myToken = token;
         try
         {
             result = wc.DownloadString("https://plex.tv/pms/servers.xml" + "?X-Plex-Token=" + Descriptor.myToken);
             rfi.SetRefreshMethod(RefreshMethod.Token);
         }
         catch
         {
             return(null);
         }
         return(result);
     }
 }
Exemplo n.º 4
0
 static public string doServerXmlLogin(string server_xml, RootFormInterface rfi)
 {
     using (WebClient wc = new System.Net.WebClient())
     {
         string result;
         try
         {
             result = wc.DownloadString(server_xml);
             rfi.SetRefreshMethod(RefreshMethod.ServerXmlUrl);
             Descriptor.sourceXmlUrl = server_xml;
         }
         catch
         {
             return(null);
         }
         return(result);
     }
 }