Skip to content

Commit

Permalink
add new filter methods to feed endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
AbstractUmbra committed Oct 18, 2022
1 parent 7782654 commit e7eb705
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
36 changes: 36 additions & 0 deletions hondana/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ async def get_my_feed(
published_at_since: Optional[datetime.datetime] = None,
order: Optional[FeedOrderQuery] = None,
includes: Optional[ChapterIncludes] = ChapterIncludes(),
include_empty_pages: Optional[bool] = None,
include_future_publish_at: Optional[bool] = None,
include_external_url: Optional[bool] = None,
) -> ChapterFeed:
"""|coro|
Expand Down Expand Up @@ -520,6 +523,12 @@ async def get_my_feed(
A query parameter to choose the 'order by' response from the API.
includes: Optional[:class:`~hondana.query.ChapterIncludes`]
The optional data to include in the response.
include_empty_pages: Optional[:class:`bool`]
Whether to show chapters with no pages available.
include_future_publish_at: Optional[:class:`bool`]
Whether to show chapters with a publishAt value set in the future.
includeExternalUrl: Optional[:class:`bool`]
Whether to show chapters that have an external URL attached to them.
.. note::
Expand Down Expand Up @@ -556,6 +565,9 @@ async def get_my_feed(
published_at_since=published_at_since,
order=order,
includes=includes,
include_empty_pages=include_empty_pages,
include_future_publish_at=include_future_publish_at,
include_external_url=include_external_url,
)

chapters.extend([Chapter(self._http, item) for item in data["data"]])
Expand Down Expand Up @@ -1056,6 +1068,9 @@ async def manga_feed(
published_at_since: Optional[datetime.datetime] = None,
order: Optional[FeedOrderQuery] = None,
includes: Optional[ChapterIncludes] = ChapterIncludes(),
include_empty_pages: Optional[bool] = None,
include_future_publish_at: Optional[bool] = None,
include_external_url: Optional[bool] = None,
) -> ChapterFeed:
"""|coro|
Expand Down Expand Up @@ -1094,6 +1109,12 @@ async def manga_feed(
includes: Optional[:class:`~hondana.query.ChapterIncludes`]
The options to include increased payloads for per chapter.
Defaults to all values.
include_empty_pages: Optional[:class:`bool`]
Whether to show chapters with no pages available.
include_future_publish_at: Optional[:class:`bool`]
Whether to show chapters with a publishAt value set in the future.
includeExternalUrl: Optional[:class:`bool`]
Whether to show chapters that have an external URL attached to them.
.. note::
Expand Down Expand Up @@ -1129,6 +1150,9 @@ async def manga_feed(
published_at_since=published_at_since,
order=order,
includes=includes,
include_empty_pages=include_empty_pages,
include_future_publish_at=include_future_publish_at,
include_external_url=include_external_url,
)

chapters.extend([Chapter(self._http, item) for item in data["data"]])
Expand Down Expand Up @@ -2942,6 +2966,9 @@ async def get_custom_list_manga_feed(
published_at_since: Optional[datetime.datetime] = None,
order: Optional[FeedOrderQuery] = None,
includes: Optional[ChapterIncludes] = ChapterIncludes(),
include_empty_pages: Optional[bool] = None,
include_future_publish_at: Optional[bool] = None,
include_external_url: Optional[bool] = None,
) -> ChapterFeed:
"""|coro|
Expand Down Expand Up @@ -2981,6 +3008,12 @@ async def get_custom_list_manga_feed(
includes: Optional[:class:`~hondana.query.ChapterIncludes`]
The list of optional includes we request the data for.
Defaults to all possible expansions.
include_empty_pages: Optional[:class:`bool`]
Whether to show chapters with no pages available.
include_future_publish_at: Optional[:class:`bool`]
Whether to show chapters with a publishAt value set in the future.
includeExternalUrl: Optional[:class:`bool`]
Whether to show chapters that have an external URL attached to them.
Raises
-------
Expand Down Expand Up @@ -3019,6 +3052,9 @@ async def get_custom_list_manga_feed(
published_at_since=published_at_since,
order=order,
includes=includes,
include_empty_pages=include_empty_pages,
include_future_publish_at=include_future_publish_at,
include_external_url=include_external_url,
)

chapters.extend([Chapter(self._http, item) for item in data["data"]])
Expand Down
24 changes: 24 additions & 0 deletions hondana/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,9 @@ def _manga_feed(
published_at_since: Optional[datetime.datetime],
order: Optional[FeedOrderQuery],
includes: Optional[ChapterIncludes],
include_empty_pages: Optional[bool],
include_future_publish_at: Optional[bool],
include_external_url: Optional[bool],
) -> Response[chapter.GetMultiChapterResponse]:
if manga_id is None:
route = Route("GET", "/user/follows/manga/feed")
Expand Down Expand Up @@ -854,6 +857,15 @@ def _manga_feed(
if includes:
query["includes"] = includes.to_query()

if include_empty_pages:
query["includeEmptyPages"] = include_empty_pages

if include_future_publish_at:
query["includeFuturePublishAt"] = include_future_publish_at

if include_external_url:
query["includeExternalUrl"] = include_external_url

return self.request(route, params=query)

def _delete_manga(self, manga_id: str, /) -> Response[dict[str, Literal["ok", "error"]]]:
Expand Down Expand Up @@ -1538,6 +1550,9 @@ def _custom_list_manga_feed(
published_at_since: Optional[datetime.datetime],
order: Optional[FeedOrderQuery],
includes: Optional[ChapterIncludes],
include_empty_pages: Optional[bool],
include_future_publish_at: Optional[bool],
include_external_url: Optional[bool],
) -> Response[chapter.GetMultiChapterResponse]:
route = Route("GET", "/list/{custom_list_id}/feed", custom_list_id=custom_list_id)

Expand Down Expand Up @@ -1582,6 +1597,15 @@ def _custom_list_manga_feed(
if includes:
query["includes"] = includes.to_query()

if include_empty_pages:
query["includeEmptyPages"] = include_empty_pages

if include_future_publish_at:
query["includeFuturePublishAt"] = include_future_publish_at

if include_external_url:
query["includeExternalUrl"] = include_external_url

return self.request(route, params=query)

def _create_scanlation_group(
Expand Down
12 changes: 12 additions & 0 deletions hondana/manga.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,9 @@ async def feed(
published_at_since: Optional[datetime.datetime] = None,
order: Optional[FeedOrderQuery] = None,
includes: Optional[ChapterIncludes] = ChapterIncludes(),
include_empty_pages: Optional[bool] = None,
include_future_publish_at: Optional[bool] = None,
include_external_url: Optional[bool] = None,
) -> ChapterFeed:
"""|coro|
Expand Down Expand Up @@ -844,6 +847,12 @@ async def feed(
includes: Optional[:class:`~hondana.query.ChapterIncludes`]
The list of options to include increased payloads for per chapter.
Defaults to these values.
include_empty_pages: Optional[:class:`bool`]
Whether to show chapters with no pages available.
include_future_publish_at: Optional[:class:`bool`]
Whether to show chapters with a publishAt value set in the future.
includeExternalUrl: Optional[:class:`bool`]
Whether to show chapters that have an external URL attached to them.
.. note::
Expand Down Expand Up @@ -880,6 +889,9 @@ async def feed(
published_at_since=published_at_since,
order=order,
includes=includes,
include_empty_pages=include_empty_pages,
include_future_publish_at=include_future_publish_at,
include_external_url=include_external_url,
)

from .chapter import Chapter
Expand Down

0 comments on commit e7eb705

Please sign in to comment.