Closed ojmaster closed 3 years ago
Hi, The problem is most likely related with PokeAPI itself and not pokepy. If that's the case, please do report the issue on the PokeAPI repo.
In any case, can you give an example of what you're getting and how?
Still, most flavour text entries are a list of FlavorText, so you should be able to iterate over the list and select the language you want. That is, of course, if PokeAPI has the language you want available
Yeah really I just need an example for how I can make sure I'm getting the first available flavor text that's in English.
That is, of course, if PokeAPI has the language you want available
example:
import pokepy
client = pokepy.V2Client()
bulbasaur = client.get_pokemon_species(1)
for flavor in bulbasaur.flavor_text_entries:
if flavor.language.name == 'en':
print(flavor.flavor_text)
A strange seed was
planted on its
back at birth.The plant sprouts
and grows with
this POKéMON.
Thank you so much i feel like I should've known this but it's good to get help
@Kronopt so I'm able to get the Pokémon's generation but then when I try to find the game version I get an error
Your code earlier worked great but its not returning the first possible games flavor text (ex. Bulbasaur return red's, arceus will return diamond's) but whenever I try to get the version it returns an error
pykemon = pokepy.V2Client()
pk = pykemon.get_pokemon_species(pokemon)
print(pk.generation.version_groups[1].name)
This is my code for getting the version group name but its returning that version_groups isnt a an attribute, yet yesterday when i was trying this it was workign fine, but now it isnt
i also just tried to get the version from the flavor text and its returning that flavortextsubersource object ahas no attribute version
Indeed the version
is not accessible.
import pokepy
from pprint import pprint
pykemon = pokepy.V2Client()
pk = pykemon.get_pokemon_species('bulbasaur')
for text in pk.flavor_text_entries:
pprint(vars(text))
print(text.version.name)
You can try this code @Kronopt. Is there another way to get the version?
Ok, the FlavorTextSubResource
didn't have the version
sub-property. I added it in the master
branch. Now we need to publish.
This code should be working with the new version
import pokepy
from pprint import pprint
pykemon = pokepy.V2Client()
pk = pykemon.get_pokemon_species('bulbasaur')
for text in pk.flavor_text_entries:
if text.language.name == 'en':
print('- Version {0}: {1}'.format(text.version.name, text.flavor_text))
I guess I forgot to add the version
property to the FlavorTextSubResource
... that is my bad! Good catch @Naramsim!
It works now thank you @Naramsim
How would I get the games a Pokémon is introduced in. Also I think version_groups doesn't have subattribute version either
I can just make a check using the Pokémon's ID but I was wondering if you could determine the game versions directly from the Pokémon's name, my goal is to get the game the pokemon was introduced in and get the flavor text for that pokemon from that game
I have already gotten a way to find the games a certain Pokémon was introduced in just was wondering if there was a way to do get_pokemon_species(pokemon).version_groups[0].version.name
Because it seems faster
I have already gotten a way to find the games a certain Pokémon was introduced in just was wondering if there was a way to do
get_pokemon_species(pokemon).version_groups[0].version.name
Because it seems faster
For this it says version is not an available subresource
To find out when a pokemon was released you can use the pokemon-species
endpoint and then look at the generation
property.
Thank you 👍
So I’m trying to get the flavor text for a user inputted pokemon and I’ve got it working but I have 2 questions, some Pokémon’s flavor text are coming out in Japanese while others in English, I’ve noticed that everything past gen 5 isn’t in English, how do I set it to only display English and how do I choose what version.