Api wrapper for coub.com
Project description
===============================
Api-wrapper for coub.com
===============================
.. image:: https://travis-ci.com/Derfirm/coub_api.svg?branch=master
:target: https://travis-ci.com/Derfirm/coub_api
:alt: Build Status
.. image:: https://codecov.io/gh/Derfirm/coub_api/branch/master/graph/badge.svg
:target: https://codecov.io/gh/Derfirm/coub_api
:alt: Coverage Status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black
:alt: Codestyle: Black
Key Features
============
- response are fully-annotated with pydantic
- test work on snapshots from real http-answers (can easy inspect responses)
Getting started
===============
Initiate Api client
________
.. code-block:: python
from coub_api import CoubApi
api = CoubApi()
access_token = "<your access token>"
api.authenticate(access_token) # required for some authenticated requests
Get coub details
________________
.. code-block:: python
coub = api.coubs.get_coub("1jf5v1")
print(coub.id, coub.channel_id)
Create Coub
___________
.. code-block:: python
api.coubs.init_upload()) # {"permalink":"1jik0b","id":93927327}
api.coubs.upload_video(93927327, "video.mp4")
api.coubs.upload_audio(93927327, "audio.mp3"))
api.coubs.finalize_upload(93927327, title="Awesome CAT", tags=["cat", "animal"]))
api.coubs.get_upload_status(93927327)) # {"done": False, "percent_done": 0}
# wait a minute
api.coubs.get_upload_status(93927327)) # {"done": True, "percent_done": 100}
Get weekly hot coubs
___________
.. code-block:: python
from coub_api.schemas.constants import Period
api.timeline.hot(period=Period.WEEKLY, order_by="likes_count")
Get 5 page of random section with cars
___________
.. code-block:: python
from coub_api.schemas.constants import Section, Category
current_page = 1
max_page = 5
while current_page <= max_page:
response = api.timeline.section(section=Section.RANDOM, category=Category.CARS, per_page=30, page=current_page)
print(f"processing {current_page} of {max_page}")
for coub in response.coubs:
print(coub.permalink)
current_page += 1
max_page = min(max_page, response.total_pages)
Api-wrapper for coub.com
===============================
.. image:: https://travis-ci.com/Derfirm/coub_api.svg?branch=master
:target: https://travis-ci.com/Derfirm/coub_api
:alt: Build Status
.. image:: https://codecov.io/gh/Derfirm/coub_api/branch/master/graph/badge.svg
:target: https://codecov.io/gh/Derfirm/coub_api
:alt: Coverage Status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/ambv/black
:alt: Codestyle: Black
Key Features
============
- response are fully-annotated with pydantic
- test work on snapshots from real http-answers (can easy inspect responses)
Getting started
===============
Initiate Api client
________
.. code-block:: python
from coub_api import CoubApi
api = CoubApi()
access_token = "<your access token>"
api.authenticate(access_token) # required for some authenticated requests
Get coub details
________________
.. code-block:: python
coub = api.coubs.get_coub("1jf5v1")
print(coub.id, coub.channel_id)
Create Coub
___________
.. code-block:: python
api.coubs.init_upload()) # {"permalink":"1jik0b","id":93927327}
api.coubs.upload_video(93927327, "video.mp4")
api.coubs.upload_audio(93927327, "audio.mp3"))
api.coubs.finalize_upload(93927327, title="Awesome CAT", tags=["cat", "animal"]))
api.coubs.get_upload_status(93927327)) # {"done": False, "percent_done": 0}
# wait a minute
api.coubs.get_upload_status(93927327)) # {"done": True, "percent_done": 100}
Get weekly hot coubs
___________
.. code-block:: python
from coub_api.schemas.constants import Period
api.timeline.hot(period=Period.WEEKLY, order_by="likes_count")
Get 5 page of random section with cars
___________
.. code-block:: python
from coub_api.schemas.constants import Section, Category
current_page = 1
max_page = 5
while current_page <= max_page:
response = api.timeline.section(section=Section.RANDOM, category=Category.CARS, per_page=30, page=current_page)
print(f"processing {current_page} of {max_page}")
for coub in response.coubs:
print(coub.permalink)
current_page += 1
max_page = min(max_page, response.total_pages)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
coub_api-0.1.1a0.tar.gz
(11.6 kB
view hashes)
Built Distribution
coub_api-0.1.1a0-py3-none-any.whl
(44.1 kB
view hashes)
Close
Hashes for coub_api-0.1.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61b50c6f0611e872622a5f391d940bc4307275261ddfe2e5207f2cf73e127653 |
|
MD5 | d60de64b136e79055c2927d36d707270 |
|
BLAKE2b-256 | 8a3241788d1c3511d1267c1d2fab942e8412d0ce1f4d8d570715e9d9773d0b7d |