From b36483620de5be3f4d1625e1aad4b4e9434909af Mon Sep 17 00:00:00 2001 From: Citrinate Date: Thu, 23 May 2024 14:36:28 -0400 Subject: [PATCH] Improve filtering of invalid apps and packages --- FreePackages/Data/FilterablePackage.cs | 8 +++++++- FreePackages/Handlers/PackageFilter.cs | 6 ------ FreePackages/Handlers/PackageHandler.cs | 2 +- FreePackages/Handlers/PackageQueue.cs | 18 +++++++++++------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/FreePackages/Data/FilterablePackage.cs b/FreePackages/Data/FilterablePackage.cs index 5227b46..85b16a1 100644 --- a/FreePackages/Data/FilterablePackage.cs +++ b/FreePackages/Data/FilterablePackage.cs @@ -5,7 +5,7 @@ namespace FreePackages { internal sealed class FilterablePackage { - internal bool IsNew; + internal bool IsNew; // This is used when finding DLC for new games added to account, and is not related to any Steam package property internal List PackageContents = new(); internal HashSet PackageContentIDs; internal HashSet PackageContentParentIDs = new(); @@ -111,6 +111,12 @@ internal bool IsAvailable() { return false; } + if (ID == 17906) { + // Special case: Anonymous Dedicated Server Comp (https://steamdb.info/sub/17906/) + // This always returns AccessDenied/InvalidPackage + return false; + } + return true; } diff --git a/FreePackages/Handlers/PackageFilter.cs b/FreePackages/Handlers/PackageFilter.cs index 703d728..2dbf9db 100644 --- a/FreePackages/Handlers/PackageFilter.cs +++ b/FreePackages/Handlers/PackageFilter.cs @@ -210,12 +210,6 @@ internal bool IsAppFreeAndValidOnStore(AppDetails? appDetails) { return false; } - bool isComingSoon = appDetails?.Data?.ReleaseDate?.ComingSoon ?? true; - if (isComingSoon) { - // App is not released yet - return false; - } - return true; } diff --git a/FreePackages/Handlers/PackageHandler.cs b/FreePackages/Handlers/PackageHandler.cs index 2c62cbc..09d8993 100644 --- a/FreePackages/Handlers/PackageHandler.cs +++ b/FreePackages/Handlers/PackageHandler.cs @@ -366,7 +366,7 @@ private async Task HandlePlaytest(FilterableApp app, SharedExternalResource await WebRequest.GetStorePage(Bot, app.Parent?.ID).ConfigureAwait(false)).ConfigureAwait(false))) { + if (!PackageFilter.IsPlaytestValidOnStore(await storePageResource.Fetch(async() => await WebRequest.GetStorePage(Bot, app.Parent.ID).ConfigureAwait(false)).ConfigureAwait(false))) { return; } diff --git a/FreePackages/Handlers/PackageQueue.cs b/FreePackages/Handlers/PackageQueue.cs index c6b379e..d3f2a24 100644 --- a/FreePackages/Handlers/PackageQueue.cs +++ b/FreePackages/Handlers/PackageQueue.cs @@ -148,7 +148,7 @@ private async Task ClaimFreeApp(uint appID) { // The Result returned by RequestFreeLicense is useless and I've only ever seen it return EResult.OK if (response.Result != EResult.OK) { - Bot.ArchiLogger.LogGenericInfo(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("app/{0}", appID), response.Result)); + Bot.ArchiLogger.LogGenericDebug(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("app/{0}", appID), response.Result)); return EResult.Fail; } @@ -170,7 +170,7 @@ private async Task ClaimFreeApp(uint appID) { bool isComingSoon = appDetails?.Data?.ReleaseDate?.ComingSoon ?? true; if (!success || !isFree || isComingSoon) { - Bot.ArchiLogger.LogGenericInfo(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("app/{0}", appID), EResult.Invalid)); + Bot.ArchiLogger.LogGenericDebug(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("app/{0}", appID), EResult.Invalid)); return EResult.Invalid; } @@ -180,7 +180,7 @@ private async Task ClaimFreeApp(uint appID) { if (hasPackages) { // Replace the app with the appropriate package and when we try to activate that we'll find out for sure if we're rate limited or not // Note: This is mostly wishful thinking. /api/appdetails rarely shows the free packages for free apps (one example where it does: https://steamdb.info/app/2119270/) - Bot.ArchiLogger.LogGenericInfo(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("app/{0}", appID), String.Format(Strings.ReplacedWith, String.Join(", ", appDetails!.Data!.Packages.Select(x => $"sub/{x}"))))); + Bot.ArchiLogger.LogGenericDebug(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("app/{0}", appID), String.Format(Strings.ReplacedWith, String.Join(", ", appDetails!.Data!.Packages.Select(x => $"sub/{x}"))))); BotCache.AddChanges(packageIDs: appDetails.Data.Packages); return EResult.OK; @@ -189,7 +189,7 @@ private async Task ClaimFreeApp(uint appID) { // We could be rate limited, but the app could also be invalid beacause it has no available licenses. It's necessary to assume invalid so we don't get into an infinite loop. // Examples: https://steamdb.info/app/2401570/ on Oct 2, 2023, Attempting to download demo through Steam client gives error "no licenses" // Free games that still have store pages but display "At the request of the publisher, ___ is unlisted on the Steam store and will not appear in search.": https://store.steampowered.com/app/376570/WildStar/ - Bot.ArchiLogger.LogGenericInfo(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("app/{0}", appID), Strings.Unknown)); + Bot.ArchiLogger.LogGenericDebug(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("app/{0}", appID), Strings.Unknown)); return EResult.Invalid; } @@ -208,7 +208,11 @@ private async Task ClaimFreeSub(uint subID) { return EResult.Invalid; } - Bot.ArchiLogger.LogGenericInfo(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("sub/{0}", subID), String.Format("{0}/{1}", result, purchaseResult))); + if (result == EResult.OK) { + Bot.ArchiLogger.LogGenericInfo(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("sub/{0}", subID), String.Format("{0}/{1}", result, purchaseResult))); + } else { + Bot.ArchiLogger.LogGenericDebug(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("sub/{0}", subID), String.Format("{0}/{1}", result, purchaseResult))); + } if (purchaseResult == EPurchaseResultDetail.RateLimited) { return EResult.RateLimitExceeded; @@ -230,14 +234,14 @@ private async Task ClaimPlaytest(uint appID) { if (response == null) { // Playtest does not exist currently - Bot.ArchiLogger.LogGenericInfo(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("playtest/{0}", appID), Strings.Invalid)); + Bot.ArchiLogger.LogGenericDebug(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("playtest/{0}", appID), Strings.Invalid)); return EResult.Invalid; } if (response.Success != 1) { // Not sure if/when this happens - Bot.ArchiLogger.LogGenericInfo(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("playtest/{0}", appID), Strings.Failed)); + Bot.ArchiLogger.LogGenericDebug(String.Format(ArchiSteamFarm.Localization.Strings.BotAddLicense, String.Format("playtest/{0}", appID), Strings.Failed)); return EResult.Invalid; }