Skip DMCA-locked grids when scraping SteamGridDB

SteamGridDB does not remove assets taken down under DMCA; it returns them
with "lock": true and strips the URL signature, so the CDN serves a
placeholder image reading "This asset has been removed in response to a
DMCA takedown notice" for both the full asset and its thumbnail.

Filter locked grids in _get_game_covers, the single funnel for scan
matching, ID lookups and the manual cover picker.

Closes #4003

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Georges-Antoine Assi
2026-07-30 10:21:00 -04:00
parent 06cafd4b10
commit 6217235c4e
3 changed files with 34 additions and 0 deletions

View File

@@ -65,6 +65,8 @@ class SGDBGrid(TypedDict):
nsfw: NotRequired[bool]
humor: NotRequired[bool]
epilepsy: NotRequired[bool]
# Locked grids serve a DMCA takedown placeholder instead of the artwork.
lock: NotRequired[bool]
url: str
thumb: str
tags: NotRequired[list[str]]

View File

@@ -199,6 +199,8 @@ class SGDBBaseHandler(MetadataHandler):
is_humor=is_humor,
is_epilepsy=is_epilepsy,
)
# Locked grids serve a DMCA takedown placeholder instead of the artwork.
if not cover.get("lock")
]
if not game_covers:
return SGDBResult(name=game_name, resources=[])

View File

@@ -78,6 +78,36 @@ class TestGetGameCoversMapping:
# `.webm` thumbs are animated covers.
assert resource["type"] == "animated"
@pytest.mark.asyncio
async def test_skips_dmca_locked_grids(self):
handler = SGDBBaseHandler()
grids = [
_make_grid(id=1, lock=True, url="https://cdn.example.com/grid/locked.png?"),
_make_grid(id=2, lock=False),
_make_grid(id=3),
]
with patch.object(
handler.sgdb_service,
"iter_grids_for_game",
side_effect=lambda *a, **k: _aiter(grids),
):
result = await handler._get_game_covers(game_id=1, game_name="Test Game")
assert len(result["resources"]) == 2
assert all("locked" not in resource["url"] for resource in result["resources"])
@pytest.mark.asyncio
async def test_all_locked_grids_yield_no_resources(self):
handler = SGDBBaseHandler()
with patch.object(
handler.sgdb_service,
"iter_grids_for_game",
side_effect=lambda *a, **k: _aiter([_make_grid(lock=True)]),
):
result = await handler._get_game_covers(game_id=1, game_name="Test Game")
assert result == {"name": "Test Game", "resources": []}
class TestGetDetailsContentFilters:
@pytest.mark.asyncio