How to get the transcription grouped by chapters? #225
Unanswered
viniciusarruda
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Hi @viniciusarruda, this module does not support retrieving chapters. You would have to find some other way to find out the chapters and then group them retrieved transcript by their timestamps. |
Beta Was this translation helpful? Give feedback.
2 replies
-
I had the same goal to retrieve chapters titles and timestamps, here's how I've managed to extract chapters : #"start" field is in millis you can easily convert
def extract_chapter_info(obj):
return {
"title": obj.get("chapterRenderer").get("title").get("simpleText"),
"start": obj.get("chapterRenderer").get("timeRangeStartMillis"),
}
def _extract_chapters_json(self, html, video_id):
splitted_html = html.split('"chapters":')
# HANDLE NO CHAPTERS SCENARIO AS YOU LIKE
chapters_json = json.loads(
splitted_html[1].split(',"trackingParams"')[0].replace("\n", "")
)
return list(map(extract_chapter_info, chapters_json)) This is basically the same of hope this helps :) don't know if this could become a PR |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How to get the transcription grouped by chapters?
Or, an alternative way to get the video chapters range and title.
Beta Was this translation helpful? Give feedback.
All reactions