Skip to content

Instantly share code, notes, and snippets.

@mehdichaouch
Created September 21, 2013 20:43
Show Gist options
  • Save mehdichaouch/6653988 to your computer and use it in GitHub Desktop.
Save mehdichaouch/6653988 to your computer and use it in GitHub Desktop.
Script GreaseMonkey qui aide à trouver les urls (RTMP) des vidéos des replays sur ARTE+7 afin de les downloader avec rtmpdump o/
// ==UserScript==
// @name ARTE+7 Video Downloader vAlpha
// @namespace http://userscripts.org/users/80029 ; http://code.google.com/p/arte-tv-greasemonkey/
// @description ARTE+7 Video Downloader : Currently this UserScript is able to find the RTMP video links of Arte+7 to be downloaded with
// @include http*://videos.arte.tv/*
// @include http*://videos.arte.tv/de/videos/*
// @include http*://videos.arte.tv/en/videos/*
// @include http*://videos.arte.tv/fr/videos/*
// ==/UserScript==
// TEST URL : http://videos.arte.tv/fr/videos/selection_bd-4268822.html
// or any videos on http://videos.arte.tv/
(function () {
var arteDebug = false, videorefFileUrl, arteVideosArray = {};
function init() {
if (arteDebug) { debug(); }
var unsafeWindow = unsafeWindow || window.wrappedJSObject || window;
if (unsafeWindow.vars_player.videorefFileUrl !== null) {
videorefFileUrl = unsafeWindow.vars_player.videorefFileUrl;
}
doXmlHttpRequest(videorefFileUrl, buildLanguagesArray);
displayBanner();
}
// Switch "arteDebug" to "true" to debug
function debug() {
// Leave only top menu
var elem;
(elem = document.getElementById("mast")).style.display = "none";
(elem = document.getElementById("contNav")).style.display = "none";
(elem = document.getElementById("content")).style.display = "none";
(elem = document.getElementById("foot")).style.display = "none";
// Original var wich contain video ref File Url
// console.log(unsafeWindow.vars_player.videorefFileUrl);
}
function displayBanner() {
var quality, links = "", lang, banner;
if (Object.getOwnPropertyNames(arteVideosArray).length !== 0) {
for (quality in arteVideosArray) {
if (arteVideosArray.hasOwnProperty(quality)) {
links += quality.toUpperCase() + ' : ';
for (lang in arteVideosArray[quality]) {
if (arteVideosArray[quality].hasOwnProperty(lang)) {
links += '<a href="' + arteVideosArray[quality][lang] + '">' + lang.toUpperCase() + '</a> ';
}
}
links += " || ";
}
}
links = links.slice(0, -4);
} else {
links = 'Sorry, there is no video to download on this page. Try on <a href="http://videos.arte.tv/">Arte+7</a>.';
}
if (!document.getElementById('arteVideoDownloader')) {
banner = document.createElement('div');
banner.setAttribute('id', 'arteVideoDownloader');
banner.setAttribute('style', 'background-color: #2B2E2E; border-bottom: 1px solid #4B4B4B; color: #242424;' +
'font-size: small; height: 21px; margin: 0 auto 0; padding-top: 1px;');
document.body.insertBefore(banner, document.body.firstChild);
}
document.getElementById('arteVideoDownloader').innerHTML = '<p style="border-bottom: 1px solid #808080; font-weight: bold;' +
'margin: 2px 0; text-align: center;"><span style="color: #FA481C; float: left; padding-left: 2px;">' +
'ARTE+7 Video Downloader <a href="#" title="Get more informations...">' +
'<img src=data:image/gif;base64,R0lGODlhDQAOAJEAANno6wBmZgAAAAAAACH5BAAAAAAALAAAAAANAA4AQAIjjI8Iyw3GhACSQecutsFV3nzgNi' +
'7SVEbo06lZa66LRib2UQAAOw%3D%3D alt="question icon" /></a></span>' +
'<span id="arteLinks" style="color: #8F8F8F;">' + links + '</span>' +
'<span onclick="document.body.removeChild(document.getElementById(\'arteVideoDownloader\'))"' +
' style="float: right; padding: 3px;"><img alt="close" title="Close" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUg' +
'AAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAADtSURBVHjajFC7DkFREJy' +
'9iXg0t+EHRKJDJSqRuIVaJT7AF+jR+xuNRiJyS8WlRaHWeOU+kBy7eyKhs8lkJrOzZ3OWzMAD15gxYhB+yzAm0ndez+eYMYLngdkIf2vpSYbCfsNkOx07' +
'n8kgWa1UpptNII5VR/M56Nyt6Qq33bbhQsHy6aR0WSyEyEmiCG6vR2ffB65X4HCwYC2e9CTjJGGok4/7Hcjl+ImLBWv1uCRDu3peV5eGQ2C5/P1zq4X9d' +
'GpXP+LYhmYz4HbDMQgUosWTnmQoKKf0htVKBZvtFsx6S9bm48ktaV3EXwd/CzAAVjt+gHT5me0AAAAASUVORK5CYII%3D"></span></p>';
}
function getXmlHttpRequestObject() {
var xmlhttp;
if (typeof window.XMLHttpRequest !== 'undefined') {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else if (typeof window.ActiveXObject) {// code for IE6, IE5
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
} catch (ex1) {
try {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
} catch (ex2) {
}
}
}
return xmlhttp;
}
function doXmlHttpRequest(url, handlerFunction) {
var request = getXmlHttpRequestObject();
// we use synchronous transfer when we need to wait for the field
// update to finish executing while closing a form, async in all other cases
request.onreadystatechange = function handleValidatorFeedback(evt) {
if (request.readyState === 4 && request.status === 200) {
handlerFunction(request.responseXML);
// handlerFunction(request.responseText);
}
};
request.open('GET', url, false);
request.setRequestHeader("Content-type", "text/xml");
request.send(null);
}
function buildLanguagesArray(videorefLangFile) {
var videos, i;
videos = (videorefLangFile.getElementsByTagName('videos')[0]).getElementsByTagName('video');
for (i = 0; i < videos.length; i++) {
doXmlHttpRequest(videos[i].attributes.ref.value, buildVideosArray);
}
}
function buildVideosArray(videorefQualityFile) {
var lang, urls, i, quality, link;
lang = videorefQualityFile.firstChild.attributes.lang.value;
urls = (videorefQualityFile.getElementsByTagName('urls')[0]).getElementsByTagName('url');
for (i = 0; i < urls.length; i++) {
quality = urls[i].attributes.quality.nodeValue;
link = urls[i].firstChild.nodeValue;
if (!arteVideosArray[quality]) {arteVideosArray[quality] = {}; }
arteVideosArray[quality][lang] = link;
}
}
function addLoadListener(func) {
if (window.addEventListener) {
window.addEventListener("load", func(), false);
} else if (document.addEventListener) {
document.addEventListener("load", func(), false);
} else if (window.attachEvent) {
window.attachEvent("onload", func());
}
}
if (document.getElementById && document.createTextNode) {
addLoadListener(init);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment