-
-
Save uahim/e74b1f7e938fe7e8a1ae1c720d72150f to your computer and use it in GitHub Desktop.
basic tampermonkey js to get video url
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
// ==UserScript== | |
// @name teka artedownloader | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.arte.tv/de/videos/* | |
// @match https://www.arte.tv/fr/videos/* | |
// @grant GM_download | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var loc = window.location.pathname.split('/'); | |
var lang = loc[1]; | |
console.log("----------- DWNL started ------------"); | |
let api_base = " https://api.arte.tv/api/player/v1/config/" +lang + "/"; | |
var id = loc[3]; | |
var name = loc[4]; | |
var download_url = api_base + id; | |
console.log("----------- download-url", download_url); | |
window.onload = function () { | |
var para = document.createElement("a"); | |
para.setAttribute('id', 'dwnl'); | |
para.setAttribute('style', 'color: #FFF'); | |
var node = document.createTextNode("Download"); | |
para.appendChild(node); | |
document.getElementsByClassName('metas-infos')[0].insertBefore(para, null); | |
var getJSON = function(url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', url, true); | |
xhr.responseType = 'json'; | |
xhr.onload = function() { | |
var status = xhr.status; | |
if (status == 200) { | |
callback(null, xhr.response); | |
} else { | |
callback(status); | |
} | |
}; | |
xhr.send(); | |
}; | |
getJSON(download_url, function(err, data) { | |
if (err != null) { | |
console.error(err); | |
} else { | |
if (lang == "de") { | |
down_url = data.videoJsonPlayer.VSR.HTTPS_SQ_1.url; | |
} else if (lang == "fr") { | |
down_url = data.videoJsonPlayer.VSR.HTTPS_SQ_2.url; | |
} | |
} | |
}); | |
document.getElementById('dwnl').addEventListener("click", function(){ | |
console.log("will download: ", down_url); | |
// document.getElementById('dwnl').textContent = down_url; | |
document.getElementById('dwnl').setAttribute('href', down_url); | |
}); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment