Created
October 13, 2020 19:50
-
-
Save JakeStanger/523b0e6a3d0f3c004482d585fc10754e to your computer and use it in GitHub Desktop.
Download Microsoft Stream Transcript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const videoId = window.location.pathname.replace("/video/", ''); | |
await fetch( | |
`https://euno-1.api.microsoftstream.com/api/videos/${videoId}/events?$filter=Type eq 'transcript'&api-version=1.4-private`, | |
{ | |
headers: { | |
Accept: "application/json", | |
}, | |
credentials: 'include' | |
} | |
) | |
.then(r => r.json()) | |
.then(r => { | |
const text = r.value | |
.filter(entry => entry.type === "transcript") | |
.map(entry => entry.eventData.text.replace(/\r\n/g, ' ')) | |
.join(" "); | |
const element = document.createElement('a'); | |
element.setAttribute( | |
"href", | |
"data:text/plain;charset=utf-8," + encodeURIComponent(text) | |
); | |
element.setAttribute("download", `${/'(.*)'/.exec(document.title)[1]} - Transcript.txt`); | |
element.style.display = "none"; | |
document.body.appendChild(element); | |
element.click(); | |
document.body.removeChild(element); | |
}); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment