Constructor
class Subtitles(lang_code, lang_name, ext, url, autogenerated)
Represents a subtitle file for a video.
Parameters:
| lang_code |
str |
The language code. ('en', 'es') |
| lang_name |
str |
The name of the language. ('English' or 'Spanish') |
| ext |
str |
The file extension of the subtitle. ('vtt') |
| url |
str |
The URL of the subtitle file. |
| autogenerated |
bool |
Auto-generated or manual. |
Properties
The humanized name of the language.
The file extension of the subtitle file.
The URL for the subtitle file.
autogenerated
bool
Auto-generated or manual.
Example
pip install prettytable
import MyTube
from prettytable import PrettyTable
yt = MyTube.YouTube("https://www.youtube.com/watch?v=Xj0Jtjg3lHQ")
t = PrettyTable(['Lang', 'Name', 'Extension', 'URL'])
for lang_code, subs in yt.subtitles:
for sub in subs:
t.add_row([sub.lang, sub.name, sub.extension, sub.url])
print(t)
+---------+----------------------+-----------+-------------------------+
| Lang | Name | Extension | URL |
+---------+----------------------+-----------+-------------------------+
| ar | Arabic | vtt | www.youtube.com/api/... |
| zh-hans | Chinese (Simplified) | vtt | www.youtube.com/api/... |
| en | English | vtt | www.youtube.com/api/... |
| fr | French | vtt | www.youtube.com/api/... |
| de | German | vtt | www.youtube.com/api/... |
| hi | Hindi | vtt | www.youtube.com/api/... |
| id | Indonesian | vtt | www.youtube.com/api/... |
| it | Italian | vtt | www.youtube.com/api/... |
| ja | Japanese | vtt | www.youtube.com/api/... |
| ko | Korean | vtt | www.youtube.com/api/... |
| pl | Polish | vtt | www.youtube.com/api/... |
| pt | Portuguese | vtt | www.youtube.com/api/... |
| ru | Russian | vtt | www.youtube.com/api/... |
| es | Spanish | vtt | www.youtube.com/api/... |
| th | Thai | vtt | www.youtube.com/api/... |
| tr | Turkish | vtt | www.youtube.com/api/... |
| vi | Vietnamese | vtt | www.youtube.com/api/... |
+---------+----------------------+-----------+-------------------------+