Пример #1
0
        public async Task <Result> GetNicoFeed(string status, string platform, bool titlePreset, int offset,
                                               int limit, string sort, string query,
                                               UserAuthenticationEntity userAuthenticationEntity)
        {
            var url = EndPoints.NicoNicoBaseUrl;

            // Sony's app hardcodes this value to 0.
            // This app could, in theory, allow for more polling of data, so these options are left open to new values and limits.
            if (!string.IsNullOrEmpty(query))
            {
                url += $"keyword={query}&";
            }
            url += $"offset={offset}&";
            url += $"limit={limit}&";
            url += $"status={status}&";
            url += $"sce_platform={platform}&";
            if (titlePreset)
            {
                url += "sce_title_preset=true&";
            }
            url += $"sort={sort}";
            // TODO: Fix this cheap hack to get around caching issue. For some reason, no-cache is not working...
            url += "&r=" + Guid.NewGuid();
            return(await _webManager.GetData(new Uri(url), userAuthenticationEntity));
        }
Пример #2
0
        public async Task <NicoNicoEntity> GetNicoFeed(string status, string platform, int offset, int limit, string sort,
                                                       UserAccountEntity userAccountEntity)
        {
            try
            {
                var url = EndPoints.NicoNicoBaseUrl;
                // Sony's app hardcodes this value to 0.
                // This app could, in theory, allow for more polling of data, so these options are left open to new values and limits.
                url += string.Format("offset={0}&", offset);
                url += string.Format("limit={0}&", limit);
                url += string.Format("status={0}&", status);
                url += string.Format("sce_platform={0}&", platform);
                url += string.Format("sort={0}", sort);
                // TODO: Fix this cheap hack to get around caching issue. For some reason, no-cache is not working...
                url += "&r=" + Guid.NewGuid();
                var result = await _webManager.GetData(new Uri(url), userAccountEntity);

                var nico = JsonConvert.DeserializeObject <NicoNicoEntity>(result.ResultJson);
                return(nico);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to get Nico Nico Douga feed", ex);
            }
        }
Пример #3
0
        public async Task <List <RegDate> > TotalRegistrations()
        {
            var uri    = new Uri(EndPoints.ViewRegistrations);
            var result = await _webManager.GetData(uri);

            return(JsonConvert.DeserializeObject <List <RegDate> >(result.ResultJson));
        }
Пример #4
0
        /// <summary>
        /// Search for GIFs.
        /// </summary>
        /// <param name="searchParameter">Required: Used to query the search engine.</param>
        /// <returns>A GifSearch Result object.</returns>
        public async Task <GiphySearchResult> GifSearch(SearchParameter searchParameter)
        {
            if (string.IsNullOrEmpty(searchParameter.Query))
            {
                throw new FormatException("Must set query in order to search.");
            }

            var nvc = new NameValueCollection();

            nvc.Add("api_key", _authKey);
            nvc.Add("q", searchParameter.Query);
            nvc.Add("limit", searchParameter.Limit.ToString());
            nvc.Add("offset", searchParameter.Offset.ToString());
            if (searchParameter.Rating != Rating.None)
            {
                nvc.Add("rating", searchParameter.Rating.ToFriendlyString());
            }
            if (!string.IsNullOrEmpty(searchParameter.Format))
            {
                nvc.Add("fmt", searchParameter.Format);
            }

            var result =
                await _webManager.GetData(new Uri($"{BaseUrl}{BaseGif}/search{UriExtensions.ToQueryString(nvc)}"));

            if (!result.IsSuccess)
            {
                throw new WebException($"Failed to get GIFs: {result.ResultJson}");
            }

            return(JsonConvert.DeserializeObject <GiphySearchResult>(result.ResultJson));
        }
