Skip to content

Commit

Permalink
Internet Content: Update Dailymotion grabber to allow remote control.
Browse files Browse the repository at this point in the history
Dailymotion is painfully slow and has a tendency to start playing before it has nearly enough buffered, but it does work, as do all the supported controls.
  • Loading branch information
Robert McNamara committed Dec 8, 2010
1 parent 5b7b93d commit 1b639d7
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 1 deletion.
@@ -0,0 +1,89 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<style type="text/css">
body {
padding: 0;
margin: 0;
}
</style>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
/* gup function by R.D. Vaughan */
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}

var myth_player = null;
var videocode = gup('videocode');

var params = {
allowScriptAccess: "always",
allowfullscreen: 'true',
wmode: 'opaque'
};

var flashvars = {
autoStart: 1
};

var atts = { id: "mydmplayer" };

swfobject.embedSWF('http://www.dailymotion.com/swf/' + videocode + '&enableApi=1&playerapiid=dmplayer&autoPlay=1',
"myth_player", window.innerWidth, window.innerHeight, "8", null, flashvars, params, atts);

function onDailymotionPlayerReady(playerId) {
myth_player = document.getElementById("mydmplayer");
myth_player.setVolume(50);
if (videocode != "") {
myth_player.loadVideoById(videocode);
myth_player.playVideo();
}
}

function play() {
if (myth_player) {
var state = myth_player.getPlayerState();
if (state == 1) // Playing
myth_player.pauseVideo();
else if (state != 3) // Video is either unstarted, ended, paused or cued
myth_player.playVideo();
}
}

function seek(amount) {
if (myth_player) {
myth_player.seekTo(myth_player.getCurrentTime() + amount);
}
}

function adjustVolume(amount) {
if (myth_player) {
myth_player.setVolume(myth_player.getVolume() + amount);
}
}

window.onresize = function() {
document.body.style.width = window.innerWidth;
document.body.style.height = window.innerHeight;
if (myth_player) {
// myth_player.setSize(window.innerWidth, window.innerHeight);
document.getElementById("mydmplayer").width = window.innerWidth;
document.getElementById("mydmplayer").height = window.innerHeight;
}
};
</script>
</head>
<body>
<div id="myth_player"/>
</body>
</html>
Expand Up @@ -37,6 +37,7 @@
import os, struct, sys, re, time import os, struct, sys, re, time
import urllib, urllib2 import urllib, urllib2
import logging import logging
from MythTV import MythXML


try: try:
import xml.etree.cElementTree as ElementTree import xml.etree.cElementTree as ElementTree
Expand Down Expand Up @@ -147,6 +148,7 @@ def __init__(self,
""" """
self.config = {} self.config = {}
self.mythxml = MythXML()


if apikey is not None: if apikey is not None:
self.config['apikey'] = apikey self.config['apikey'] = apikey
Expand Down Expand Up @@ -697,6 +699,10 @@ def setTreeViewIcon(self, dir_icon=None):
# #
########################################################################################################### ###########################################################################################################


def processVideoUrl(self, url):
playerUrl = self.mythxml.getInternetContentUrl("nv_python_libs/configs/HTML/dailymotion.html", \
url.replace(u'http://www.dailymotion.com/swf/video/', ''))
return self.ampReplace(playerUrl)


def searchTitle(self, title, pagenumber, pagelen): def searchTitle(self, title, pagenumber, pagelen):
'''Key word video search of the Dailymotion web site '''Key word video search of the Dailymotion web site
Expand Down Expand Up @@ -927,7 +933,7 @@ def getVideosForURL(self, url, dictionaries):
for elem in e: for elem in e:
if elem.tag.endswith('content') and elem.get('type') == 'application/x-shockwave-flash': if elem.tag.endswith('content') and elem.get('type') == 'application/x-shockwave-flash':
if elem.get('url'): if elem.get('url'):
meta_data['video'] = self.ampReplace((elem.get('url')+u'?autoPlay=1')) meta_data['video'] = self.processVideoUrl(elem.get('url'))
if elem.get('duration'): if elem.get('duration'):
meta_data['duration'] = elem.get('duration').strip() meta_data['duration'] = elem.get('duration').strip()
if elem.get('width'): if elem.get('width'):
Expand Down

0 comments on commit 1b639d7

Please sign in to comment.