ReverseSearch

Core Class

class retaggr.ReverseSearch(config, test_mode=False)[source]

Core class used for Reverse Searching.

This class can only be instantiated with a ReverseSearchConfig instance.

All listed methods can only be ran from an asynchronous context.

Variables:

accessible_engines – The accessible boorus from the passed in configuration object.

Parameters:
  • config (ReverseSearchConfig) – The config object.
  • test_mode (bool) – Enable test mode. Test mode adds two dummy engines that can fail as well as return some very basic values.

Reverse searches all accessible boorus for url.

Note

Callback is a callback function that can be passed in. This can be used to keep track of progress for certain methods and functions.

1
2
3
4
5
6
7
8
 async def callback(engine, rresult):
     print("This booru was searched: %s", booru)
     print("These tags were found: %s", rresult.tags)
     print("This source was found: %s", rresult.source)
     print("This rating was found: %s", rresult.rating)

 # Callback will be called each time a search finishes.
 rs.reverse_search(url, callback)

After a reverse search, this method will be called with the engine name that was just searched.

Parameters:
  • url (str) – The URL to search.
  • callback (Optional[function]) – Callback function.
  • download (Optional[bool]) – Run searches on boorus that require a file download. Defaults to False.
Returns:

A ReverseResult instance containing your data.

Return type:

ReverseResult

search_image(booru, url)[source]

Reverse search a booru for url.

Parameters:
  • booru (str) – Booru to search, this must match a filename in the boorus folder.
  • url (str) – The URL to search.
Raises:
Returns:

A ImageResult instance containing your data.

Return type:

ImageResult

Answer Class

class retaggr.ReverseResult(tags, source, rating)

The response from a reverse image search. All attributes are Sets.

tags

The tags the engine has located.

source

All the sources that have been found for the image.

rating

The rating on the image.