Пример #5
0
        public async Task <List <PrivateMessageEntity> > GetPrivateMessages(int page)
        {
            var privateMessageEntities = new List <PrivateMessageEntity>();
            var url = Constants.PRIVATE_MESSAGES;

            if (page > 0)
            {
                url = Constants.PRIVATE_MESSAGES + string.Format(Constants.PAGE_NUMBER, page);
            }

            HtmlDocument doc = (await _webManager.GetData(url)).Document;

            HtmlNode forumNode =
                doc.DocumentNode.Descendants("tbody").FirstOrDefault();


            foreach (
                HtmlNode threadNode in
                forumNode.Descendants("tr"))
            {
                var threadEntity = new PrivateMessageEntity();
                threadEntity.Parse(threadNode);
                privateMessageEntities.Add(threadEntity);
            }
            return(privateMessageEntities);
        }
        public async Task <Result> GetMessageGroup(string username, UserAuthenticationEntity userAuthenticationEntity, string region = "jp", string language = "ja")
        {
            var url = string.Format(EndPoints.MessageGroup, region, username, language);

            url += "&r=" + Guid.NewGuid();
            return(await _webManager.GetData(new Uri(url), userAuthenticationEntity, language));
        }
        public async Task <Result> GetTrophyList(string comparedUser, string fromUser, int offset, UserAuthenticationEntity userAuthenticationEntity,
                                                 string region = "jp", string language = "ja")
        {
            var url = string.Format(EndPoints.TrophyList, region, language, offset, comparedUser, fromUser);

            url += "&r=" + Guid.NewGuid();
            return(await _webManager.GetData(new Uri(url), userAuthenticationEntity, language));
        }
Пример #8
0
        public async Task <List <Groups> > GetGenreGroupsAsync(int @group = 1)
        {
            var result = await _webManager.GetData(new Uri(string.Format(EndPoints.GenreGroup, group)));

            var entity = result.ResultXml.ParseXml <GroupEntity>();

            return(entity.Groups);
        }
Пример #9
0
        public async Task <Thumb> GetThumbInfoAsync(string videoId)
        {
            var result = await _webManager.GetData(new Uri(string.Format(EndPoints.ThumbInfo, videoId)));

            var entity = result.ResultXml.ParseXml <ThumbnailEntity>();

            return(entity.Thumbnail);
        }
Пример #10
0
        public async Task <string> GetSearchResults(String url)
        {
            try
            {
                string htmlBody = await PathIO.ReadTextAsync("ms-appx:///Assets/thread.html");

                var doc2 = new HtmlDocument();

                doc2.LoadHtml(htmlBody);

                HtmlNode bodyNode = doc2.DocumentNode.Descendants("body").FirstOrDefault();

                //inject this
                HtmlDocument doc = (await _webManager.GetData(url)).Document;

                HtmlNode searchNode =
                    doc.DocumentNode.Descendants("div")
                    .FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("inner"));
                url = string.Format("{0}search.php{1}", Constants.BASE_URL, searchNode.Descendants("a").FirstOrDefault().GetAttributeValue("href", string.Empty));

                doc = (await _webManager.GetData(url)).Document;
                var tableNode = doc.DocumentNode.Descendants("table")
                                .FirstOrDefault(node => node.GetAttributeValue("id", string.Empty).Contains("main_full"));

                tableNode.SetAttributeValue("style", "width: 100%");

                HtmlNode[] linkNodes = tableNode.Descendants("a").ToArray();

                if (!linkNodes.Any())
                {
                    // User has no items on their rap sheet, return nothing back.
                    return(string.Empty);
                }

                foreach (var linkNode in linkNodes)
                {
                    var divNode = HtmlNode.CreateNode(linkNode.InnerText);
                    linkNode.ParentNode.ReplaceChild(divNode.ParentNode, linkNode);
                }

                HtmlNode[] jumpPostsNodes = tableNode.Descendants("div").Where(node => node.GetAttributeValue("align", string.Empty).Equals("right")).ToArray();

                foreach (var jumpPost in jumpPostsNodes)
                {
                    jumpPost.Remove();
                }

                bodyNode.InnerHtml = tableNode.OuterHtml;
                return(WebUtility.HtmlDecode(WebUtility.HtmlDecode(doc2.DocumentNode.OuterHtml)));
            }
            catch (Exception)
            {
                // Person does not have platinum.
                return(string.Empty);
            }
        }
Пример #11
0
        public async Task <FrontPageWebArticleEntity> GetArticleMetaData(string url)
        {
            HtmlDocument articleDoc  = (await _webManager.GetData(url)).Document;
            string       articleHtml = await ParseArticleHtml(articleDoc);

            var frontPageArticleEntity = new FrontPageWebArticleEntity();

            frontPageArticleEntity.MapTo(WebUtility.HtmlDecode(articleHtml), 1);
            return(frontPageArticleEntity);
        }
