Skip to content

Commit

Permalink
Merge pull request #31 from LEv145:dev
Browse files Browse the repository at this point in the history
v 1.0.10
  • Loading branch information
LEv145 authored Jan 7, 2022
2 parents 3f9f139 + ac4e29f commit f0155fa
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 36 deletions.
33 changes: 21 additions & 12 deletions aiontai/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ async def get_doujin(self, doujin_id: int) -> Dict[str, Any]:
Args:
doujin_id: ID of doujin.
Returns:
Doujin raw data from responce.
Raises:
DoujinDoesNotExistError: If doujin does not exit.
ClientResponseError: Error from response.
Returns:
Doujin raw data from responce.
"""
url = f"https://nhentai.net/api/gallery/{doujin_id}"

Expand All @@ -97,6 +97,9 @@ async def is_exist(self, doujin_id: int) -> bool:
Returns:
Doujin is exists.
Raises:
ClientResponseError: Error from response.
"""
try:
await self.get_doujin(doujin_id)
Expand All @@ -110,6 +113,9 @@ async def get_random_doujin(self) -> Dict[str, Any]:
Returns:
Doujin raw data from responce.
Raises:
ClientResponseError: Error from response.
"""
url = "https://nhentai.net/random/"

Expand Down Expand Up @@ -140,12 +146,13 @@ async def search(
sort_by: Sort options for search.
Defaults to SortOptions.DATE.
Returns:
Doujins raw data result from responce.
Raises:
WrongPageError: If number of page is invalid.
EmptyAPIResultError: If api result is empty.
Returns:
Doujins raw data result from responce.
ClientResponseError: Error from response.
"""
if page < 1:
raise WrongPageError("Page can not be less than 1")
Expand Down Expand Up @@ -182,13 +189,14 @@ async def search_by_tag(
sort_by: Sort options for search.
Defaults to SortOptions.DATE.
Returns:
Doujins raw data result from responce.
Raises:
WrongPageError: If number of page is invalid.
WrongTagError: If tag ID is invalid.
EmptyAPIResultError: If api result is empty.
Returns:
Doujins raw data result from responce.
ClientResponseError: Error from response.
"""
if page < 1:
raise WrongPageError("Page can not be less than 1")
Expand Down Expand Up @@ -223,11 +231,12 @@ async def get_homepage_doujins(
page: Number of page from which we return results.
Defaults to 1.
Raises:
EmptyAPIResultError: If api result is empty.
Returns:
Doujins raw data result from responce.
Raises:
EmptyAPIResultError: If api result is empty.
ClientResponseError: Error from response.
"""
url = "https://nhentai.net/api/galleries/all"

Expand Down
25 changes: 25 additions & 0 deletions aiontai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ async def get_doujin(self, doujin_id: int) -> Doujin:
Returns:
Doujin model.
Raises:
DoujinDoesNotExistError: If doujin does not exit.
ClientResponseError: Error from response.
"""
raw_data = await self.api.get_doujin(doujin_id)

Expand All @@ -81,6 +85,9 @@ async def is_exist(self, doujin_id: int) -> bool:
Returns:
Doujin is exists.
Raises:
ClientResponseError: Error from response.
"""
raw_data = await self.api.is_exist(doujin_id)

Expand All @@ -92,6 +99,9 @@ async def get_random_doujin(self) -> Doujin:
Returns:
Doujin model.
Raises:
ClientResponseError: Error from response.
"""
raw_data = await self.api.get_random_doujin()

Expand All @@ -116,6 +126,11 @@ async def search(
Returns:
Doujins result model.
Raises:
WrongPageError: If number of page is invalid.
EmptyAPIResultError: If api result is empty.
ClientResponseError: Error from response.
"""
result = await self.api.search(
query=query,
Expand Down Expand Up @@ -144,6 +159,12 @@ async def search_by_tag(
Returns:
Doujins result model.
Raises:
WrongPageError: If number of page is invalid.
WrongTagError: If tag ID is invalid.
EmptyAPIResultError: If api result is empty.
ClientResponseError: Error from response.
"""
result = await self.api.search_by_tag(
tag_id=tag_id,
Expand All @@ -167,6 +188,10 @@ async def get_homepage_doujins(
Returns:
Doujins result model.
Raises:
EmptyAPIResultError: If api result is empty.
ClientResponseError: Error from response.
"""
result = await self.api.get_homepage_doujins(
page=page,
Expand Down
2 changes: 1 addition & 1 deletion aiontai/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def convert_title(
Convert raw data to title model.
Args:
raw_data: model raw data.
raw_data: Model raw data.
Returns:
Title model.
Expand Down
5 changes: 4 additions & 1 deletion aiontai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ def __getitem__(self, index: int) -> Image:
index: List index.
Returns:
Model.
Image model.
Raises:
IndexError: If page index out of range.
"""
return self.images[index]

Expand Down
21 changes: 1 addition & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aiontai"
version = "1.0.9"
version = "1.0.10"
description = "Async wrapper for nhentai API"
authors = ["LEv145"]
license = "MIT"
Expand All @@ -21,7 +21,6 @@ mkinit = "^0.3.4"
black = "^21.12b0"
coverage = {extras = ["toml"], version = "^6.2"}
attrs = "^21.4.0"
pydocstyle = {extras = ["toml"], version = "^6.1.1"}
flake8-commas = {git = "https://github.com/LEv145/flake8-commas"}
flake9 = "^3.8.3"
poethepoet = "^0.11.0"
Expand Down

0 comments on commit f0155fa

Please sign in to comment.