2012-11-19, 03:05
Nice!
// Extract video- or playlist-id and send to remote function
// regex from: http://linuxpanda.wordpress.com/2013/07/24/ultimate-best-regex :
function makelink(url) {
videore = /(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))(
[\w\-]{11})[a-z0-9;:@#?&%=+\/\$_.-]*/
listre = /(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([
\w\-]{12,})[a-z0-9;:@#?&%=+\/\$_.-]*/
var videoid = false;
var listid = false;
try {videoid = videore.exec(url)[1];} catch (e) {};
try {listid = listre.exec(url)[1];} catch (e) {};
var notify = document.getElementById('notify');
if (listid) {
Remote('Player.Open','plugin://plugin.video.youtube/?path=/root/playlists&action=play_all&playlist='+listid);
}
else if (videoid) {
Remote('Playlist.Clear','','Playlist.Add','plugin://plugin.video.youtube/?action=play_video&videoid='+videoid,'Player.Open','');
}
else {
notify.style.display = 'block'; setTimeout('notify.style.display = "none";', 1500);
};
}