Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Internet Content: Convert blip.tv grabber to accept remote input.

Blip.tv decided to go their own way with their javascript API, and it shows.  It stinks.  Theoretically the player is supposed to update member variables with a required callback, but even though I've implemented it *exactly* es in their documentation, the callback is never triggered.  So, instead, I'm forced to track certain states manually.  It causes some occasional strange behavior but volume, seek, pause, and play at least mostly work.  It's pretty easy to tell the difference between the polish of the Vimeo and Youtube javascript controls and the blip.tv one.
  • Loading branch information...
commit 281efa72b2821e45f97deb35054a27df20c2adb1 1 parent b674e52
Robert McNamara authored
View
8 mythtv/programs/scripts/internetcontent/nv_python_libs/bliptv/bliptv_api.py
@@ -40,6 +40,7 @@
import os, struct, sys, re, time
import urllib, urllib2
import logging
+from MythTV import MythXML
try:
import xml.etree.cElementTree as ElementTree
@@ -150,6 +151,7 @@ def __init__(self,
"""
self.config = {}
+ self.mythxml = MythXML()
if apikey is not None:
self.config['apikey'] = apikey
@@ -410,6 +412,10 @@ def setTreeViewIcon(self, dir_icon=None):
#
###########################################################################################################
+ def processVideoUrl(self, url):
+ playerUrl = self.mythxml.getInternetContentUrl("nv_python_libs/configs/HTML/bliptv.html", \
+ url.replace(u'http://blip.tv/play/', ''))
+ return self.ampReplace(playerUrl)
def searchTitle(self, title, pagenumber, pagelen):
'''Key word video search of the blip.tv web site
@@ -500,7 +506,7 @@ def searchTitle(self, title, pagenumber, pagelen):
if not item.has_key('video') and not item.has_key('link') and not embedURL:
continue
if embedURL:
- item['link'] = embedURL
+ item['link'] = self.processVideoUrl(embedURL)
if item.has_key('link') and not item.has_key('video'):
continue
if item.has_key('video') and not item.has_key('link'):
View
140 mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/bliptv.html
@@ -1,31 +1,115 @@
<!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
- June 8th, 2010
- Purpose: Implement full screen browser video display for the Blip.tv
- Example:
- file:///usr/local/share/mythtv/mythnetvision/scripts/nv_python_libs/configs/HTML/bliptv.html?videocode=Terraadmin-TERRA534HindsightAndForesight20YearsAfterTheExxonVald846
- -->
- <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 videocode = gup( 'videocode' );
-
- var embedded = '<embed src="http://www.tribute.ca/player/player.swf" width="100%" height="98%" quality="high" allowFullScreen="true" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" FlashVars="flashlet={_thumbnailTitles:[\'video\'],_videoList:[\'http://blip.tv/file/get/VIDEOCODE.flv\'],_videoAdsList:[\'\'],_previewImageList:[\'\'],_thumbnailPlayList:[\'\'],_fixedWidth:100%,_fixedHeight:98%,_videoProportions:true,_autoSize:true,_autoPlay:true,_bufferTime:4,_ownerLogoIMGPath:\'/player/watermark.png\',_ownerLogoAlpha:50,_ownerLogoLink:\'\',_thumbnailCarousel:false,_mainbarAutoHide:true,_mainbar_Alpha:75,_mainbar_Top:#333333,_mainbar_Bottom:#666666,_volumeAudio:60,_seekBar_color:#999999,_buttonToolTips:false,_buttonsColor:#FFFFFF,_hideEmailButton:true,_hideEmbedButton:true,_hideFullscreenButton:false,_hidePlayListButton:true,_hideTimerButton:false,_hideVideoPropButton:true,_hideVolumeButton:false}"></embed> />'
-
- document.write('<title>Blip.tv Full Screen</title>');
- document.write(embedded.replace(/VIDEOCODE/g, videocode));
-
- </script>
+ <head>
+ <style type="text/css">
+ body {
+ padding: 0;
+ margin: 0;
+ overflow-x: hidden;
+ overflow-y: hidden;
+ }
+ </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 video_id = gup( 'videocode' );
+ var url = 'http://blip.tv/play/';
+ var final = url.concat(video_id);
+ var curTime = 0;
+ var curVolume = 1;
+ var curState = 2;
+
+ var params = {
+ allowScriptAccess: "always",
+ allowfullscreen: 'true',
+ wmode: 'opaque'
+ };
+
+ var flashvars = {
+ 'enablejs': 'true',
+ 'javascriptid': 'mybtvplayer',
+ 'autostart': 'true'
+ };
+
+ var atts = { id: "mybtvplayer" };
+
+ swfobject.embedSWF(final,
+ "myth_player", window.innerWidth, window.innerHeight, "8", null, flashvars, params, atts, onPlayerReady);
+
+ function onPlayerReady() {
+ myth_player = document.getElementById("mybtvplayer");
+ }
+
+ function getUpdate(changeType, param1, param2){
+ switch(changeType) {
+ case "time":
+ curTime = param1;
+ break;
+ case "volume":
+ break;
+ case "state":
+ curState = param1;
+ break;
+ }
+ }
+
+ function play() {
+ if (myth_player) {
+ if (curState == 0) {
+ myth_player.sendEvent("play");
+ curState = 2;
+ }
+ else if (curState == 2) {
+ myth_player.sendEvent("pause");
+ curState = 0;
+ }
+ }
+ }
+
+ function seek(amount) {
+ if (myth_player) {
+ curTime += amount;
+ myth_player.sendEvent("seek", curTime);
+ }
+ }
+
+ function adjustVolume(amount) {
+ if (myth_player) {
+ curVolume += (amount / 30);
+ if (curVolume > 1)
+ curVolume = 1;
+ if (curVolume < 0)
+ curVolume = 0;
+ myth_player.sendEvent("volume", curVolume);
+ }
+ }
+
+ 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("mybtvplayer").width = window.innerWidth;
+ document.getElementById("mybtvplayer").height = window.innerHeight;
+ }
+ };
+ </script>
+ </head>
+ <body>
+ <div id="myth_player"/>
+ </body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.