From 12b04306286a7700450e1abea1325c07fcd972e2 Mon Sep 17 00:00:00 2001 From: Ceiling Waffle Date: Thu, 31 Dec 2020 08:27:05 +1100 Subject: [PATCH] Fix: Usernames not being generated (#25) --- CollectionManagerExtensionsDll/Modules/API/osu/OsuSite.cs | 8 ++++---- .../Modules/API/osu/OsuSiteTests.cs | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CollectionManagerExtensionsDll/Modules/API/osu/OsuSite.cs b/CollectionManagerExtensionsDll/Modules/API/osu/OsuSite.cs index bce0779..148113c 100644 --- a/CollectionManagerExtensionsDll/Modules/API/osu/OsuSite.cs +++ b/CollectionManagerExtensionsDll/Modules/API/osu/OsuSite.cs @@ -14,8 +14,8 @@ public class OsuSite private static readonly string parsingPage = "Getting page {0} of {1}"; private static readonly string parsingComplete = "Finished Processing of {0} pages"; - private static readonly string _baseUrl = "https://old.ppy.sh/p"; - private static readonly string UserPpRankingUrl = _baseUrl + "/pp/?m=0&s=3&o=1&f=0&page={0}"; + private static readonly string _baseUrl = "https://osu.ppy.sh/rankings/osu/performance"; + private static readonly string UserPpRankingUrl = _baseUrl + "?m=0&s=3&o=1&f=0&page={0}"; private static readonly int UsersPerPage = 50; public delegate void LogUsernameGeneration(string logMessage, int completionPrecentage); @@ -60,14 +60,14 @@ private List GetUsernamesFromPage(string pageContents, int startUserInde var usernames = new List(); if (pageContents.Length > 0) { - var match = Regex.Matches(pageContents, ".*?href=\'\\/u\\/(\\d+)\'>(.*)<\\/a>"); + var match = Regex.Matches(pageContents, ".*?href=\".*?\\/users\\/(\\d+)\\/osu\"\n.*\n.*\n.*\n.*>\n(.*)\n.*<\\/a>"); if (match.Count > 0) { for (int i = startUserIndex; i <= endUserIndex; i++) { var entry = match[i]; //var userId = entry.Groups[1].Value; - var username = entry.Groups[2].Value; + var username = entry.Groups[2].Value.Trim(); usernames.Add(username); } } diff --git a/CollectionManagerExtensionsDllTests/Modules/API/osu/OsuSiteTests.cs b/CollectionManagerExtensionsDllTests/Modules/API/osu/OsuSiteTests.cs index 8bf65be..2d0c876 100644 --- a/CollectionManagerExtensionsDllTests/Modules/API/osu/OsuSiteTests.cs +++ b/CollectionManagerExtensionsDllTests/Modules/API/osu/OsuSiteTests.cs @@ -3,7 +3,6 @@ namespace CollectionManagerExtensionsDll.Modules.API.osu.Tests { - [Ignore("old performance page is not avaliable anymore, url is now https://osu.ppy.sh/rankings/osu/performance")] [TestClass()] public class OsuSiteTests {