Pybooru Reference

Pybooru

pybooru.pybooru

This module contains pybooru main class for access to API calls, authentication and return JSON response.

Classes:
_Pybooru – Main pybooru classs, define Pybooru object and do requests.
class pybooru.pybooru._Pybooru(site_name='', site_url='', username='')

Bases: object

Pybooru main class.

site_name

Get or set site name set.

Type:str
site_url

Get or set the URL of Moebooru/Danbooru based site.

Type:str
username

Return user name.

Type:str
last_call

Return last call.

Type:dict
__init__(site_name='', site_url='', username='')

Initialize Pybooru.

Keyword Arguments:
 
  • site_name (str) – The site name in ‘SITE_LIST’, default sites.
  • site_url (str) – URL of on Moebooru/Danbooru based sites.
  • username (str) – Your username of the site (Required only for functions that modify the content).
Raises:

PybooruError – When ‘site_name’ and ‘site_url’ are empty.

site_name

Get or set site name.

Getter:Return site name.
Setter:Validate and set site name.
Type:string
__weakref__

list of weak references to the object (if defined)

site_url

Get or set site url.

Getter:Return site url.
Setter:Validate and set site url.
Type:string
static _get_status(status_code)

Get status message for status code.

Parameters:status_code (int) – HTTP status code.
Returns:status message (str).
_request(url, api_call, request_args, method='GET')

Function to request and returning JSON data.

Parameters:
  • url (str) – Base url call.
  • api_call (str) – API function to be called.
  • request_args (dict) – All requests parameters.
  • method (str) – (Defauld: GET) HTTP method ‘GET’ or ‘POST’
Raises:
  • PybooruHTTPError – HTTP Error.
  • requests.exceptions.Timeout – When HTTP Timeout.
  • ValueError – When can’t decode JSON response.

Exceptions

pybooru.exceptions

This module contains Pybooru exceptions.

Classes:
  • PybooruError – Main Pybooru exception class.
  • PybooruHTTPError – Manages HTTP status errors.
  • PybooruAPIError – Manages all API errors.
exception pybooru.exceptions.PybooruError

Bases: Exception

Class to catch Pybooru error message.

__weakref__

list of weak references to the object (if defined)

exception pybooru.exceptions.PybooruHTTPError(msg, http_code, url)

Bases: pybooru.exceptions.PybooruError

Class to catch HTTP error message.

__init__(msg, http_code, url)

Initialize PybooruHTTPError.

Keyword Arguments:
 
  • msg (str) – The error message.
  • http_code (int) – The HTTP status code.
  • url (str) – The URL.
__str__()

Print exception.

exception pybooru.exceptions.PybooruAPIError

Bases: pybooru.exceptions.PybooruError

Class to catch all API errors.

Resources

pybooru.resources

This module contains all resources for Pybooru.

SITE_LIST (dict):
Contains various Moebooru and Danbooru-based default sites.
HTTP_STATUS_CODE (dict):
Contains http status codes for Moebooru and Danbooru API.