Skip to content

Instantly share code, notes, and snippets.

@7cc
Created January 30, 2019 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7cc/81e66e1391c2d0391c75133c1e211053 to your computer and use it in GitHub Desktop.
Save 7cc/81e66e1391c2d0391c75133c1e211053 to your computer and use it in GitHub Desktop.
// RWBY字幕取り出し
// Google Chromeのコンソールで実行すると、各言語のリンクがコピーされます
fetch($$("video>source")[0].src)
.then(response=> response.text())
.then(getRoosterSub)
.then(copy)
.then(()=> console.log("コピーされました"))
function getRoosterSub(m3u8FileContent) {
return m3u8FileContent.split("\n")
.filter(e=>e.includes("TYPE=SUBTITLES"))
.map(e=>{
return {
lang: e.match(/LANGUAGE="(\w{2})"/)[1],
uri: e.match(/URI="(.+)"/)[1]
}
})
.reduce((p,c)=> {
p[c.lang] = getRealSubURL(c.uri, c.lang)
return p
}, {})
}
function getRealSubURL(subURL, lang) {
// var subURL = "https://rtv3-video.roosterteeth.com/caption_store/34993f30-3c9a-4346-82eb-620bc99d1e4d/en_manifest.m3u8"
// var lang = "en"
let m = `${lang}_manifest.m3u8`
let replacement = `vtt_${lang}.webvtt`
let replaced = subURL.replace(m, replacement)
return replaced
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment