From e7eb70579e82034623980254deb8e317083c975a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20N=C3=B8rgaard?= Date: Tue, 18 Oct 2022 13:37:19 +0100 Subject: [PATCH] add new filter methods to feed endpoints --- hondana/client.py | 36 ++++++++++++++++++++++++++++++++++++ hondana/http.py | 24 ++++++++++++++++++++++++ hondana/manga.py | 12 ++++++++++++ 3 files changed, 72 insertions(+) diff --git a/hondana/client.py b/hondana/client.py index 5726691..d2640f4 100644 --- a/hondana/client.py +++ b/hondana/client.py @@ -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| @@ -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:: @@ -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"]]) @@ -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| @@ -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:: @@ -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"]]) @@ -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| @@ -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 ------- @@ -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"]]) diff --git a/hondana/http.py b/hondana/http.py index 842d4fe..fb8b7e3 100644 --- a/hondana/http.py +++ b/hondana/http.py @@ -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") @@ -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"]]]: @@ -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) @@ -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( diff --git a/hondana/manga.py b/hondana/manga.py index 4223d6f..c4c4b65 100644 --- a/hondana/manga.py +++ b/hondana/manga.py @@ -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| @@ -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:: @@ -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