Explorar el Código

[videogames] Fix minor metadata look up bug

Colin Powell hace 6 meses
padre
commit
5111cee14b
Se han modificado 1 ficheros con 7 adiciones y 5 borrados
  1. 7 5
      vrobbler/apps/videogames/utils.py

+ 7 - 5
vrobbler/apps/videogames/utils.py

@@ -29,11 +29,13 @@ def get_or_create_videogame(
     # Create missing platforms and prep for loading after create
     platform_ids = []
     if "platforms" in game_dict.keys():
-        for platform in game_dict.get("platforms", []):
-            p, _created = VideoGamePlatform.objects.get_or_create(
-                name=platform
-            )
-            platform_ids.append(p.id)
+        platforms = game_dict.get("platforms", [])
+        if platforms:
+            for platform in game_dict.get("platforms", []):
+                p, _created = VideoGamePlatform.objects.get_or_create(
+                    name=platform
+                )
+                platform_ids.append(p.id)
         game_dict.pop("platforms")
 
     cover_url = game_dict.pop("cover_url")