Engines

This file documents some general information about the engines you can search.

You generally shouldn’t instantiate these classes yourself, rather you should use them as a reference.

ImageResult

class retaggr.engines.ImageResult(tags, source, rating)

The response from the engine.

tags

The tags the engine has located.

source

The sources that have been found for the image.

rating

The rating on the image.

Danbooru

class retaggr.engines.Danbooru(username, api_key, min_score)[source]

Reverse searches https://danbooru.donmai.us for images.

This booru does not required images to be downloaded before searching.

Parameters:
  • username (str) – The danbooru username you wish to use.
  • api_key (str) – A danbooru API key. You can obtain one from your profile.
  • min_score (float) – Minimum search match percentage needed.
search_image(url)[source]

Reverse search the engine for url.

Parameters:url (str) – URL to search
Return type:ImageResult

Iqdb

class retaggr.engines.Iqdb(min_score)[source]

Reverse searches https://iqdb.org for images.

This booru does not required images to be downloaded before searching.

This method may have unexpected failures relating to HTML parsing. This is because IQDB does not officially offer an API and the raw HTML parsing is not functional if the page is not fully loaded.

Parameters:min_score (float) – Minimum search match percentage needed.
search_image(url)[source]

Reverse search the engine for url.

Parameters:url (str) – URL to search
Return type:ImageResult
search_tag(tag)[source]

Reverse search the booru for tag data.

Paheal

class retaggr.engines.Paheal[source]

Reverse searches https://rule34.paheal.net for images.

This booru does require images to be downloaded before searching.

search_image(url)[source]

Reverse search the engine for url.

Parameters:url (str) – URL to search
Return type:ImageResult
search_tag(tag)[source]

Reverse search the booru for tag data.

SauceNao

class retaggr.engines.SauceNao(api_key, test_mode=False)[source]

Reverse searches the SauceNao API and then does additional matching.

This booru does not require images to be downloaded before searching.

This API is subject to rate limits.

Parameters:
  • api_key (str) – SauceNao API key. You can get this by registering an account on saucenao.com
  • test_mode – Enable test mode. Test mode is unique in that it does not need an API key, but it only works on one URL.
enable_e621(username, app_name, version)[source]

Enable the E621 parser. This allows for looking up tag information on E621.

Parameters:
  • username (str) – An E621 username.
  • app_name (str) – The name of the application.
  • version (str) – The version of the appliation.
index_parser(json)[source]

Parse the output from a succesful saucenao search to retrieve data from specific indexes.

Parameters:json (dict) – JSON output from the API.
Returns:Dictionary containing data that matches the output for SauceNao.search_image_source()
Return type:ImageResult
search_image(url)[source]

Reverse search the engine for url.

Parameters:url (str) – URL to search
Return type:ImageResult
search_tag(tag)[source]

Reverse search the booru for tag data.

Base

This class is the base class for all engines that exist in the application. The attributes and methods listed here should exist in some form on all the previous classes.

class retaggr.engines.Engine[source]

Base class for an engine.

All the engine classes must derive from this class.

Variables:
  • host (str) – The base URL for the reverse image domain. This is not an API endpoint, but can be a link to IQDB or something similar.
  • download_required (bool) – Determines if the search_image() function will download the image to be searched beforehand or not.
  • last_request (datetime.datetime) – Optional. Instance variable that can be set to make use of Booru.sleep_until_ratelimit(). Update after making a request. If you just use the library, this should be done by the engine so there’s no need to manually set it.
search_image(url)[source]

Reverse search the engine for url.

Parameters:url (str) – URL to search
Return type:ImageResult
search_tag(tag)[source]

Reverse search the booru for tag data.