Metadata-Version: 2.1
Name: vadivelu
Version: 1.0.0
Summary: A Python wrapper for accessing the Vadivelu API
Home-page: https://github.com/TheMaster3558/vadivelu
Author: TheMaster3558
License: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Requires-Python: >=3.7.0
Description-Content-Type: text/x-rst
License-File: LICENSE

Vadivelu
========
A Python library for accessing the `Vadivelu API <https://vadivelu.anoram.com/>`_.

Installation
------------
**Must have Python 3.7 or higher**

.. code:: sh

    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
-------

.. code:: python

    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)
