Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Internet Content: Update Dailymotion grabber to allow remote control.

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...
commit 1b639d7a1d12dde1f91411b3f2f01334070f79bd 1 parent 5b7b93d
Robert McNamara authored
View
89 mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/dailymotion.html
@@ -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>
View
8 mythtv/programs/scripts/internetcontent/nv_python_libs/dailymotion/dailymotion_api.py
@@ -37,6 +37,7 @@
import os, struct, sys, re, time
import urllib, urllib2
import logging
+from MythTV import MythXML
try:
import xml.etree.cElementTree as ElementTree
@@ -147,6 +148,7 @@ def __init__(self,
"""
self.config = {}
+ self.mythxml = MythXML()
if apikey is not None:
self.config['apikey'] = apikey
@@ -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):
'''Key word video search of the Dailymotion web site
@@ -927,7 +933,7 @@ def getVideosForURL(self, url, dictionaries):
for elem in e:
if elem.tag.endswith('content') and elem.get('type') == 'application/x-shockwave-flash':
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'):
meta_data['duration'] = elem.get('duration').strip()
if elem.get('width'):
Please sign in to comment.
Something went wrong with that request. Please try again.