Skip to main content

A Python wrapper for accessing the Vadivelu API

Project description

A Python library for accessing the Vadivelu API.

Installation

Must have Python 3.7 or higher

pip install vadivelu

API Reference

vadivelu.get_available_formats(code)

Get the available formats for a HTTP code. The formats can be gif, jpg, or both.

Parameters

code: int

The HTTP code to use

Returns

Tuple[str, str] A tuple containing the avaiable formats

Raises

ValueError if the code provided is not supported by the API

pick_available_format(code, priority)

Pick a format (gif or jpg) that the API supports for a specific HTTP code.

Parameters

code: int

The HTTP code to use

priority: str

The format to pick in the case both gif and jpg are available, defaults to gif

Returns

str The chosen format (gif or jpg)

Raises

ValueError if the code provided is not supported by the API or if priority is not gif or jpg

get_media_url(code, media_format)

Get the media URL for the specified code in the specified format.

Parameters

code: int

The HTTP code to use

media_format: str

The media format to get (gif or jpg)

Returns

str Theurl for the media

Raises

ValueError media_format is not available for the given code, use pick_available_format to avoid this error

Example

import requests
import vadivelu

code = 404
url = vadivelu.get_media_url(code, vadivelu.pick_available_format(code, 'jpg'))

# save jpg to 404.jpg file
with open('404.jpg', 'wb') as f:
    f.write(requests.get(url).content)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vadivelu-1.0.0.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file vadivelu-1.0.0.tar.gz.

File metadata

  • Download URL: vadivelu-1.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for vadivelu-1.0.0.tar.gz
Algorithm Hash digest
SHA256 37312aa403d9815c289b55abd2a642f5573b6e3283d589df9e23c63edc193bbf
MD5 c7504230303e708381ce3aa333f2cd63
BLAKE2b-256 43890fb472930ab087c4ef32f155f773b8eaabc46f3ede013c52088ebced366c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page