summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert McNamara <rmcnamara@mythtv.org>2010-11-17 20:25:37 (GMT)
committer Robert McNamara <rmcnamara@mythtv.org>2010-11-17 20:25:37 (GMT)
commit695018a83a9251cabda0a212028cea61677931ae (patch)
treea41b64f11df340556a9e1d27fdcc179073a71ee4
parent2bccadda2a82a49c5792caff00f873b9df37e802 (diff)
Update MTV content script to accomodate API changes. Patch from Doug Vaughan.
git-svn-id: http://svn.mythtv.org/svn/trunk@27260 7dbf422c-18fa-0310-86e9-fd20926502f2
-rw-r--r--mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/mtv.html39
-rwxr-xr-xmythtv/programs/scripts/internetcontent/nv_python_libs/mtv/mtv_api.py18
2 files changed, 53 insertions, 4 deletions
diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/mtv.html b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/mtv.html
new file mode 100644
index 0000000..f8d68aa
--- a/dev/null
+++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/mtv.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<html>
+ <head>
+ <!-- Author: R.D. Vaughan
+ Nov 17th, 2010
+ Purpose: Implement full screen browser video display for MTV Videos
+ Example:
+ file:///usr/local/share/mythtv/mythnetvision/scripts/nv_python_libs/configs/HTML/mtv.html?title=We%20Are%20The%20One&videocode=176000
+ -->
+ <script type="text/javascript">
+ 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 pageTitle = gup( 'title' );
+ if (pageTitle != "")
+ pageTitle = 'MTV: '+unescape(pageTitle);
+ var videocode = gup( 'videocode' );
+ var image = gup( 'image' );
+
+ var embedded = '<object style="visibility: visible;" data="http://media.mtvnservices.com/mgid:uma:video:mtv.com:VIDEOCODE" name="embeddedPlayer" id="embeddedPlayer" type="application/x-shockwave-flash" height="100%" width="100%"><param value="true" name="allowFullScreen"><param value="always" name="allowScriptAccess"><param value="transparent" name="wmode"><param value="true" name="swliveconnect"><param value="#000000" name="bgcolor"><param value="sid=MTV_Videos&amp;configParams=instance%3Dmtv%26vid%3DVIDEOCODE%26id%3D1572737&amp;autoPlay=true" name="flashvars"></object>'
+
+ document.write('<title>'+pageTitle+'</title>');
+ embedded = embedded.replace(/VIDEOCODE/g, videocode)
+ embedded = embedded.replace(/IMAGE/g, image)
+
+ document.write(embedded);
+
+ </script>
+ </head>
+</html>
diff --git a/mythtv/programs/scripts/internetcontent/nv_python_libs/mtv/mtv_api.py b/mythtv/programs/scripts/internetcontent/nv_python_libs/mtv/mtv_api.py
index 2800cc9..47612f2 100755
--- a/mythtv/programs/scripts/internetcontent/nv_python_libs/mtv/mtv_api.py
+++ b/mythtv/programs/scripts/internetcontent/nv_python_libs/mtv/mtv_api.py
@@ -19,7 +19,7 @@ metadata, video and image URLs from MTV. These routines are based on the api. Sp
for this api are published at http://developer.mtvnservices.com/docs
'''
-__version__="v0.2.4"
+__version__="v0.2.5"
# 0.1.0 Initial development
# 0.1.1 Added Tree View Processing
# 0.1.2 Modified Reee view code and structure to be standandized across all grabbers
@@ -33,6 +33,7 @@ __version__="v0.2.4"
# Removed the import and use of the feedparser library
# 0.2.3 Fixed an exception message output code error in two places
# 0.2.4 Removed the need for python MythTV bindings and added "%SHAREDIR%" to icon directory path
+# 0.2.5 Use MTV web page as API not returning valid URLs
import os, struct, sys, re, time
from datetime import datetime, timedelta
@@ -238,6 +239,8 @@ class Videos(object):
'genres': {'Genres': 'directories/topics/music','world_reggae': 'directories/music_genres/world_reggae', 'pop': 'directories/music_genres/pop', 'metal': 'directories/music_genres/metal', 'environmental': 'directories/music_genres/environmental', 'latin': 'directories/music_genres/latino', 'randb': 'directories/music_genres/rnb', 'rock': 'directories/music_genres/rock', 'easy_listening': 'directories/music_genres/easy_listening', 'jazz': 'directories/music_genres/jazz', 'country': 'directories/music_genres/country', 'hip_hop': 'directories/music_genres/hiphop', 'classical': 'directories/music_genres/classical', 'electronic_dance': 'directories/music_genres/electronic_dance', 'blues_folk': 'directories/music_genres/blues_folk', 'alternative': 'directories/music_genres/alternative', 'soundtracks_musicals': 'directories/music_genres/soundtracks_musicals',
},
}
+ # Get the absolute path to the mtv.html file
+ self.mtvHtmlPath = u'file://'+os.path.dirname( os.path.realpath( __file__ )).replace(u'/nv_python_libs/mtv', u'/nv_python_libs/configs/HTML/mtv.html?title=%s&amp;videocode=%s')
# Initialize the tree view flag so that the item parsing code can be used for multiple purposes
self.treeview = False
@@ -400,7 +403,7 @@ class Videos(object):
video_details = None
try:
- video_details = self.videoDetails(item['id'])
+ video_details = self.videoDetails(item['id'], urllib.quote(item['title'].encode("utf-8")))
except MtvUrlError, msg:
sys.stderr.write(self.error_messages['MtvUrlError'] % msg)
except MtvVideoDetailError, msg:
@@ -442,7 +445,7 @@ class Videos(object):
# end searchTitle()
- def videoDetails(self, url):
+ def videoDetails(self, url, title=u''):
'''Using the passed URL retrieve the video meta data details
return a dictionary of video metadata details
return
@@ -463,7 +466,10 @@ class Videos(object):
cur_size = True
for e in etree:
if e.tag.endswith(u'content') and e.text == None:
- metadata['video'] = e.get('url')
+ index = e.get('url').rindex(u':')
+ metadata['video'] = self.mtvHtmlPath % (title, e.get('url')[index+1:])
+ # !! This tag will need to be added at a later date
+# metadata['customhtml'] = u'true'
metadata['duration'] = e.get('duration')
if e.tag.endswith(u'player'):
metadata['link'] = e.get('url')
@@ -745,7 +751,11 @@ class Videos(object):
if not metadata.has_key('video'):
metadata['video'] = metadata['link']
else:
+ index = metadata['video'].rindex(u':')
+ metadata['video'] = self.mtvHtmlPath % (urllib.quote(metadata['title'].encode("utf-8")), metadata['video'][index+1:])
metadata['link'] = metadata['video']
+ # !! This tag will need to be added at a later date
+# metadata['customhtml'] = u'true'
if not dictionary_first: # Add the dictionaries display name
dictionaries.append([self.massageDescription(self.feed_names[self.tree_key][self.feed]), self.setTreeViewIcon()])