Skip to main content

YTSAPI

YTSAPI (YouTube Transcribe API) for The Abuse Project is a python API (Application Programming Interface) which allows you to get the transcript/subtitle for a given YouTube video in a nice list consisting of dictionaries. It also works for videos which have automatically generated subtitles. It does not use any hacky mechanisms.

Install

For using this library in your project, simple use pip to install the module.

pip install ytsapi

The module published is in it's early stage as of now, as it's being used internally in The Abuse Project. If you want to develop it further, you'll have to use this source repository.

git clone https://github.com/theabuseproject/YTSAPI.git

After cloning, install the dependencies using pip,

pip install -r requirements.txt

Usage

The implemented API class can be found under ytsapi/ytsapi.py.

import ytsapi
ytsapi.YTSAPI.get_transcript("Youtube Video ID")

Example Usage

Obtaining transcript of a YouTube video

>>> import ytsapi
>>> video = 'http://www.youtube.com/watch?v=BaW_jenozKc'
>>> video_id = video.split('?v=')[1]
>>> video_subtitles = ytsapi.YTSAPI.get_transcript(video_id)
>>> print(video_subtitles)
[{'text': 'This a test video\nfor youtube-dl', 'start': 0.26, 'duration': 3.33}, {'text': 'For more information\ncontact phihag@phihag.de', 'start': 3.59, 'duration': 6.08}]
>>>
>>> type(video_subtitles)
<class 'list'>
>>> type(video_subtitles[0])
<class 'dict'>
>>>

Downloading a YouTube video

>>> import ytsapi
>>> ytsapi.YTSAPI.get_video('BaW_jenozKc')
YoutubeDL - Starting the download (BaW_jenozKc)
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading video info webpage
WARNING: Unable to extract video title
[download] BaW_jenozKc.mp4 has already been downloaded
[download] 100% of 1.74MiB
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading video info webpage
WARNING: Unable to extract video title
[download] BaW_jenozKc.mp4 has already been downloaded
[download] 100% of 1.74MiB
YoutubeDL - Writing video in current working directory.
YoutubeDL - Done.
>>>

Metadata

Release files for YTSAPI 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for YTSAPI 0.1.1
File Size Uploaded
YTSAPI-0.1.1.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for YTSAPI 0.1.1
File Interpreter ABI Platform
YTSAPI-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.2 kB

Release files / YTSAPI-0.1.1.tar.gz

Download URL YTSAPI-0.1.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e843fdebd0a9f1d659549951e7159ecca282e9ff7d41b5c52e7beb8cd87f9e0b
BLAKE2b-256 checksum
How to use checksums
7a184c77b02286967c700ac71e49cce5e3f93bc1fe068ca474c1582ca7a45fb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.11.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / YTSAPI-0.1.1-py3-none-any.whl

Download URL YTSAPI-0.1.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ec766918f84f8aa349ee7812a6c95152e35e80a6578f26bad001fdabec677b9
BLAKE2b-256 checksum
How to use checksums
4c6157cfce4f2a6db056cb8f39f5001b5d836612802559754cbd2579675d83b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.11.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page