Skip to content

Commit

Permalink
Update search return type
Browse files Browse the repository at this point in the history
  • Loading branch information
IchBinLeoon committed Aug 25, 2021
1 parent bb83ec9 commit eb09109
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ async def main():
async with TraceMoe() as tracemoe:

# Search by image URL
result: dict = await tracemoe.search('https://XXX/XXX.jpg')
print(result)
results: list = await tracemoe.search('https://XXX/XXX.jpg')
print(results)

# Search by image upload
result: dict = await tracemoe.search(open('/home/ichbinleoon/XXX.jpg', 'rb'))
print(result)
results: list = await tracemoe.search(open('/home/ichbinleoon/XXX.jpg', 'rb'))
print(results)

# Get account info
info: dict = await tracemoe.me()
Expand All @@ -52,16 +52,16 @@ async def main():
tracemoe = TraceMoe(api_key='Your API key')

# Cut black borders
result: dict = await tracemoe.search('https://XXX/XXX.jpg', cut_borders=True)
print(result)
results: list = await tracemoe.search('https://XXX/XXX.jpg', cut_borders=True)
print(results)

# Filter by AniList ID
result: dict = await tracemoe.search('https://XXX/XXX.jpg', anilist_id=11617)
print(result)
results: list = await tracemoe.search('https://XXX/XXX.jpg', anilist_id=11617)
print(results)

# Include AniList info
result: dict = await tracemoe.search('https://XXX/XXX.jpg', anilist_info=True)
print(result)
results: list = await tracemoe.search('https://XXX/XXX.jpg', anilist_info=True)
print(results)

await tracemoe.close()

Expand Down
10 changes: 5 additions & 5 deletions tracemoe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"""

import logging
from typing import TypeVar, Optional, Dict, Any, Union, BinaryIO
from typing import TypeVar, Optional, Dict, Any, Union, BinaryIO, List
from urllib.parse import urljoin

import aiohttp
from aiohttp import ContentTypeError

__author__ = 'IchBinLeoon'
__version__ = '1.0.0'
__version__ = '1.0.1'

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -167,7 +167,7 @@ async def search(
cut_borders: Optional[bool] = False,
anilist_id: Optional[int] = None,
anilist_info: Optional[bool] = False,
) -> Dict[str, Any]:
) -> List[Dict[str, Any]]:
"""Searches the scene the anime screenshot is from by URL or upload.
Args:
Expand All @@ -177,7 +177,7 @@ async def search(
anilist_info(bool, optional): Include AniList info.
Returns:
dict: The search result.
list: The search results.
"""
params = {}
data = None
Expand All @@ -201,7 +201,7 @@ async def search(

url = urljoin(BASE_URL, 'search')
data = await self._request(method, url=url, params=params, headers=headers, data=data)
return data
return data.get('result')

async def me(self) -> Dict[str, Any]:
"""Checks the search quota and limit for your account (with API key) or IP address (without API key).
Expand Down

0 comments on commit eb09109

Please sign in to comment.