Skip to content

Commit

Permalink
Adapt to anilist adult filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
doron-goldstein committed Feb 20, 2021
1 parent 6ceff56 commit d71aa78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions kadal/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,30 @@ async def get_user(self, id) -> User:
data = await self._request(USER_BY_ID, id=id)
return User(data)

async def search_anime(self, query, *, popularity=False, allow_adult=True) -> Media:
async def search_anime(self, query, *, popularity=False, allow_adult=False) -> Media:
variables = {
"search": query,
"type": "ANIME",
"isAdult": allow_adult
}
if not allow_adult:
variables['isAdult'] = False

if popularity:
data = (await self._most_popular(query, **variables))[0]
else:
data = await self._request(MEDIA_SEARCH, **variables)
return Media(data, page=popularity)

async def search_manga(self, query, *, popularity=False, include_novels=False, allow_adult=True) -> Media:
async def search_manga(self, query, *, popularity=False, include_novels=False, allow_adult=False) -> Media:
exclude = "NOVEL" if not include_novels else None
variables = {
"search": query,
"type": "MANGA",
"exclude": exclude,
"isAdult": allow_adult
}
if not allow_adult:
variables['isAdult'] = False

if popularity:
data = (await self._most_popular(query, **variables))[0]
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup(
name='Kadal',
author='SynderBlack',
version="0.2.5",
version="0.2.6",
packages=['kadal'],
license='MIT',
description='Async wrapper for the Anilist API',
Expand Down

0 comments on commit d71aa78

Please sign in to comment.