TVI Play Download

Inclui comando do rtmpdump nas páginas da TVI para fazer download do vídeo.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        TVI Play Download
// @description Inclui comando do rtmpdump nas páginas da TVI para fazer download do vídeo.
// @namespace   daniel-sousa-me
// @include     http://www.tvi.iol.pt/programa/*
// @grant       none
// @version     1.0.1
// ==/UserScript==
// Based on RTP Play Download, since I didn't know how to create GreaseMonkey scripts

var metaTags=document.getElementsByTagName("meta");

var full_video_url = "";
for (var i = 0; i < metaTags.length; i++) {
    if (metaTags[i].getAttribute("property") == "og:video") {
        full_video_url = metaTags[i].getAttribute("content");
        break;
    }
}

var rtmp_dump_cmd = "rtmpdump -e -R -r "+getUrlVars(full_video_url)["streamer"]+"/"+getUrlVars(full_video_url)["file"];

var parentGuest = document.getElementsByClassName("seccao")[0];
// http://stackoverflow.com/questions/7258185/javascript-append-child-after-element/7258301#7258301
parentGuest.parentNode.insertBefore(document.createTextNode(rtmp_dump_cmd), parentGuest.nextSibling);

var a = document.createElement("a");
if (link.length != 0) {
	a.setAttribute("href",link);
	a.appendChild(document.createTextNode("Link Directo"));
}
else {
	a.appendChild(document.createTextNode(flashvars));
}
div_add.appendChild(a);

// http://papermashup.com/read-url-get-variables-withjavascript/
function getUrlVars(url) {
	var vars = {};
	var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
	    vars[key] = decodeURIComponent(value);
	});
	return vars;
}