mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-21 19:03:08 +00:00
fix: don't add or replace parts of the sprites' URL
This commit is contained in:
parent
369d09f390
commit
3fa2b6952f
1 changed files with 1 additions and 28 deletions
|
@ -1507,13 +1507,6 @@ class ItemDetailSerializer(serializers.ModelSerializer):
|
|||
sprites_object = ItemSprites.objects.get(item_id=obj)
|
||||
sprites_data = ItemSpritesSerializer(sprites_object, context=self.context).data
|
||||
sprites_data = json.loads(sprites_data["sprites"])
|
||||
host = "raw.githubusercontent.com/PokeAPI/sprites/master/"
|
||||
|
||||
for key in sprites_data:
|
||||
if sprites_data[key]:
|
||||
sprites_data[key] = (
|
||||
"https://" + host + sprites_data[key].replace("/media/", "")
|
||||
)
|
||||
|
||||
return sprites_data
|
||||
|
||||
|
@ -2689,14 +2682,6 @@ class PokemonFormDetailSerializer(serializers.ModelSerializer):
|
|||
).data
|
||||
sprites_data = json.loads(sprites_data["sprites"])
|
||||
|
||||
host = "raw.githubusercontent.com/PokeAPI/sprites/master/"
|
||||
|
||||
for key in sprites_data:
|
||||
if sprites_data[key]:
|
||||
sprites_data[key] = (
|
||||
"https://" + host + sprites_data[key].replace("/media/", "")
|
||||
)
|
||||
|
||||
return sprites_data
|
||||
|
||||
def get_pokemon_form_types(self, obj):
|
||||
|
@ -2956,20 +2941,8 @@ class PokemonDetailSerializer(serializers.ModelSerializer):
|
|||
sprites_data = PokemonSpritesSerializer(
|
||||
sprites_object, context=self.context
|
||||
).data
|
||||
sprites_data = json.loads(sprites_data["sprites"])
|
||||
host = "raw.githubusercontent.com/PokeAPI/sprites/master/"
|
||||
|
||||
def replace_sprite_url(d):
|
||||
for key, value in d.items():
|
||||
if isinstance(value, dict):
|
||||
replace_sprite_url(value)
|
||||
else:
|
||||
if d[key]:
|
||||
d[key] = "https://" + host + d[key].replace("/media/", "")
|
||||
|
||||
replace_sprite_url(sprites_data)
|
||||
|
||||
return sprites_data
|
||||
return json.loads(sprites_data["sprites"])
|
||||
|
||||
def get_pokemon_moves(self, obj):
|
||||
|
||||
|
|
Loading…
Reference in a new issue