@@ -146,7 +146,9 @@ def _get(self, *args, **kwargs) -> requests.Response:
146146
147147 # check if api credentials are set
148148 if is_api_request and self .user_id == None and self .api_key == None :
149- raise ValueError ("API credentials must be supplied, api_key and user_id can not be None!\n See https://api.rule34.xxx/ for more information." )
149+ raise ValueError (
150+ "API credentials must be supplied, api_key and user_id can not be None!\n See https://api.rule34.xxx/ for more information."
151+ )
150152
151153 # headers
152154 kwargs .setdefault ("headers" , {})
@@ -361,13 +363,16 @@ def random_post_id(self) -> int:
361363 def search (
362364 self ,
363365 tags : list [str ] = [],
366+ exclude_ai : bool = False ,
364367 page_id : Union [int , None ] = None ,
365368 limit : int = SEARCH_RESULT_MAX ,
366369 ) -> list [Post ]:
367370 """Search for posts.
368371
369372 Args:
370373 tags: A list of tags to search for.
374+ exclude_ai: Exclude ai generated content from the results.
375+ Default is False.
371376 page_id: The search page number to request, or None.
372377 If None, search will eventually return all pages.
373378 limit: The maximum number of post results to return per page.
@@ -386,6 +391,12 @@ def search(
386391 if limit < 0 or limit > SEARCH_RESULT_MAX :
387392 raise ValueError (f"Search limit must be between 0 and { SEARCH_RESULT_MAX } ." )
388393
394+ # exclude all tags starting with ai if user whishes so
395+ if exclude_ai == True :
396+ # filter out any ai tag
397+ tags = [tag for tag in tags if not tag .lower ().startswith ("ai" )]
398+ tags .append ("-ai*" )
399+
389400 params = [
390401 ["TAGS" , "+" .join (tags )],
391402 ["LIMIT" , str (limit )],
0 commit comments