Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ObservableCollection<InboxFeedViewModel> ParseInboxFeed(string HTMLCode)
- {
- ObservableCollection<InboxFeedViewModel> observableCollection = new ObservableCollection<InboxFeedViewModel>();
- string text = "<ul class=\"activity\">";
- string value = "</ul>";
- int num = 0;
- int num2;
- while ((num2 = HTMLCode.IndexOf(text, num)) != -1)
- {
- num = num2 + text.Length;
- int num3 = HTMLCode.IndexOf(value, num);
- string text2 = HTMLCode.Substring(num, num3 - num).Trim();
- int num4 = 0;
- int count = new Regex("<li").Matches(text2).Count;
- for (int i = 1; i <= count; i++)
- {
- num4 = text2.IndexOf("<li", num4);
- int num5 = text2.IndexOf("</li>", num4);
- string input = text2.Substring(num4, num5 - num4).Trim();
- Match match = Regex.Match(input, "<li class=\\\"(?<GroupName>[a-zA-Z0-9\\w\\s\\-]+?)\"\\>");
- if (match.Success)
- {
- string value2 = match.Groups["GroupName"].Value;
- InboxFeedViewModel inboxFeedViewModel = new InboxFeedViewModel();
- Match match2 = Regex.Match(input, "<p class=\\\"timestamp\\\" data-timestamp=\\\"(?<TimeStamp>[0-9]+?)\\\">(?<RelativeTime>[a-zA-Z0-9\\w\\s\\-]+?)</p>\\n");
- Match match3 = Regex.Match(input, "<a class=\\\"single-image profile-pic thumbnail\\\" href=\\\"instagram://user\\?username=(?<UserName>[a-zA-Z0-9_]+?)\\\"><img aria-label=\\\"(?<UserNameDesc>[a-zA-Z0-9_ ]+?)\\\" src=\\\"(?<URL>[a-zA-Z0-9:/._]+?)\\\" onerror=");
- Match match4 = Regex.Match(input, "/profiles/profile_(?<UserId>[0-9]+?)_");
- Match match5 = Regex.Match(input, "<a class=\\\"thumbnail gutter single-image\\\" href=\\\"instagram://media\\?id=(?<MediaId>[a-zA-Z0-9_]+?)\\\"><img src=\\\"(?<URL>[a-zA-Z0-9:/._]+?)\\\"/></a>");
- if (value2 == "fb-contact-joined-activity group gutter")
- {
- if (match2.Success && match3.Success)
- {
- inboxFeedViewModel.timestamp = long.Parse(match2.Groups["TimeStamp"].Value);
- inboxFeedViewModel.TimeStampRelative = match2.Groups["RelativeTime"].Value;
- inboxFeedViewModel.ImageFromURL = match3.Groups["URL"].Value;
- inboxFeedViewModel.Username = match3.Groups["UserName"].Value;
- inboxFeedViewModel.UsernameDesc = match3.Groups["UserNameDesc"].Value;
- if (match5.Success)
- {
- inboxFeedViewModel.OptionalMediaId = match5.Groups["MediaId"].Value;
- inboxFeedViewModel.ImageToURL = match5.Groups["URL"].Value;
- }
- inboxFeedViewModel.ProfileId = match4.Groups["UserId"].Value;
- string a;
- if ((a = value2) != null)
- {
- if (!(a == "group no-media follow-activity"))
- {
- if (!(a == "group no-media follow-activity hidden"))
- {
- if (!(a == "like-activity group"))
- {
- if (!(a == "mention-activity group gutter"))
- {
- if (!(a == "comment-activity group"))
- {
- if (a == "fb-contact-joined-activity group gutter")
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.None;
- inboxFeedViewModel.PostDesc = " joined Instagram";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Comment;
- inboxFeedViewModel.PostDesc = " left a comment on your photo.";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Mention;
- inboxFeedViewModel.PostDesc = " mentioned you in a comment.";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Like;
- inboxFeedViewModel.PostDesc = " liked your photo.";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Follow;
- inboxFeedViewModel.PostDesc = " started following you.";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Follow;
- inboxFeedViewModel.PostDesc = " started following you.";
- }
- }
- observableCollection.Add(inboxFeedViewModel);
- }
- }
- else
- {
- if (match2.Success && match3.Success && match4.Success)
- {
- inboxFeedViewModel.timestamp = long.Parse(match2.Groups["TimeStamp"].Value);
- inboxFeedViewModel.TimeStampRelative = match2.Groups["RelativeTime"].Value;
- inboxFeedViewModel.ImageFromURL = match3.Groups["URL"].Value;
- inboxFeedViewModel.Username = match3.Groups["UserName"].Value;
- inboxFeedViewModel.UsernameDesc = match3.Groups["UserNameDesc"].Value;
- if (match5.Success)
- {
- inboxFeedViewModel.OptionalMediaId = match5.Groups["MediaId"].Value;
- inboxFeedViewModel.ImageToURL = match5.Groups["URL"].Value;
- }
- inboxFeedViewModel.ProfileId = match4.Groups["UserId"].Value;
- string a2;
- if ((a2 = value2) != null)
- {
- if (!(a2 == "group no-media follow-activity"))
- {
- if (!(a2 == "group no-media follow-activity hidden"))
- {
- if (!(a2 == "like-activity group"))
- {
- if (!(a2 == "mention-activity group gutter"))
- {
- if (!(a2 == "comment-activity group"))
- {
- if (a2 == "fb-contact-joined-activity group gutter")
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.None;
- inboxFeedViewModel.PostDesc = " joined Instagram";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Comment;
- inboxFeedViewModel.PostDesc = " left a comment on your photo.";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Mention;
- inboxFeedViewModel.PostDesc = " mentioned you in a comment.";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Like;
- inboxFeedViewModel.PostDesc = " liked your photo.";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Follow;
- inboxFeedViewModel.PostDesc = " started following you.";
- }
- }
- else
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Follow;
- inboxFeedViewModel.PostDesc = " started following you.";
- }
- }
- observableCollection.Add(inboxFeedViewModel);
- }
- }
- }
- if (num4 <= 0)
- {
- num4 += num5;
- }
- else
- {
- num4 = num5;
- }
- }
- }
- return observableCollection;
- }
- public ObservableCollection<InboxFeedViewModel> ParseRequestFeed(string HTMLCode)
- {
- ObservableCollection<InboxFeedViewModel> observableCollection = new ObservableCollection<InboxFeedViewModel>();
- string text = "<ul class=\"activity friend-requests\">";
- string value = "</ul>";
- int num = 0;
- int num2;
- while ((num2 = HTMLCode.IndexOf(text, num)) != -1)
- {
- num = num2 + text.Length;
- int num3 = HTMLCode.IndexOf(value, num);
- string text2 = HTMLCode.Substring(num, num3 - num).Trim();
- int num4 = 0;
- int count = new Regex("<li").Matches(text2).Count;
- for (int i = 1; i <= count; i++)
- {
- num4 = text2.IndexOf("<li", num4);
- int num5 = text2.IndexOf("</li>", num4);
- string input = text2.Substring(num4, num5 - num4).Trim();
- Match match = Regex.Match(input, "<li class=\\\"(?<GroupName>[a-zA-Z0-9\\w\\s\\-]+?)\"\\>");
- if (match.Success)
- {
- string value2 = match.Groups["GroupName"].Value;
- InboxFeedViewModel inboxFeedViewModel = new InboxFeedViewModel();
- Match match2 = Regex.Match(input, "<a class=\\\"single-image profile-pic thumbnail\\\" href=\\\"instagram://user\\?username=(?<UserName>[a-zA-Z0-9_]+?)\\\"><img aria-label=\\\"(?<UserNameDesc>[a-zA-Z0-9_ ]+?)\\\" src=\\\"(?<URL>[a-zA-Z0-9:/._]+?)\\\" onerror=");
- Match match3 = Regex.Match(input, "/profiles/profile_(?<UserId>[0-9]+?)_");
- Match match4 = Regex.Match(input, "<a class=\\\"thumbnail gutter single-image\\\" href=\\\"instagram://media\\?id=(?<MediaId>[a-zA-Z0-9_]+?)\\\"><img src=\\\"(?<URL>[a-zA-Z0-9:/._]+?)\\\"/></a>");
- if (match2.Success && match3.Success)
- {
- inboxFeedViewModel.ImageFromURL = match2.Groups["URL"].Value;
- inboxFeedViewModel.Username = match2.Groups["UserName"].Value;
- inboxFeedViewModel.UsernameDesc = match2.Groups["UserNameDesc"].Value;
- if (match4.Success)
- {
- inboxFeedViewModel.OptionalMediaId = match4.Groups["MediaId"].Value;
- inboxFeedViewModel.ImageToURL = match4.Groups["URL"].Value;
- }
- inboxFeedViewModel.ProfileId = match3.Groups["UserId"].Value;
- string a;
- if ((a = value2) != null && a == "group")
- {
- inboxFeedViewModel.EnumType = InboxFeedTypeEnum.Follow;
- inboxFeedViewModel.PostDesc = inboxFeedViewModel.Username + " requests to follow you.";
- }
- observableCollection.Add(inboxFeedViewModel);
- }
- }
- if (num4 <= 0)
- {
- num4 += num5;
- }
- else
- {
- num4 = num5;
- }
- }
- }
- return observableCollection;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement