Resolve merge conflict: cache failures, add Cloudflare detection, bump to v0.1.6
All checks were successful
Build plugin / build (push) Successful in 1m6s
All checks were successful
Build plugin / build (push) Successful in 1m6s
This commit is contained in:
parent
d842605098
commit
730b600ec0
2 changed files with 13 additions and 4 deletions
|
|
@ -63,15 +63,19 @@ func get_boxart(item: LibraryItem, kind: LAYOUT) -> Texture2D:
|
|||
return null
|
||||
|
||||
# Enrich on first access: scrape the itch.io page for screenshots.
|
||||
# Cached failures (empty screenshots) are stored to avoid repeated
|
||||
# requests against Cloudflare-protected pages.
|
||||
var meta: Dictionary = _enriched_meta.get(game_id, {})
|
||||
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)
|
||||
if meta.is_empty():
|
||||
logger.warn("Page scrape returned no metadata for: %s" % title)
|
||||
else:
|
||||
# Cache both successes and failures to avoid repeated requests.
|
||||
_enriched_meta[game_id] = meta
|
||||
_save_enriched_meta(game_id, meta)
|
||||
if meta.is_empty():
|
||||
logger.info("No screenshots available for: %s — will use cover art" % title)
|
||||
else:
|
||||
logger.info("Scraped %d screenshots for: %s" % [meta.get("screenshots", []).size(), title])
|
||||
elif not meta.is_empty():
|
||||
logger.info("Using cached metadata for: %s (%d screenshots)" % [title, meta.get("screenshots", []).size()])
|
||||
else:
|
||||
|
|
@ -261,6 +265,11 @@ func _fetch_game_page_metadata(game: Dictionary) -> Dictionary:
|
|||
logger.warn("Empty HTML response for: " + page_url)
|
||||
return {}
|
||||
|
||||
# Detect Cloudflare challenge pages — no point extracting screenshots.
|
||||
if html.find("challenge-platform") != -1 or html.find("cf-browser-verification") != -1:
|
||||
logger.warn("Cloudflare challenge detected for: %s — falling back to cover art" % page_url)
|
||||
return {}
|
||||
|
||||
var shot_re := RegEx.new()
|
||||
shot_re.compile(SCREENSHOT_REGEX_PATTERN)
|
||||
var screenshots: Array = []
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"plugin.id": "itch-artprovider",
|
||||
"plugin.name": "itch.io Art Provider",
|
||||
"plugin.version": "0.1.5",
|
||||
"plugin.version": "0.1.6",
|
||||
"plugin.min-api-version": "1.1.0",
|
||||
"plugin.link": "https://forge.thergic.ar/jose/itchio-opengamepadui-artprovider-plugin",
|
||||
"plugin.source": "https://forge.thergic.ar/jose/itchio-opengamepadui-artprovider-plugin",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue