Skip to content

Instantly share code, notes, and snippets.

@steelman
Last active April 17, 2018 09:45
Show Gist options
  • Save steelman/3cd40454ed2a0aeaa7d158ad96db1670 to your computer and use it in GitHub Desktop.
Save steelman/3cd40454ed2a0aeaa7d158ad96db1670 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @include http://audycje.tokfm.pl/*
// @description Wyciąga bezpośrednie linki do plików mp3
// @author Marek Drwota
// ==/UserScript==
function zm() {
var podcasts_data=document.getElementsByClassName('tok-topwrap__topwrap tok-topwrap__topwrap--podcast');
var linki = null;
var i = 0;
if (podcasts_data != null) {
linki = podcasts_data[i].getElementsByClassName('tok-topwrap__button--play tok-js__play')[0].getAttribute('data-id');
var file_id = location.href.match('[0-9]+$');
podcasts_data[i].innerHTML = podcasts_data[i].innerHTML + '<div>curl \'http://audycje.tokfm.pl/gets\' --data-binary \'{"pid":' + file_id + ',"st":"tokfm"}\' | jq -r .url | xargs curl -o ' + file_id + '.mp3</div>';
}
podcasts_data = document.getElementById('col_left');
linki = podcasts_data.getElementsByTagName('li');
for (i=0;i<linki.length;i+=1) {
if (linki[i].hasAttribute('class') &&
(linki[i].getAttribute('class') === "tok-podcasts__podcast")) {
var file_id = linki[i].getElementsByTagName('a')[2].href.match('[0-9]+$');
if (file_id === null) {
continue;
} else {
file_id = file_id[0];
}
linki[i].innerHTML = linki[i].innerHTML + '<div>curl \'http://audycje.tokfm.pl/gets\' --data-binary \'{"pid":' + file_id + ',"st":"tokfm"}\' | jq -r .url | xargs curl -o ' + file_id + '.mp3</div>';
}
}
}
zm();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment