Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
SecondThundeR committed May 17, 2022
2 parents 623d634 + fe7bb00 commit f9464bc
Show file tree
Hide file tree
Showing 14 changed files with 929 additions and 233 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "shikithon"
version = "0.3.0"
version = "0.4.0"
description = "Yet another Python wrapper for Shikimori API"
authors = [
"SecondThundeR <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion shikithon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Contains package version and some magic for importing API object."""
from shikithon.api import API

__version__ = '0.3.0'
__version__ = '0.4.0'
__all__ = ['API']
856 changes: 671 additions & 185 deletions shikithon/api.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion shikithon/config_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def save_config(config: Dict[str, str]) -> bool:

try:
with open(config_name, 'w', encoding='utf-8') as config_file:
config_file.write(dumps(config))
config_file.write(dumps(config, indent=4))
return True
except IOError as err:
logger.warning(f'Couldn\'t save config to file: {err}')
Expand Down
3 changes: 1 addition & 2 deletions shikithon/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def wrapper(api: API, *args, **kwargs):
or if required scope is missing
:rtype: None
"""
logger.debug('Checking the possibility of using a protected '
f'"{function.__name__}" method')
logger.debug('Checking the possibility of using a protected method')
if api.restricted_mode:
logger.debug('It is not possible to use the protected method '
'due to the restricted mode')
Expand Down
46 changes: 38 additions & 8 deletions shikithon/enums/anime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,73 +2,103 @@
from enum import Enum


class Order(Enum):
class AnimeOrder(Enum):
"""Contains constants related for list ordering query."""
ID = 'id'
ID_DESC = 'id_desc'
RANKED = 'ranked'
KIND = 'kind'
POPULARITY = 'popularity'
NAME = 'name'
AIRED_ON = 'aired_on'
EPISODES = 'episodes'
STATUS = 'status'
CREATED_AT = 'created_at'
CREATED_AT_DESC = 'created_at_desc'
RANDOM = 'random'


class Kind(Enum):
class AnimeKind(Enum):
"""Contains constants related for getting certain kind of anime."""
TV = 'tv'
NOT_TV = '!tv'
TV_13 = 'tv_13'
NOT_TV_13 = '!tv_13'
TV_24 = 'tv_24'
NOT_TV_24 = '!tv_24'
TV_48 = 'tv_48'
NOT_TV_48 = '!tv_48'
MOVIE = 'movie'
NOT_MOVIE = '!movie'
OVA = 'ova'
NOT_OVA = '!ova'
ONA = 'ona'
NOT_ONA = '!ona'
SPECIAL = 'special'
NOT_SPECIAL = '!special'
MUSIC = 'music'
NOT_MUSIC = '!music'


class Status(Enum):
class AnimeStatus(Enum):
"""Contains constants related for getting certain status of anime."""
ANONS = 'anons'
NOT_ANONS = '!anons'
ONGOING = 'ongoing'
NOT_ONGOING = '!ongoing'
RELEASED = 'released'
EPISODE = 'episode'
NOT_RELEASED = '!released'


class Duration(Enum):
class AnimeDuration(Enum):
"""Contains constants related for getting certain duration of anime."""
SHORT = 'S'
NOT_SHORT = '!S'
MEDIUM = 'D'
NOT_MEDIUM = '!D'
LONG = 'F'
NOT_LONG = '!F'


class Rating(Enum):
class AnimeRating(Enum):
"""Contains constants related for getting certain rating of anime."""
NO_RATING = 'none'
NOT_NO_RATING = '!none'
ALL_AGES = 'g'
NOT_ALL_AGES = '!g'
CHILDREN = 'pg'
NOT_CHILDREN = '!pg'
TEENS = 'pg_13'
NOT_TEENS = '!pg_13'
VIOLENCE = 'r'
NOT_VIOLENCE = '!r'
MILD_NUDITY = 'r_plus'
NOT_MILD_NUDITY = '!r_plus'
HENTAI = 'rx'
NOT_HENTAI = '!rx'


class Censorship(Enum):
class AnimeCensorship(Enum):
"""Contains constants related for getting
certain censorship status of anime.
"""
CENSORED = 'true'
UNCENSORED = 'false'


class MyList(Enum):
class AnimeList(Enum):
"""Contains constants related for getting
certain user list status of anime.
"""
PLANNED = 'planned'
NOT_PLANNED = '!planned'
WATCHING = 'watching'
NOT_WATCHING = '!watching'
REWATCHING = 'rewatching'
NOT_REWATCHING = '!rewatching'
COMPLETED = 'completed'
NOT_COMPLETED = '!completed'
ON_HOLD = 'on_hold'
NOT_ON_HOLD = '!on_hold'
DROPPED = 'dropped'
NOT_DROPPED = '!dropped'
76 changes: 76 additions & 0 deletions shikithon/enums/manga.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""Enums for /api/mangas."""
from enum import Enum


class MangaOrder(Enum):
"""Contains constants related for list ordering query."""
ID = 'id'
ID_DESC = 'id_desc'
RANKED = 'ranked'
KIND = 'kind'
POPULARITY = 'popularity'
NAME = 'name'
AIRED_ON = 'aired_on'
VOLUMES = 'volumes'
CHAPTERS = 'chapters'
CREATED_AT = 'created_at'
CREATED_AT_DESC = 'created_at_desc'
RANDOM = 'random'


class MangaKind(Enum):
"""Contains constants related for getting certain kind of manga."""
MANGA = 'manga'
NOT_MANGA = '!manga'
MANHWA = 'manhwa'
NOT_MANHWA = '!manhwa'
MANHUA = 'manhua'
NOT_MANHUA = '!manhua'
LIGHT_NOVEL = 'light_novel'
NOT_LIGHT_NOVEL = '!light_novel'
NOVEL = 'novel'
NOT_NOVEL = '!novel'
ONE_SHOT = 'one_shot'
NOT_ONE_SHOT = '!one_shot'
DOUJIN = 'doujin'
NOT_DOUJIN = '!doujin'


class MangaStatus(Enum):
"""Contains constants related for getting certain status of manga."""
ANONS = 'anons'
NOT_ANONS = '!anons'
ONGOING = 'ongoing'
NOT_ONGOING = '!ongoing'
RELEASED = 'released'
NOT_RELEASED = '!released'
PAUSED = 'paused'
NOT_PAUSED = '!paused'
DISCONTINUED = 'discontinued'
NOT_DISCONTINUED = '!discontinued'


class MangaCensorship(Enum):
"""Contains constants related for getting
certain censorship status of manga.
"""
CENSORED = 'true'
UNCENSORED = 'false'


class MangaList(Enum):
"""Contains constants related for getting
certain user list status of manga.
"""
PLANNED = 'planned'
NOT_PLANNED = '!planned'
WATCHING = 'watching'
NOT_WATCHING = '!watching'
REWATCHING = 'rewatching'
NOT_REWATCHING = '!rewatching'
COMPLETED = 'completed'
NOT_COMPLETED = '!completed'
ON_HOLD = 'on_hold'
NOT_ON_HOLD = '!on_hold'
DROPPED = 'dropped'
NOT_DROPPED = '!dropped'
1 change: 1 addition & 0 deletions shikithon/enums/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
class ResponseCode(Enum):
"""Contains response status codes."""
SUCCESS = 200
NO_CONTENT = 204
RETRY_LATER = 429
4 changes: 2 additions & 2 deletions shikithon/models/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from pydantic import BaseModel

from shikithon.models.character import Character
from shikithon.models.person import Person
from shikithon.models.people import People


class Creator(BaseModel):
"""Represents creator of an anime."""
roles: List[str]
roles_russian: List[str]
character: Optional[Character]
person: Optional[Person]
person: Optional[People]
35 changes: 35 additions & 0 deletions shikithon/models/people.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Model for /api/people and submodel for creator.py"""
from datetime import datetime
from typing import List, Optional, Tuple

from pydantic import BaseModel

from shikithon.models.image import Image
from shikithon.models.people_roles import PeopleRoles
from shikithon.models.people_works import PeopleWorks


class People(BaseModel):
"""Represents person entity."""
id: int
name: str
russian: str
image: Image
url: str
japanese: Optional[str]
job_title: Optional[str]
birthday: Optional[str]
website: Optional[str]
groupped_roles: Optional[List[Tuple[str, int]]]
roles: Optional[List[PeopleRoles]]
works: Optional[List[PeopleWorks]]
thread_id: Optional[int]
topic_id: Optional[int]
person_favoured: Optional[bool]
producer: Optional[bool]
producer_favoured: Optional[bool]
mangaka: Optional[bool]
mangaka_favoured: Optional[bool]
seyu: Optional[bool]
seyu_favoured: Optional[bool]
updated_at: Optional[datetime]
13 changes: 13 additions & 0 deletions shikithon/models/people_roles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Submodel for people.py"""
from typing import List, Optional

from pydantic import BaseModel

from shikithon.models.anime import Anime
from shikithon.models.character import Character


class PeopleRoles(BaseModel):
"""Represents roles entity of person."""
characters: Optional[List[Character]]
anime: Optional[List[Anime]]
14 changes: 14 additions & 0 deletions shikithon/models/people_works.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Submodel for people.py"""
from typing import Optional

from pydantic import BaseModel

from shikithon.models.anime import Anime
from shikithon.models.manga import Manga


class PeopleWorks(BaseModel):
"""Represents works entity of person."""
anime: Optional[Anime]
manga: Optional[Manga]
role: str
13 changes: 0 additions & 13 deletions shikithon/models/person.py

This file was deleted.

Loading

0 comments on commit f9464bc

Please sign in to comment.