Skip to content

Commit

Permalink
Prefer UrlSlug as game name
Browse files Browse the repository at this point in the history
  • Loading branch information
azhuge233 committed Feb 28, 2025
1 parent 720527f commit 312ecb2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions EGSFreeGamesNotifier/Services/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ private string GetProductSlug(Element_ game) {
if (game.OfferMappings != null && game.OfferMappings.Any(map => map.PageType == ParseStrings.UrlProductSlugPageType || map.PageType == ParseStrings.UrlPageSlugPageType))
gameName = game.OfferMappings.First(map => map.PageType == ParseStrings.UrlProductSlugPageType || map.PageType == ParseStrings.UrlPageSlugPageType).PageSlug;
} else {
if (!string.IsNullOrEmpty(game.ProductSlug)) gameName = game.ProductSlug;
if (game.CatalogNs.Mappings != null && game.CatalogNs.Mappings.Any(map => map.PageType == ParseStrings.UrlProductSlugPageType))
gameName = game.CatalogNs.Mappings.First(map => map.PageType == ParseStrings.UrlProductSlugPageType).PageSlug;
if (game.OfferMappings != null && game.OfferMappings.Any(map => map.PageType == ParseStrings.UrlProductSlugPageType))
gameName = game.OfferMappings.First(map => map.PageType == ParseStrings.UrlProductSlugPageType).PageSlug;
if (game.CustomAttributes != null && game.CustomAttributes.Any(pair => pair.Key == ParseStrings.CustomAttrProductSlugKey))
gameName = game.CustomAttributes.First(pair => pair.Key == ParseStrings.CustomAttrProductSlugKey).Value;
if (gameName == ParseStrings.MisteryGameName) {
gameName = game.UrlSlug;
_logger.LogDebug(ParseStrings.debugMisteryGameFound, gameName);
}
} else if (!string.IsNullOrEmpty(game.UrlSlug)) gameName = game.UrlSlug;
else if (!string.IsNullOrEmpty(game.ProductSlug)) gameName = game.ProductSlug;
else if (game.CatalogNs.Mappings != null && game.CatalogNs.Mappings.Any(map => map.PageType == ParseStrings.UrlProductSlugPageType))
gameName = game.CatalogNs.Mappings.First(map => map.PageType == ParseStrings.UrlProductSlugPageType).PageSlug;
else if (game.OfferMappings != null && game.OfferMappings.Any(map => map.PageType == ParseStrings.UrlProductSlugPageType))
gameName = game.OfferMappings.First(map => map.PageType == ParseStrings.UrlProductSlugPageType).PageSlug;
else if (game.CustomAttributes != null && game.CustomAttributes.Any(pair => pair.Key == ParseStrings.CustomAttrProductSlugKey))
gameName = game.CustomAttributes.First(pair => pair.Key == ParseStrings.CustomAttrProductSlugKey).Value;
}

return gameName;
Expand Down

0 comments on commit 312ecb2

Please sign in to comment.