From 5889065f7746f5e0dd9d196fa05d3f7d70612b43 Mon Sep 17 00:00:00 2001 From: Marco S <70583350+MarcoSa-2000@users.noreply.github.com> Date: Tue, 18 Jul 2023 19:29:12 +0200 Subject: [PATCH] 0.7.1 --- README.md | 23 ++++++++++++++++++++++- animegifs/animegifs.py | 2 +- animegifs/distutils/errors.py | 12 ++++++++++++ setup.py | 4 ++-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7583e32..84c4a1d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Get random anime gifs by category. Use Python (intended (for now) for Discord). WIP - updated in time to time. Versions below v0.5.3 aren't expected to work flawlessly or at all. Version below v0.6 will not have the gifs library updated anymore. +For troubleshoots, known errors and categories list, check below. `pip install animegifs` @@ -38,6 +39,21 @@ title = gifs.get_animetitle(gif) #get the title of the gif's anime. malid = gifs.get_malId(gif) #get the ID of the gif's anime myanimelist page. ``` +```py +#v0.6> +from animegifs import animegifs + +gifs = animegifs.Animegifs() + +user_input = input() #let user send any input and search if that input matches a category. +#if user_input == "nom": #nom as category doesn't exist, but is similar to bite (as example) +# user_input = "bite" +try: + gif = gifs.get_gif(user_input) #return the url of the gif if category exists. +except animegifs.errors.CategoryError: + print("not a valid gif category.") +``` + ## Category list: **A** @@ -102,10 +118,15 @@ malid = gifs.get_malId(gif) #get the ID of the gif's anime myanimelist page. You can test out the API (and lib functionality) on my bot's website here: https://enkidu-app.github.io/animegifs +# Submit a GIF + +If you also want to contribute to the gifs collection, you can submit a gif at: https://forms.gle/wxWmRuy5VCdDCZWp8 + # Troubleshooting and other +The first call (only!) in the session is expected to have a slower reaction time (5-15s) because of the authentication process. If you encounter an error, please raise an issue on the issue page: https://github.com/MarcoSa-2000/animegifs/issues. -Alternatively, you can join my Discord server to request new categories, functions, provide feedback, or report any errors. +Alternatively, you can join my Discord server (https://discord.com/invite/TKZJ4GJj2z) to request new categories, functions, provide feedback, or report any errors. I do also have a multi-function Discord bot. Feel free to check out the web dashboard here: https://enkidu-app.github.io. # Copyright diff --git a/animegifs/animegifs.py b/animegifs/animegifs.py index 9808bd7..9ed1fbd 100644 --- a/animegifs/animegifs.py +++ b/animegifs/animegifs.py @@ -102,7 +102,7 @@ def get_animetitle(self, gif) -> str: try: title = Anime(int(result)).title except ValueError as exc: - raise errors.MethodNotUpdated(gif) from exc + raise errors.AnimeNotFound(gif) from exc return title else: continue diff --git a/animegifs/distutils/errors.py b/animegifs/distutils/errors.py index 5cce3a4..75b33d3 100644 --- a/animegifs/distutils/errors.py +++ b/animegifs/distutils/errors.py @@ -43,6 +43,18 @@ def __init__(self, gif, error="Method not yet available for this gif."): self.error = error super().__init__(self.error) +class AnimeNotFound(Exception): + """ + Raised if the anime's id is either invalid or has been removed or relocated. + Check firstly if myanimelist.net is working correctly, if confirmed, + please raise an issue in https://github.com/MarcoSa-2000/animegifs/issues. + """ + + def __init__(self, gif, error="Anime's ID is either invalid, removed or MyAnimeList is currently down."): + self.gif = gif + self.error = error + super().__init__(self.error) + class AuthTimeout(Exception): """ Authentication request timed out. Probably status error 504 on server side. diff --git a/setup.py b/setup.py index dc303b6..9bf9058 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ long_description = "\n" + fh.read() LONG_DESCRIPTION = long_description -VERSION = '0.7.0' +VERSION = '0.7.1' setup( name='animegifs', @@ -35,5 +35,5 @@ "Programming Language :: Python :: 3.11", "License :: OSI Approved :: MIT License", "Operating System :: Microsoft :: Windows"], - keywords=['anime', 'gif', 'python', 'anime-gif', 'discord'], + keywords=['anime', 'gif', 'python', 'anime-gifs', 'discord'], )