Пример #12
0
        public async Task <FriendsEntity> GetFriendsList(string username, int?offset, bool blockedPlayer,
                                                         bool playedRecently, bool personalDetailSharing, bool friendStatus, bool requesting, bool requested,
                                                         bool onlineFilter, UserAccountEntity userAccountEntity)
        {
            try
            {
                var user = userAccountEntity.GetUserEntity();
                var url  = string.Format(EndPoints.FriendList, user.Region, username, offset);
                if (onlineFilter)
                {
                    url += "&filter=online";
                }
                if (friendStatus && !requesting && !requested)
                {
                    url += "&friendStatus=friend&presenceType=primary";
                }
                if (friendStatus && requesting && !requested)
                {
                    url += "&friendStatus=requesting";
                }
                if (friendStatus && !requesting && requested)
                {
                    url += "&friendStatus=requested";
                }
                if (personalDetailSharing && requested)
                {
                    url += "&friendStatus=friend&personalDetailSharing=requested&presenceType=primary";
                }
                if (personalDetailSharing && requesting)
                {
                    url += "&friendStatus=friend&personalDetailSharing=requesting&presenceType=primary";
                }
                if (playedRecently)
                {
                    url =
                        string.Format(
                            EndPoints.RecentlyPlayed, username);
                }
                if (blockedPlayer)
                {
                    url = string.Format("https://{0}-prof.np.community.playstation.net/userProfile/v1/users/{1}/blockList?fields=@default,@profile&offset={2}", user.Region, username, offset);
                }
                // TODO: Fix this cheap hack to get around caching issue. For some reason, no-cache is not working...
                url += "&r=" + Guid.NewGuid();
                var result = await _webManager.GetData(new Uri(url), userAccountEntity);

                var friend = JsonConvert.DeserializeObject <FriendsEntity>(result.ResultJson);
                return(friend);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Пример #13
0
        public async Task <Suggestion> GetSuggestions(string suggestion)
        {
            var result = await _webManager.GetData(new Uri(EndPoints.SearchSuggestion + suggestion));

            try
            {
                return(JsonConvert.DeserializeObject <Suggestion>(result.ResultXml));
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to get suggestions" + result.ResultXml, ex);
            }
        }
Пример #14
0
 public async Task <Result> GetUser(string userName, UserAuthenticationEntity userAuthenticationEntity,
                                    string region = "jp", string language = "ja")
 {
     try
     {
         var url = string.Format(EndPoints.User, region, userName);
         return(await _webManager.GetData(new Uri(url), userAuthenticationEntity, language));
     }
     catch (Exception exception)
     {
         throw new Exception("Error getting user", exception);
     }
 }
Пример #15
0
        public async Task <NicoliveVideoResponse> GetOnAirListAsync(int @from   = 0, int length = 50, string order = "a", string provider = "community",
                                                                    string sort = "start_time")
        {
            var result = await _webManager.GetData(new Uri(string.Format(EndPoints.OnAirList, from, length, order, provider, sort)));

            try
            {
                var live = JsonConvert.DeserializeObject <LiveVideo>(result.ResultXml);
                return(live.NicoliveVideoResponse);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to get live videos: " + result.ResultXml, ex);
            }
        }
Пример #16
0
        public async Task <SessionInviteEntity> GetSessionInvites(int offset, UserAccountEntity userAccountEntity)
        {
            try
            {
                var    user   = userAccountEntity.GetUserEntity();
                string url    = string.Format(EndPoints.SessionInformation, user.Region, user.OnlineId, user.Language, offset);
                var    result = await _webManager.GetData(new Uri(url), userAccountEntity);

                var sessionInvite = JsonConvert.DeserializeObject <SessionInviteEntity>(result.ResultJson);
                return(sessionInvite);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to get session invites", ex);
            }
        }
Пример #17
0
        public async Task <List <SmileCategoryEntity> > GetSmileList()
        {
            var smileCategoryList = new List <SmileCategoryEntity>();

            //inject this
            HtmlDocument doc = (await _webManager.GetData(Constants.SMILE_URL)).Document;

            IEnumerable <HtmlNode> smileCategoryTitles =
                doc.DocumentNode.Descendants("div")
                .FirstOrDefault(node => node.GetAttributeValue("class", string.Empty).Contains("inner"))
                .Descendants("h3");
            List <string> categoryTitles =
                smileCategoryTitles.Select(smileCategoryTitle => WebUtility.HtmlDecode(smileCategoryTitle.InnerText))
                .ToList();
            IEnumerable <HtmlNode> smileNodes =
                doc.DocumentNode.Descendants("ul")
                .Where(node => node.GetAttributeValue("class", string.Empty).Contains("smilie_group"));
            int smileCount = 0;

            foreach (HtmlNode smileNode in smileNodes)
            {
                var smileList = new List <SmileEntity>();
                IEnumerable <HtmlNode> smileIcons = smileNode.Descendants("li");
                foreach (HtmlNode smileIcon in smileIcons)
                {
                    var smileEntity = new SmileEntity();
                    smileEntity.Parse(smileIcon);
                    smileList.Add(smileEntity);
                }
                smileCategoryList.Add(new SmileCategoryEntity(categoryTitles[smileCount], smileList));
                smileCount++;
            }
            return(smileCategoryList);
        }
Пример #18
0
        public async Task <List <Avatar> > GetStaticAvatars()
        {
            var uri    = new Uri(EndPoints.GetAvatarList);
            var result = await _webManager.GetData(uri);

            return(JsonConvert.DeserializeObject <List <Avatar> >(result.ResultJson));
        }
Пример #19
0
        public async Task <Result> SearchForFriends(string query, UserAuthenticationEntity userAuthenticationEntity,
                                                    string region = "jp", string language = "ja")
        {
            var url = String.Format(EndPoints.FriendFinder, query);

            return(await _webManager.GetData(new Uri(url), userAuthenticationEntity, language));
        }
Пример #20
0
        public async Task <User> GetUserViaEmail(int id)
        {
            var uri    = new Uri(string.Format(EndPoints.GetUserViaId, id));
            var result = await _webManager.GetData(uri);

            return(JsonConvert.DeserializeObject <User>(result.ResultJson));
        }
Пример #21
0
        public async Task <UserEntity> GetCurrentUserInfoAsync()
        {
            var result = await _webManager.GetData(new Uri(EndPoints.UserCurrentInfo));

            if (!result.IsSuccess)
            {
                throw new Exception("Failed to Get User Info: " + result.ResultXml);
            }

            try
            {
                return(result.ResultXml.ParseXml <UserEntity>());
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to Login: " + result.ResultXml, ex);
            }
        }
        public async Task <Result> GetFriendsList(string username, int?offset, bool blockedPlayer,
                                                  bool playedRecently, bool personalDetailSharing, bool friendStatus, bool requesting, bool requested,
                                                  bool onlineFilter, UserAuthenticationEntity userAuthenticationEntity, string region = "jp", string language = "ja")
        {
            var url = string.Format(EndPoints.FriendList, region, username, offset);

            if (onlineFilter)
            {
                url += "&filter=online";
            }
            if (friendStatus && !requesting && !requested)
            {
                url += "&friendStatus=friend&presenceType=primary";
            }
            if (friendStatus && requesting && !requested)
            {
                url += "&friendStatus=requesting";
            }
            if (friendStatus && !requesting && requested)
            {
                url += "&friendStatus=requested";
            }
            if (personalDetailSharing && requested)
            {
                url += "&friendStatus=friend&personalDetailSharing=requested&presenceType=primary";
            }
            if (personalDetailSharing && requesting)
            {
                url += "&friendStatus=friend&personalDetailSharing=requesting&presenceType=primary";
            }
            if (playedRecently)
            {
                url =
                    string.Format(
                        EndPoints.RecentlyPlayed, username);
            }
            if (blockedPlayer)
            {
                url =
                    $"https://{region}-prof.np.community.playstation.net/userProfile/v1/users/{username}/blockList?fields=@default,@profile&offset={offset}";
            }
            url += "&r=" + Guid.NewGuid();
            return(await _webManager.GetData(new Uri(url), userAuthenticationEntity, language));
        }
Пример #23
0
        private async Task <WebManager.Result> SendLoginData(string sessionId)
        {
            var result = await _webManager.GetData(new Uri(string.Format(EndPoints.Login, sessionId)));

            if (result.IsSuccess)
            {
                _localSettings.Values["sessionId"] = sessionId;
            }
            return(result);
        }
Пример #24
0
        public async Task <ForumThreadEntity> GetThread(string url)
        {
            var forumThread = new ForumThreadEntity();

            WebManager.Result result = await _webManager.GetData(url);

            HtmlDocument doc = result.Document;

            try
            {
                forumThread.ParseFromThread(doc);
            }
            catch (Exception)
            {
                return(null);
            }
            var query = Extensions.ParseQueryString(url);

            if (!query.ContainsKey("postid"))
            {
                return(forumThread);
            }

            // If we are going to a post, it won't use #pti but instead uses the post id.

            forumThread.ScrollToPost       = Convert.ToInt32(query["postid"]);
            forumThread.ScrollToPostString = "#post" + query["postid"];
            return(forumThread);
        }
Пример #25
0
        public async Task <Result> GetActivityFeed(string userName, int?pageNumber, bool storePromo,
                                                   bool isNews, UserAuthenticationEntity userAuthenticationEntity, string region = "jp", string language = "ja")
        {
            var feedNews = isNews ? "news" : "feed";
            var url      = string.Format(EndPoints.RecentActivity, userName, feedNews, pageNumber);

            if (storePromo)
            {
                url += "&filters=STORE_PROMO";
            }
            url += "&r=" + Guid.NewGuid();
            return(await _webManager.GetData(new Uri(url), userAuthenticationEntity, language));
        }
Пример #26
0
        public async Task <UserSession> StartUserSessionAsync()
        {
            if (!_webManager.IsCookieContainerSet)
            {
                throw new Exception("You must log the user in and set the cookie container");
            }

            var result = await _webManager.GetData(new Uri(EndPoints.CreateSession));

            if (!result.IsSuccess)
            {
                throw new Exception("Failed to Create Session: " + result.ResultXml);
            }

            try
            {
                return(result.ResultXml.ParseXml <UserSession>());
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to Create Session: " + result.ResultXml, ex);
            }
        }
Пример #27
0
        public async Task <IEnumerable <PostIconCategoryEntity> > GetPostIcons(ForumEntity forum)
        {
            string url = string.Format(Constants.NEW_THREAD, forum.ForumId);

            WebManager.Result result = await _webManager.GetData(url);

            HtmlDocument doc = result.Document;

            HtmlNode[] pageNodes          = doc.DocumentNode.Descendants("div").Where(node => node.GetAttributeValue("class", string.Empty).Equals("posticon")).ToArray();
            var        postIconEntityList = new List <PostIconEntity>();

            foreach (var pageNode in pageNodes)
            {
                var postIconEntity = new PostIconEntity();
                postIconEntity.Parse(pageNode);
                postIconEntityList.Add(postIconEntity);
            }
            var postIconCategoryEntity = new PostIconCategoryEntity("Post Icon", postIconEntityList);
            var postIconCategoryList   = new List <PostIconCategoryEntity> {
                postIconCategoryEntity
            };

            return(postIconCategoryList);
        }
Пример #28
0
        public async Task <SearchResultsEntity> SearchForUsers(int offset, string query, UserAccountEntity userAccountEntity)
        {
            try
            {
                var url = string.Format(EndPoints.Search, offset, query);
                url += "&r=" + Guid.NewGuid();
                var result = await _webManager.GetData(new Uri(url), userAccountEntity);

                var search = JsonConvert.DeserializeObject <SearchResultsEntity>(result.ResultJson);
                return(search);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Пример #29
0
        public async Task <NotificationEntity> GetNotifications(string username, UserAccountEntity userAccountEntity)
        {
            try
            {
                var user   = userAccountEntity.GetUserEntity();
                var url    = string.Format(EndPoints.Notification, user.Region, username, user.Language);
                var result = await _webManager.GetData(new Uri(url), userAccountEntity);

                var notification = JsonConvert.DeserializeObject <NotificationEntity>(result.ResultJson);
                return(notification);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to get notification list", ex);
            }
        }
Пример #30
0
        public async Task <UserEntity> GetUser(string userName, UserAccountEntity userAccountEntity)
        {
            try
            {
                var    user = userAccountEntity.GetUserEntity();
                string url  = string.Format(EndPoints.User, user.Region, userName);
                url += "&r=" + Guid.NewGuid();
                var result = await _webManager.GetData(new Uri(url), userAccountEntity);

                var userEntity = JsonConvert.DeserializeObject <UserEntity>(result.ResultJson);
                return(userEntity);
            }
            catch (Exception ex)
            {
                throw new Exception("Error getting user", ex);
            }
        }