Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
adogecheems committed Sep 29, 2024
1 parent 3eaff16 commit f5c11f0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions anisearch/AniSearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def reset(self) -> None:
self.if_selected: Optional[bool] = False

def search(self, keyword: str, collected: Optional[bool] = None, proxies: Optional[dict] = None,
system_proxy: Optional[bool] = None, **extra_options) -> None:
system_proxy: Optional[bool] = None, **extra_options) -> bool:
"""
Search for anime using the given keyword.
Expand All @@ -67,26 +67,32 @@ def search(self, keyword: str, collected: Optional[bool] = None, proxies: Option
- collected: Whether to collect results
- proxies: Proxy settings
- system_proxy: Whether to use system proxy
Returns:
- True if search is successful, False otherwise.
"""
self.reset()

# 使用过滤条件减少不必要的计算
kwargs = {'keyword': keyword}
if collected is not None:
kwargs['collected'] = collected
if proxies is not None:
if proxies:
kwargs['proxies'] = proxies
if system_proxy is not None:
if system_proxy:
kwargs['system_proxy'] = system_proxy
if extra_options is not None:
kwargs = {**kwargs, **extra_options}
kwargs.update(extra_options)

try:
self.animes = self.plugin.search(**kwargs)

log.info(f"This search is complete: {keyword}")
return True

except Exception as e:
log.error(f"Search failed: {str(e)}")
raise
return False


def select(self, index: int) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='Anisearch-lib',
version='1.3.4',
version='1.3.5',
packages=find_packages(exclude=['tests*']),
install_requires=requirements,
entry_points={
Expand Down

0 comments on commit f5c11f0

Please sign in to comment.