Beispiel #1
0
        public bool LoginWithUsername()
        {
            var userName = Config.GetParameterValue("Username") as string;
            var password = Config.GetParameterValue("Password") as string;

            if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(password))
            {
                IsAnonymous = true;
                return(true);
            }
            NickName = userName;

            var authString = String.Format(@"{{""email"":""{0}"",""password"":""{1}""}}", userName, password);

            SetCommonHeaders();
            var authToken = this.With(x => loginWebClient.Upload("https://api.gaminglive.tv/auth/session", authString))
                            .With(x => JToken.Parse(x))
                            .With(x => x.Value <string>("authToken"));

            if (authToken == null)
            {
                Log.WriteError("Login to gaminglive.tv failed.");
                return(false);
            }
            else
            {
                IsAnonymous = false;
                Config.SetParameterValue("AuthToken", authToken);
                Config.SetParameterValue("AuthTokenCredentials", userName + password);
                return(LoginWithToken());
            }
        }
Beispiel #2
0
        private bool LoginWithUsername()
        {
            var userName = Config.GetParameterValue("Username") as string;
            var password = Config.GetParameterValue("Password") as string;

            if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(password))
            {
                IsAnonymous = true;
                ResetAuthData();
                return(true);
            }

            NickName = userName;

            var authString = String.Format(@"nickname={0}&password={1}&remember=1", HttpUtility.UrlEncode(userName), HttpUtility.UrlEncode(password));

            webClient.ContentType = ContentType.UrlEncoded;
            webClient.Headers["X-Requested-With"] = "XMLHttpRequest";

            webClient.Upload(@"http://goodgame.ru/ajax/login/", authString);
            var authToken = webClient.CookieValue("PHPSESSID", "http://goodgame.ru");
            var uid       = webClient.CookieValue("uid", "http://goodgame.ru");

            if (String.IsNullOrWhiteSpace(authToken))
            {
                Log.WriteError("Login to goodgame.ru failed. Joining anonymously");
                IsAnonymous = true;
                ResetAuthData();
                return(false);
            }
            else
            {
                Config.SetParameterValue("AuthToken", authToken);
                Config.SetParameterValue("AuthTokenCredentials", userName + password);
                Config.SetParameterValue("UserId", uid);
                if (!String.IsNullOrEmpty(uid) && uid != "0")
                {
                    return(LoginWithToken());
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #3
0
        public bool SetTopic()
        {
            GetProfileData();

            if (profileFormParams == null || !Status.IsLoggedIn)
            {
                return(false);
            }

            String param       = "a=save_profile&channel_game={0}&channel_desc={1}&channel={2}&display_name={3}&channel_name={4}";
            var    displayName = profileFormParams.Where(k => k.Key.StartsWith("display_name_", StringComparison.CurrentCultureIgnoreCase)).Select(v => v.Value).FirstOrDefault();
            var    channelName = profileFormParams.Where(k => k.Key.StartsWith("channel_name_", StringComparison.CurrentCultureIgnoreCase)).Select(v => v.Value).FirstOrDefault();

            if (String.IsNullOrEmpty(displayName))
            {
                displayName = NickName;
            }

            loginWebClient.ContentType = ContentType.UrlEncodedUTF8;
            loginWebClient.Headers["X-Requested-With"] = "XMLHttpRequest";

            Info.CurrentGame.Id = webGameList.FirstOrDefault(game => game.Value.Equals(Info.CurrentGame.Name, StringComparison.InvariantCultureIgnoreCase)).Key;

            loginWebClient.Upload(String.Format(@"http://cybergame.tv/my_profile_edit/?mode=async&rand={0}", Time.UnixTimestamp()),
                                  String.Format(param, Info.CurrentGame.Id, HttpUtility.UrlEncode(Info.Topic), webChannelId, HttpUtility.UrlEncode(displayName), HttpUtility.UrlEncode(channelName)));


            var content = loginWebClient.Download(String.Format(@"http://cybergame.tv/my_profile_edit/?rand={0}", Time.UnixTimestamp()));

            Info.Topic            = Html.GetInnerText(@"//textarea[@name='channel_desc']", content);
            Info.CurrentGame.Name = Html.GetSiblingInnerText(@"//select/option[@selected='selected']", content);


            loginWebClient.ContentType = ContentType.UrlEncodedUTF8;

            content = loginWebClient.Download(String.Format(@"http://cybergame.tv/my_profile_edit/?rand={0}", Time.UnixTimestamp()));
            if (Info.Topic.Equals(Html.GetInnerText(@"//textarea[@name='channel_desc']", content)) &&
                Info.CurrentGame.Name.Equals(Html.GetSiblingInnerText(@"//select/option[@selected='selected']", content)))
            {
                return(true);
            }

            return(false);
        }
Beispiel #4
0
        public bool LoginWithUsername()
        {
            var userName = Config.GetParameterValue("Username") as string;
            var password = Config.GetParameterValue("Password") as string;

            if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(password))
            {
                IsAnonymous = true;
                return(true);
            }

            NickName = userName;

            var authString = String.Format(@"{{""login"":""{0}"",""pass"":""{1}"",""rememberme"":""""}}", userName, password);

            SetCommonHeaders();
            var authToken = this.With(x => loginWebClient.Upload("http://www.hitbox.tv/api/auth/login", authString))
                            .With(x => String.IsNullOrWhiteSpace(x) ? null : x)
                            .With(x => JToken.Parse(x))
                            .With(x => x.Value <string>("authToken"));

            if (authToken == null)
            {
                Log.WriteError("Login to hitbox.tv failed. Joining anonymously");
                IsAnonymous = true;
                Config.SetParameterValue("AuthTokenCredentials", String.Empty);
                return(false);
            }
            else
            {
                IsAnonymous = false;
                Config.SetParameterValue("AuthToken", authToken);
                Config.SetParameterValue("AuthTokenCredentials", userName + password);

                return(LoginWithToken());
            }
        }
Beispiel #5
0
        public bool LoginWithUsername()
        {
            var userName = Config.GetParameterValue("Username") as string;
            var password = Config.GetParameterValue("Password") as string;

            if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(password) || userName.Equals(AnonymousNickName, StringComparison.InvariantCultureIgnoreCase))
            {
                IsAnonymous = true;
                return(true);
            }

            if (Regex.IsMatch(userName, @"justinfan\d+"))
            {
                AnonymousNickName = userName;
            }

            NickName = userName;

            webClient.SetCookie("api_token", null, "twitch.tv");
            webClient.SetCookie("csrf_token", null, "twitch.tv");

            var csrfToken = this.With(x => webClient.Download("http://www.twitch.tv/login"))
                            .With(x => Re.GetSubString(x, @"^.*authenticity_token.*?value=""(.*?)"""));


            if (csrfToken == null)
            {
                Log.WriteError("Twitch: Can't get CSRF token. Twitch web layout changed ?");
                return(false);
            }
            string csrf_cookie = csrfToken;

            if (csrf_cookie.Substring(csrf_cookie.Length - 1).Equals("="))
            {
                csrf_cookie = csrf_cookie.Substring(0, csrf_cookie.Length - 1) + "%3D";
            }

            webClient.SetCookie("csrf_token", csrf_cookie, "twitch.tv");
            webClient.ContentType = ContentType.UrlEncoded;
            webClient.Headers["X-Requested-With"] = "XMLHttpRequest";
            webClient.Headers["X-CSRF-Token"]     = csrfToken;
            webClient.Headers["Accept"]           = "text/html, application/xhtml+xml, */*";

            var apiToken = this.With(x => webClient.Upload("https://secure.twitch.tv/user/login", String.Format(
                                                               "utf8=%E2%9C%93&authenticity_token={0}%3D&redirect_on_login=&embed_form=false&user%5Blogin%5D={1}&user%5Bpassword%5D={2}",
                                                               csrfToken,
                                                               userName,
                                                               password)))
                           .With(x => webClient.CookieValue("api_token", "http://twitch.tv"));

            if (String.IsNullOrWhiteSpace(apiToken))
            {
                Log.WriteError("Twitch: Can't get API token");
                return(false);
            }
            webClient.Headers["Twitch-Api-Token"] = apiToken;
            webClient.Headers["X-CSRF-Token"]     = csrfToken;
            webClient.Headers["Accept"]           = "*/*";

            if (apiToken == null)
            {
                Log.WriteError("Login to twitch.tv failed. Joining anonymously");
                IsAnonymous = true;
                return(false);
            }
            else
            {
                var oauthToken = this.With(x => webClient.Download("http://api.twitch.tv/api/me?on_site=1"))
                                 .With(x => JToken.Parse(x))
                                 .With(x => x.Value <string>("chat_oauth_token"));

                if (String.IsNullOrWhiteSpace(oauthToken))
                {
                    Log.WriteError("Login to twitch.tv failed. Joining anonymously");
                    IsAnonymous = true;
                    return(false);
                }

                IsAnonymous = false;
                Config.SetParameterValue("OAuthToken", oauthToken);
                Config.SetParameterValue("ApiToken", apiToken);
                Config.SetParameterValue("AuthTokenCredentials", userName + password);

                return(LoginWithToken());
            }
        }