Fetch Twitch VOD MPEG-2 Stream Information
Project description
Twitchvod (v0.1.2)
Installation
pip install twitchvod
Compatibility
This package is python3 compatible. There is no support for python2 currently.
>= python 3.5.2
Please note that this library is to be used at your own risk. Using undocumented api interfaces is against the Twitch terms of service. I take no responsibility if your developer tokens get revoked etc. However, if you would like to learn how this library works, please feel free to read through the source.
Okay now for the more interesting stuff.
This API client will use your provided Twitch developer client_id to make several requests to Twitch API endpoints to fetch information related to a particular VOD. You can even query for all of the MPEG-2 Transport Stream files to which you can download however you wish. For this example, let's say you want to download VOD 372739399.
>>> from twitchvod import Client
# Create client...
>>> client = Client("TWITCH-DEV-APP-CLIENT-ID")
>>> client
<Client>
# Generate access token for VOD 372739399...
>>> token = client.get_access_token(372739399)
>>> token
<AccessToken [372739399-vod_id]>
# Fetch the different vod qualities w/ token...
>>> vods = client.get_vods(token)
>>> vods
[
<Vod [chunked,1920x1080]>,
<Vod [720p60,1280x720]>,
<Vod [720p30,1280x720]>,
<Vod [480p30,852x480]>,
<Vod [audio_only]>,
<Vod [360p30,640x360]>,
<Vod [160p30,284x160]>
]
# Get VOD chunks... There are 364 of them...
>>> vod_chunk = client.get_chunks(vods[0])
>>> vod_chunk
<VodChunk [364-chunks]>
# Get the MPEG-2 transport stream files... Boom!
>>> mpeg2_ts_chunks = [c for c in vod_chunks.chunks()]
>>> mpeg2_ts_chunks[:3]
[
('1988.ts', 'https://vod-metro.twitch.tv/.../chunked/1988.ts'),
('1989.ts', 'https://vod-metro.twitch.tv/.../chunked/1989.ts'),
('1990.ts', 'https://vod-metro.twitch.tv/.../chunked/1990.ts')
]
Development Environment / Setup
This package is early in development, so if anyone has any questions or concerns you can raise a PR or Issue on the github repo.
- Git clone the above repo.
git clone git@github.com:nomadmtb/twitchvod.git
- Move into the project.
cd twitchvod
- Create virtualenv (assuming your have 3.7)
python3.7 -m venv .env
- Activate virtualenv.
source .env/bin/activate
- Install dev requirements.
pip install -r requirements.txt
With the above set-up you can perform the following to get started.
- Run the unittests w/ pytest.
make test
- Run the unittests w/ coverage + pytest.
make coverage
- Install a local copy of the package.
python setup.py install
- Remove the local copy of the package.
pip uninstall twitchvod
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
Built Distribution
File details
Details for the file twitchvod-0.1.2.tar.gz
.
File metadata
- Download URL: twitchvod-0.1.2.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 398c5b8309f3afe5ae5397d524ab6afd71de2ae9b421f19ef7b3c96ddf31a05d |
|
MD5 | a230942b5d481a3a971570e98ce7ea28 |
|
BLAKE2b-256 | f1b8a6b5d58994110dbed5be6f5b56100ca6e27865b2f2f3c1dd0520ce68a2c2 |
File details
Details for the file twitchvod-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: twitchvod-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19bbef43193dcb4f24c5af85404b00460f29062690e1275c579105bd7ba1eb44 |
|
MD5 | a89c45b4c97a92db16b23e149be508e0 |
|
BLAKE2b-256 | 263379984e1336c1bd350f409d6dfe34f83bef9c881619cf9a48d8fad2367a85 |