Created
May 8, 2017 19:19
-
-
Save Tobiaqs/5d20e52cf803e259f12a83d16168a501 to your computer and use it in GitHub Desktop.
A script that leeches video files off of the TU/e's videocollege site. This is useful when you don't have a Windows PC, and hence can't use the site.
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
(function () { | |
let payload = { | |
getPlayerOptionsRequest: { | |
ResourceId: location.pathname.split('/').reverse()[0], | |
QueryString: location.search, | |
UseScreenReader: false, | |
UrlReferrer: document.referrer | |
} | |
}; | |
fetch("/Mediasite/PlayerService/PlayerService.svc/json/GetPlayerOptions", { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json" | |
}, | |
body: JSON.stringify(payload), | |
credentials: "include" | |
}).then((response) => { | |
return response.json(); | |
}, (error) => { | |
alert("An error occurred. See console for details."); | |
console.log(error); | |
}).then((json) => { | |
if (!json || !json.d || !json.d.Presentation || !json.d.Presentation.Streams) { | |
alert("Unusable data received. See console for a dump."); | |
console.log(json); | |
return; | |
} | |
let stream = json.d.Presentation.Streams.find((stream) => { | |
return stream.VideoUrls.length > 0; | |
}); | |
if (!stream) { | |
alert("No video stream found."); | |
return; | |
} | |
let a = document.createElement('A'); | |
a.download = json.d.Presentation.Title; | |
a.href = stream.VideoUrls[0].Location; | |
a.click(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment