Skip to content

Commit

Permalink
Improve filtering of invalid apps and packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed May 23, 2024
1 parent ac40da1 commit b364836
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
8 changes: 7 additions & 1 deletion FreePackages/Data/FilterablePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FilterableApp> PackageContents = new();
internal HashSet<uint> PackageContentIDs;
internal HashSet<uint> PackageContentParentIDs = new();
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 0 additions & 6 deletions FreePackages/Handlers/PackageFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion FreePackages/Handlers/PackageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ private async Task HandlePlaytest(FilterableApp app, SharedExternalResource<Html
return;
}

if (!PackageFilter.IsPlaytestValidOnStore(await storePageResource.Fetch(async() => 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;
}

Expand Down
18 changes: 11 additions & 7 deletions FreePackages/Handlers/PackageQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private async Task<EResult> 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;
}
Expand All @@ -170,7 +170,7 @@ private async Task<EResult> 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;
}
Expand All @@ -180,7 +180,7 @@ private async Task<EResult> 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;
Expand All @@ -189,7 +189,7 @@ private async Task<EResult> 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;
}
Expand All @@ -208,7 +208,11 @@ private async Task<EResult> 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;
Expand All @@ -230,14 +234,14 @@ private async Task<EResult> 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;
}
Expand Down

0 comments on commit b364836

Please sign in to comment.