Skip to content

Instantly share code, notes, and snippets.

@omeryagmurlu
Created November 11, 2022 16:28
Show Gist options
  • Save omeryagmurlu/6ad2f5cc2f7e5fd6fe4c5e394d54bee6 to your computer and use it in GitHub Desktop.
Save omeryagmurlu/6ad2f5cc2f7e5fd6fe4c5e394d54bee6 to your computer and use it in GitHub Desktop.
KIT Ilias 7 downloader for lecture videos using aria2c
function ilias --description 'cli companion for ilias vid downloader userscript' --argument b64
base64 -d (echo "$b64" | psub) | aria2c --file-allocation=none -R --http-accept-gzip=true --auto-file-renaming=false -x16 -j30 --input-file -
end
// ==UserScript==
// @name ilias generate download button
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://ilias.studium.kit.edu/**
// @grant none
// ==/UserScript==
const stuff = async function() {
'use strict';
const resp = (await Promise.all(Array.from(document.querySelectorAll("a"))
.filter(a => a.innerHTML == "Abspielen")
.map(a => fetch(a.href).then(a => a.text()))))
.map(h => h.split('xoctPaellaPlayer.init(')[1].split(')\n</script>')[0])
.map(a => JSON.parse(`[${a}]`)[0])
.map(j => ({ title: j.metadata.title.replace(/[^\x00-\x7F/]/g, '').replace(':', '').replace('/', '')+'.mp4', src: j.streams[0].sources.mp4[0].src}))
const text = resp.map(({title, src}) => `${src}\n\tout=${title}`).join('\n')
return text;
};
const fn = async () => {
if (document.getElementById('xoct_waiter').style.display != "none") {
window.clearTimeout(timeout)
timeout = window.setTimeout(fn, 500)
return
}
const t = await stuff();
if (t == '') {
window.clearTimeout(timeout)
timeout = window.setTimeout(fn, 500)
return
}
window.clearTimeout(timeout);
console.log(btoa(t))
buttonUp(btoa(t))
}
let timeout = window.setTimeout(fn, 5000)
const buttonUp = t => {
const but = document.createElement('button')
but.appendChild(document.createTextNode('get via ilias cli'))
but.className = 'btn btn-default'
but.onclick = () => navigator.clipboard.writeText(t)
const div = document.createElement('div')
div.className = 'navbar-text'
div.appendChild(but)
document.querySelector("#tb-collapse-2 .ilToolbarGroup").appendChild(div)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment