Skip to content

[Request] add cover image URL to JSON output #8

@Parzival1608vonKatze

Description

@Parzival1608vonKatze

Hello, I would like to request a feature:

  • URL of cover image of anime/manga
    I do not really know my way around JSON and do not really understand your output chain (i.e.: I'm too stupid to implement this myself). But I wrote a script to give you an Idea of what I mean:
import requests

# Define the GraphQL query to retrieve anime data
query = '''
query ($search: String) {
  Media(search: $search, type: ANIME) {
    coverImage {
      extraLarge
    }
  }
}
'''

# Prompt the user to enter the anime name
anime_name = input('Enter the name of the anime (Romaji): ')

# Define the variables for the GraphQL query
variables = {
    'search': anime_name
}

# Send the GraphQL query to the AniList API
response = requests.post('https://graphql.anilist.co', json={'query': query, 'variables': variables})

# Extract the cover image URL from the API response
try:
    cover_image_url = response.json()['data']['Media']['coverImage']['extraLarge']
except KeyError:
    print('Anime not found!')
else:
    # Modify the URL to get the cover image of the desired size
    cover_image_url = cover_image_url.replace('/large/', '/medium/')

    # Print the cover image URL
    print('Cover image URL:', cover_image_url)

I don't know if this is too much to ask. Either way, thanks for reading this.
Have a good day!
- Parzival

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions