From c2b2a4605d99e124f80d14e177c411963c22b955 Mon Sep 17 00:00:00 2001 From: Nam Le Date: Wed, 2 Sep 2026 19:43:33 +0700 Subject: [PATCH] paging steam purchase date import --- .../Services/SteamLicenseService.cs | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/source/Generic/PurchaseDateImporter/Services/SteamLicenseService.cs b/source/Generic/PurchaseDateImporter/Services/SteamLicenseService.cs index f8bcd7c7d..9dc0131a4 100644 --- a/source/Generic/PurchaseDateImporter/Services/SteamLicenseService.cs +++ b/source/Generic/PurchaseDateImporter/Services/SteamLicenseService.cs @@ -42,31 +42,43 @@ public static List GetLicenses() { var licensesList = new List(); var licensesRegex = @"(?:)(.*?(?=<\/td>))(?:<\/td>\s+)(?:\s+
(?:[\s\S]*?(?=<\/div>))<\/div>)?(?:\s+)([^\t]+)"; - var licensePageSource = GetLicensesPageContent(); - if (licensePageSource.IsNullOrEmpty()) + var continuationTokenRegex = @"license_paginator_next""\s+href=""\?continuationToken=([^""&]+)"; + var continuationToken = string.Empty; + while (true) { - return licensesList; - } + var licensePageSource = GetLicensesPageContent(continuationToken, 0); // They don't care what the offset is + if (licensePageSource.IsNullOrEmpty()) + { + break; + } - var licenseMatches = Regex.Matches(licensePageSource, licensesRegex); - if (licenseMatches.Count == 0) - { - return licensesList; - } + var licenseMatches = Regex.Matches(licensePageSource, licensesRegex); + if (licenseMatches.Count == 0) + { + break; + } - foreach (Match licenseMatch in licenseMatches) - { - licensesList.Add(new LicenseData(licenseMatch.Groups[2].Value.HtmlDecode(), DateTime.Parse(licenseMatch.Groups[1].Value))); + foreach (Match licenseMatch in licenseMatches) + { + licensesList.Add(new LicenseData(licenseMatch.Groups[2].Value.HtmlDecode(), DateTime.Parse(licenseMatch.Groups[1].Value))); + } + + var continuationTokenMatches = Regex.Match(licensePageSource, continuationTokenRegex); + if (!continuationTokenMatches.Success) + { + break; + } + continuationToken = continuationTokenMatches.Groups[1].Value; } return licensesList; } - private static string GetLicensesPageContent() + private static string GetLicensesPageContent(string continuationToken, uint offset) { using (var webView = Playnite.SDK.API.Instance.WebViews.CreateOffscreenView()) { - webView.NavigateAndWait("https://store.steampowered.com/account/licenses/?l=english"); + webView.NavigateAndWait(string.Format("https://store.steampowered.com/account/licenses/?l=english&continuationToken={0}&offset={1}", continuationToken, offset)); return webView.GetPageSource(); } }