Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: AniList.get() now accepts every parameter accepted by anilist #21

Merged
merged 6 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.5.0
hooks:
- id: ruff
args: ['--fix']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.5.0
hooks:
- id: ruff-format
- repo: https://github.com/python-poetry/poetry
Expand Down
100 changes: 13 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
## About

- Supports both sync and async.
- Provides easy access to almost every field present in AniList's `Media` type.
- Only supports querying the `Media` type
- Only supports querying the `Media` type.

## Installation

Expand All @@ -45,91 +44,18 @@ pip install pyanilist

## Usage

1. `AniList()` - Synchronous class
- `search()` - Search a media

```py
from pyanilist import AniList, MediaType

media = AniList().search("Attack on Titan", type=MediaType.ANIME)

print(media.title.romaji)
"""
Shingeki no Kyojin
"""
print(media.site_url)
"""
https://anilist.co/anime/16498
"""
print(media.episodes)
"""
25
"""
```
- `get()` - Get a media by it's AniList ID

```py
from pyanilist import AniList

media = AniList().get(21459)

print(media.title.english)
"""
My Hero Academia
"""
print(media.site_url)
"""
https://anilist.co/anime/21459
"""
print(media.episodes)
"""
13
"""
```

2. `AsyncAniList()` - Asynchronous class
- `search()` - Search a media

```py
import asyncio
from pyanilist import AsyncAniList, MediaType

media = asyncio.run(AsyncAniList().search("Attack on Titan", type=MediaType.ANIME))

print(media.title.romaji)
"""
Shingeki no Kyojin
"""
print(media.site_url)
"""
https://anilist.co/anime/16498
"""
print(media.episodes)
"""
25
"""
```
- `get()` - Get a media by it's AniList ID

```py
import asyncio
from pyanilist import AsyncAniList

media = asyncio.run(AsyncAniList().get(21459))

print(media.title.english)
"""
My Hero Academia
"""
print(media.site_url)
"""
https://anilist.co/anime/21459
"""
print(media.episodes)
"""
13
"""
```
```py
from pyanilist import AniList

media = AniList().get("My Hero Academia")

print(media.title.romaji)
#> Boku no Hero Academia
print(media.site_url)
#> https://anilist.co/anime/21459
print(media.episodes)
#> 13
```

## Docs

Expand Down
12 changes: 0 additions & 12 deletions docs/api-reference/clients.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,2 @@
::: pyanilist.AniList
options:
members:
- __init__
- search
- get


::: pyanilist.AsyncAniList
options:
members:
- __init__
- search
- get
23 changes: 22 additions & 1 deletion docs/api-reference/enums.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
::: pyanilist._enums.BaseStrEnum
::: pyanilist._enums.CharacterRole
options:
members: true
::: pyanilist._enums.ExternalLinkType
options:
members: true
::: pyanilist._enums.MediaFormat
options:
members: true
::: pyanilist._enums.MediaRankType
options:
members: true
::: pyanilist._enums.MediaRelation
options:
members: true
::: pyanilist._enums.MediaSeason
options:
members: true
::: pyanilist._enums.MediaSort
options:
members: true
::: pyanilist._enums.MediaSource
options:
members: true
::: pyanilist._enums.MediaStatus
::: pyanilist._enums.MediaType
options:
members: true
::: pyanilist._enums.MediaType
options:
members: true
119 changes: 3 additions & 116 deletions docs/api-reference/exceptions.md
Original file line number Diff line number Diff line change
@@ -1,117 +1,4 @@
!!! note
PyAniList simply re-exports exceptions from
[`httpx`](https://www.python-httpx.org/exceptions/) and
[`pydantic`](https://docs.pydantic.dev/latest/api/pydantic_core/#pydantic_core.ValidationError) for convenience.
PyAniList doesn't raise any custom exceptions of it's own. The two most likely errors you'll encounter will be either of these:

::: pyanilist._exceptions.CloseError
options:
show_source: false
members: false
::: pyanilist._exceptions.ConnectError
options:
show_source: false
members: false
::: pyanilist._exceptions.ConnectTimeout
options:
show_source: false
members: false
::: pyanilist._exceptions.CookieConflict
options:
show_source: false
members: false
::: pyanilist._exceptions.DecodingError
options:
show_source: false
members: false
::: pyanilist._exceptions.HTTPError
options:
show_source: false
members: false
::: pyanilist._exceptions.HTTPStatusError
options:
show_source: false
members: false
::: pyanilist._exceptions.InvalidURL
options:
show_source: false
members: false
::: pyanilist._exceptions.LocalProtocolError
options:
show_source: false
members: false
::: pyanilist._exceptions.NetworkError
options:
show_source: false
members: false
::: pyanilist._exceptions.PoolTimeout
options:
show_source: false
members: false
::: pyanilist._exceptions.ProtocolError
options:
show_source: false
members: false
::: pyanilist._exceptions.ProxyError
options:
show_source: false
members: false
::: pyanilist._exceptions.ReadError
options:
show_source: false
members: false
::: pyanilist._exceptions.ReadTimeout
options:
show_source: false
members: false
::: pyanilist._exceptions.RemoteProtocolError
options:
show_source: false
members: false
::: pyanilist._exceptions.RequestError
options:
show_source: false
members: false
::: pyanilist._exceptions.RequestNotRead
options:
show_source: false
members: false
::: pyanilist._exceptions.ResponseNotRead
options:
show_source: false
members: false
::: pyanilist._exceptions.StreamClosed
options:
show_source: false
members: false
::: pyanilist._exceptions.StreamConsumed
options:
show_source: false
members: false
::: pyanilist._exceptions.StreamError
options:
show_source: false
members: false
::: pyanilist._exceptions.TimeoutException
options:
show_source: false
members: false
::: pyanilist._exceptions.TooManyRedirects
options:
show_source: false
members: false
::: pyanilist._exceptions.UnsupportedProtocol
options:
show_source: false
members: false
::: pyanilist._exceptions.WriteError
options:
show_source: false
members: false
::: pyanilist._exceptions.WriteTimeout
options:
show_source: false
members: false
::: pyanilist._exceptions.ValidationError
options:
show_source: false
members: false
- `pyanilist.HTTPStatusError` - Alias for [`httpx.HTTPStatusError`](https://www.python-httpx.org/exceptions/). Raised if a request returns a non 2xx status code.
- `pyanilist.ValidationError` - Alias for [`pydantic.ValidationError`](https://docs.pydantic.dev/latest/errors/validation_errors/). Raised if an input is invalid.
18 changes: 4 additions & 14 deletions docs/api-reference/types.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
!!! note
Additionally, PyAniList also uses and exports the following [pydantic](https://docs.pydantic.dev/latest/) types for convenience:

- [HttpUrl](https://docs.pydantic.dev/latest/api/networks/#pydantic.networks.HttpUrl)

- [Color](https://docs.pydantic.dev/latest/api/pydantic_extra_types_color/#pydantic_extra_types.color.Color)

- [CountryAlpha2 as CountryCode](https://docs.pydantic.dev/latest/api/pydantic_extra_types_country/#pydantic_extra_types.country.CountryAlpha2)

::: pyanilist._types.AniListID
::: pyanilist._types.AniListTitle
::: pyanilist._types.AniListYear
::: pyanilist._types.YearsActive
::: pyanilist._types.HTTPXAsyncClientKwargs
::: pyanilist._types.HTTPXClientKwargs
options:
members: true
::: pyanilist._types.FuzzyDateInt
::: pyanilist._types.Iterable
Loading