subs
This commit is contained in:
parent
b4dfb3e597
commit
12ac6cad39
1 changed files with 21 additions and 2 deletions
|
@ -10,7 +10,7 @@ from rwx import Object
|
||||||
from rwx.fs import read_file_yaml
|
from rwx.fs import read_file_yaml
|
||||||
from rwx.log import stream as log
|
from rwx.log import stream as log
|
||||||
|
|
||||||
EXT = "webm"
|
SUBTITLES_EXTENSIONS = ["vtt"]
|
||||||
TIMESTAMP = "%Y%m%d%H%M%S"
|
TIMESTAMP = "%Y%m%d%H%M%S"
|
||||||
URL = "https://youtube.com"
|
URL = "https://youtube.com"
|
||||||
|
|
||||||
|
@ -135,6 +135,20 @@ class Playlist(Object):
|
||||||
self.title = d["title"]
|
self.title = d["title"]
|
||||||
|
|
||||||
|
|
||||||
|
class Subtitles(Object):
|
||||||
|
"""YouTube subtitles."""
|
||||||
|
|
||||||
|
def __init__(self, uid: str, d: dict) -> None:
|
||||||
|
"""Set subtitles info.
|
||||||
|
|
||||||
|
:param d: subtitles info
|
||||||
|
:type d: dict
|
||||||
|
"""
|
||||||
|
self.uid = uid
|
||||||
|
self.extension = d["ext"]
|
||||||
|
self.name = d["name"]
|
||||||
|
|
||||||
|
|
||||||
# TODO Thumbnail
|
# TODO Thumbnail
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,7 +189,12 @@ class Video(Object):
|
||||||
self.categories = d["categories"]
|
self.categories = d["categories"]
|
||||||
self.tags = d["tags"]
|
self.tags = d["tags"]
|
||||||
# TODO automatic_captions
|
# TODO automatic_captions
|
||||||
# TODO subtitles
|
self.subtitles = []
|
||||||
|
for uid, entries in d["subtitles"].items():
|
||||||
|
for entry in entries:
|
||||||
|
subtitles = Subtitles(uid, entry)
|
||||||
|
if subtitles.extension in SUBTITLES_EXTENSIONS:
|
||||||
|
self.subtitles.append(subtitles)
|
||||||
self.chapters = d["chapters"]
|
self.chapters = d["chapters"]
|
||||||
self.likes = d["like_count"]
|
self.likes = d["like_count"]
|
||||||
self.timestamp = datetime.fromtimestamp(d["timestamp"]).strftime(
|
self.timestamp = datetime.fromtimestamp(d["timestamp"]).strftime(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue