- I developed YouTube subtitle extraction.
My program fetches subtitles for 'user selected language'.
- However, there were so many languages ??to choose from.
- So, I used the link below to get the 'subtitles language list of for the video'.
http://video.google.com/timedtext?v=${youtubeID}&type=list
http://video.google.com/timedtext?v=oIa3BFBHJFI&type=list (example)
my code:
fetch(`http://video.google.com/timedtext?v=${youtubeID}&type=list`
.then(res => res.text()) // 1. xml -> get text
.then(str => (new window.DOMParser()).parseFromString(str, "text/xml")) // 2. text -> xml
.then(data => {
let tempLanguageList = [];
let xml = data.getElementsByTagName("transcript_list")[0];
// get language
for (let i = 0; i < xml.childElementCount; i++) {
let item = xml.children.item(i); // ??: <track id=?"22" name lang_code=?"en" lang_original=?"English" lang_translated=?"English" lang_default=?"true">?</track>?
let itemObject = item.getAttribute("lang_code") + ", " + item.getAttribute("lang_original")
tempLanguageList.push(itemObject); // ex) en
}
console.log("tempLanguageList: ", tempLanguageList);
})
result:
- However, the automatic subtitles were not displayed in the link above.
(add)
For example, https://youtu.be/D_M9fl_Cj9I in this video,'english' is an automatic subtitle and 'korea' is a manual subtitle.
But when I check it, english did not appear on the list.
http://video.google.com/timedtext?v=D_M9fl_Cj9I&type=list
[question]
How can I check the 'language list of automatic subtitles' for a specific YouTube video?
question from:
https://stackoverflow.com/questions/65895932/how-to-find-out-youtube-auto-subtitle-language-with-javascript-get-auto-capt 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…