Cloudflare detection, cache failed scrapes, cover art fallback logging
All checks were successful
Build plugin / build (push) Successful in 1m15s
All checks were successful
Build plugin / build (push) Successful in 1m15s
This commit is contained in:
parent
d06cba872c
commit
2598c0397b
2 changed files with 10 additions and 5 deletions
|
|
@ -62,11 +62,12 @@ func get_boxart(item: LibraryItem, kind: LAYOUT) -> Texture2D:
|
|||
if meta.is_empty() and game.has("url"):
|
||||
logger.info("Enriching metadata for: %s (url=%s)" % [title, game.get("url", "")])
|
||||
meta = _fetch_game_page_metadata(game)
|
||||
# Cache even empty results to avoid re-scraping on every request.
|
||||
if meta.is_empty():
|
||||
logger.warn("Page scrape returned no metadata for: %s" % title)
|
||||
else:
|
||||
_enriched[game_id] = meta
|
||||
_save_enriched_meta(game_id, meta)
|
||||
meta = {"screenshots": []}
|
||||
logger.info("Page scrape returned no screenshots for: %s (cached as empty)" % title)
|
||||
_enriched[game_id] = meta
|
||||
_save_enriched_meta(game_id, meta)
|
||||
elif not meta.is_empty():
|
||||
logger.info("Using cached metadata for: %s (%d screenshots)" % [title, meta.get("screenshots", []).size()])
|
||||
else:
|
||||
|
|
@ -267,6 +268,10 @@ func _fetch_game_page_metadata(game: Dictionary) -> Dictionary:
|
|||
logger.warn("Empty HTML response for: " + page_url)
|
||||
return {}
|
||||
|
||||
if html.find("challenge-platform") != -1 or html.find("cf-browser-verification") != -1:
|
||||
logger.warn("Cloudflare challenge detected for: " + page_url)
|
||||
return {}
|
||||
|
||||
var shot_re := RegEx.new()
|
||||
shot_re.compile("https://img\\.itch\\.zone/aW1hZ2Uv[^\"]*/original/[^\"]*")
|
||||
var screenshots: Array = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue