1212from lists import smart_rules
1313
1414# IGDB artwork_type values used to classify fetched artwork images.
15- IGDB_ARTWORK_TYPE_HERO = 7
16- IGDB_ARTWORK_TYPE_TOP_BANNER = 4
15+ # Verified by sampling artwork_type + image dimensions across titles already
16+ # tracked on this instance (Hades, Big Walk, 007 First Light, and others):
17+ # type=2 is the one that is consistently a clean widescreen promotional image.
18+ # type=7 was tried previously on a guess, but its shape is inconsistent across
19+ # titles (a wide banner for some, a square for others), so it does not hold up
20+ # as Key Art.
21+ IGDB_ARTWORK_TYPE_KEY_ART = 2
1722
1823# Acceptable image aspect ratio range for list artwork: from 3:2 (1.5) up to
1924# 16:9 (1.777..., allowing a small rounding margin up to 1.778).
@@ -476,7 +481,7 @@ def _get_igdb_backdrop(self, media_id):
476481 # We request both artworks.image_id (to get image_ids) and artworks (to get artwork IDs for fetching image_type)
477482 # Note: IGDB API doesn't support artworks.image_type as nested field,
478483 # so we'll fetch artworks separately to get image_type
479- # Key Art is identified by image_type=4 in the artworks endpoint, not a separate field
484+ # Key Art is identified by artwork_type=2 in the artworks endpoint, not a separate field
480485 access_token = igdb .get_access_token ()
481486 url = "https://api.igdb.com/v4/games"
482487 data = (
@@ -592,7 +597,7 @@ def _get_igdb_backdrop(self, media_id):
592597 )
593598
594599 # Fetch artwork details to get image_type (to identify Key Art)
595- # Key Art is identified by image_type=4 in the artworks endpoint
600+ # Key Art is identified by artwork_type=2 in the artworks endpoint
596601 key_arts = []
597602 other_artworks = []
598603
@@ -617,8 +622,7 @@ def _get_igdb_backdrop(self, media_id):
617622 for i in range (0 , len (artwork_ids ), batch_size ):
618623 batch_ids = artwork_ids [i : i + batch_size ]
619624 artwork_id_list = "," .join (str (aid ) for aid in batch_ids )
620- # IGDB artwork types: 0=Other, 1=Box Art, 2=Screenshot, 3=Clear Logo, 4=Top Banner, 5=Marquee, 6=Steam Grid, 7=Hero, 8=Logo, 9=Icon
621- # Key Art is typically artwork_type=4 (Top Banner) or artwork_type=7 (Hero)
625+ # Key Art is artwork_type=2, verified against sampled images
622626 artworks_data = (
623627 f"fields image_id,artwork_type;"
624628 f"where id = ({ artwork_id_list } );"
@@ -678,27 +682,10 @@ def _get_igdb_backdrop(self, media_id):
678682 image_id = artwork .get ("image_id" )
679683 artwork_type = artwork .get ("artwork_type" )
680684 if image_id :
681- # IGDB artwork types: 0=Other, 1=Box Art, 2=Screenshot, 3=Clear Logo, 4=Top Banner, 5=Marquee, 6=Steam Grid, 7=Hero, 8=Logo, 9=Icon
682- # Based on user feedback, artwork_type=4 might be Concept Art, not Key Art
683- # Need to identify the correct type for Key Art - possibly type 7 (Hero) or a different value
684- # For now, let's try type 7 (Hero) as Key Art, and if that doesn't work, we'll need to check the actual values
685- if (
686- artwork_type == IGDB_ARTWORK_TYPE_HERO
687- ): # Hero - trying this as Key Art
685+ if artwork_type == IGDB_ARTWORK_TYPE_KEY_ART :
688686 key_arts .append (image_id )
689687 logger .debug (
690- "Identified Key Art (Hero) for game %s: image_id=%s, artwork_type=%s" ,
691- media_id ,
692- image_id ,
693- artwork_type ,
694- )
695- elif (
696- artwork_type == IGDB_ARTWORK_TYPE_TOP_BANNER
697- ): # Top Banner - might be Concept Art based on user feedback
698- # Skip type 4 for now since user says it's showing Concept Art
699- other_artworks .append (image_id )
700- logger .debug (
701- "Skipping Top Banner (might be Concept Art) for game %s: image_id=%s, artwork_type=%s" ,
688+ "Identified Key Art for game %s: image_id=%s, artwork_type=%s" ,
702689 media_id ,
703690 image_id ,
704691 artwork_type ,
0 commit comments