The branch, eden has been updated
via 3dc56460a31f3f9d8bb2525a9bb1241c5c860e4a (commit)
via b66e8fe3b0683f33a7b44fc492b2b4ee64aef0e4 (commit)
from 6e4fcd0f7d60c6634bc85786edf1b8806d73cb60 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=3dc56460a31f3f9d8bb2525a9bb1241c5c860e4a
commit 3dc56460a31f3f9d8bb2525a9bb1241c5c860e4a
Author: beenje <[email protected]>
Date: Mon Jan 14 21:39:42 2013 +0100
[plugin.video.pbs] updated to version 2.0.9
diff --git a/plugin.video.pbs/addon.xml b/plugin.video.pbs/addon.xml
index deaa6f5..fbe5d6f 100644
--- a/plugin.video.pbs/addon.xml
+++ b/plugin.video.pbs/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.pbs"
name="PBS"
- version="2.0.6"
+ version="2.0.9"
provider-name="stacked">
<requires>
<import addon="xbmc.python" version="2.0"/>
diff --git a/plugin.video.pbs/changelog.txt b/plugin.video.pbs/changelog.txt
index 1446f17..8ab3bae 100644
--- a/plugin.video.pbs/changelog.txt
+++ b/plugin.video.pbs/changelog.txt
@@ -1,3 +1,22 @@
+[B]Version 2.0.9[/B]
+
+- Version bump for Frodo
+- Fixed 'listitem' is not defined error
+- Fixed play back error in rtmp steams
+- Added setting for preferred video quality (720p on Frodo only)
+- Added setting for default view in Confluence skin
+
+[B]Version 2.0.8[/B]
+
+- Updated code to be compatible with Requests v1.0.4
+
+[B]Version 2.0.7[/B]
+
+- Fixed duration time issue
+- Fixed 'argument 1 must be unicode or str' error
+- Fixed 'NoneType' has no len()" error in find_videos
+- Fixed redirect_url error
+
[B]Version 2.0.6[/B]
- Fixed access_voilation error
diff --git a/plugin.video.pbs/default.py b/plugin.video.pbs/default.py
index 642b169..e226e45 100644
--- a/plugin.video.pbs/default.py
+++ b/plugin.video.pbs/default.py
@@ -1,12 +1,12 @@
import xbmc, xbmcgui, xbmcplugin, urllib2, urllib, re, base64, string, sys,
os, traceback, time, xbmcaddon, datetime, coveapi, buggalo
-from urllib2 import Request, urlopen, URLError, HTTPError
+from urllib2 import Request, urlopen, URLError, HTTPError
plugin = "PBS"
__author__ = 'stacked <[email protected]>'
__url__ = 'http://code.google.com/p/plugin/'
-__date__ = '12-17-2012'
-__version__ = '2.0.6'
+__date__ = '12-30-2012'
+__version__ = '2.0.9'
settings = xbmcaddon.Addon( id = 'plugin.video.pbs' )
buggalo.SUBMIT_URL = 'http://www.xbmc.byethost17.com/submit.php'
dbg = False
@@ -24,6 +24,16 @@ import CommonFunctions
common = CommonFunctions
common.plugin = plugin + ' ' + __version__
+from addonfunc import addListItem, playListItem, getUrl, setViewMode,
getParameters, retry
+
+try:
+ if common.getXBMCVersion() >= 12.0:
+ HIGH = 'iPad'
+ else:
+ HIGH = 'MP4 1200k'
+except:
+ HIGH = 'MP4 1200k'
+
def clean( string ):
list = [( '&', '&' ), ( '"', '"' ), ( ''', '\'' ), (
'\n','' ), ( '\r', ''), ( '\t', ''), ( '</p>', '' ), ( '<br />', ' ' ),
( '<br/>', ' ' ), ( '<b>', '' ), ( '</b>', '' ), (
'<p>', '' ), ( '<div>', '' ), ( '</div>', '' ), ( '<strong>', ' ' ),
@@ -32,6 +42,13 @@ def clean( string ):
for search, replace in list:
string = string.replace( search, replace )
return string
+
+def clean_type( string ):
+ if string == None: return 'None'
+ list = [( '-16x9', '' ), ( '-4x3', '' ), ( ' 16x9', '' ), ( ' 4x3','' )]
+ for search, replace in list:
+ string = string.replace( search, replace )
+ return string
def build_main_directory():
main=[
@@ -42,7 +59,7 @@ def build_main_directory():
]
for name, thumbnailImage, mode in main:
u = { 'mode': mode, 'name': name }
- ListItem(label = name, image = thumbnailImage, url = u,
isFolder = True, infoLabels = False)
+ addListItem(label = name, image = thumbnailImage, url = u,
isFolder = True, infoLabels = False, fanart = fanart)
try:
build_most_watched_directory()
except:
@@ -53,7 +70,7 @@ def build_main_directory():
def build_most_watched_directory():
url = 'http://video.pbs.org/'
- data = open_url( url )
+ data = getUrl( url )
list = common.parseDOM(data, "ul", attrs = { "class": "video-list clear
clearfix" })
videos = common.parseDOM(list, "span", attrs = { "class": "title clear
clearfix" })
img = common.parseDOM(list, "img", ret = "src")
@@ -65,9 +82,10 @@ def build_most_watched_directory():
thumb = img[count]
infoLabels = { "Title": label, "Director": "PBS", "Studio":
clean(title.rsplit(' | ')[0]) }
u = { 'mode': '0', 'name': label, 'program_id': program_id,
'topic': 'False', 'page': '0' }
- ListItem(label = label, image = thumb, url = u, isFolder =
False, infoLabels = infoLabels)
+ addListItem(label = label, image = thumb, url = u, isFolder =
False, infoLabels = infoLabels, fanart = fanart)
count += 1
+@retry(TypeError)
def build_programs_directory( name, page ):
checking = True
while checking:
@@ -100,11 +118,11 @@ def build_programs_directory( name, page ):
thumb = programs_thumb
program_id = re.compile(
'/cove/v1/programs/(.*?)/' ).findall( results['resource_uri'] )[0]
infoLabels = { "Title":
results['title'].encode('utf-8'), "Plot": clean(results['long_description']) }
- u = { 'mode': '0', 'name':
urllib.quote_plus( results['title'].encode('utf-8') ), 'program_id':
urllib.quote_plus( program_id ) }
- ListItem(label = results['title'],
image = thumb, url = u, isFolder = True, infoLabels = infoLabels)
+ u = { 'mode': '0', 'name':
results['title'].encode('utf-8'), 'program_id': program_id }
+ addListItem(label = results['title'],
image = thumb, url = u, isFolder = True, infoLabels = infoLabels, fanart =
fanart)
# if ( len(data) ) == 200:
# u = { 'mode': '1', 'page': str( int( page ) + 1 ) }
- # ListItem(label = '[Next Page (' + str( int( page ) + 2 ) +
')]', image = next_thumb, url = u, isFolder = True, infoLabels = False)
+ # addListItem(label = '[Next Page (' + str( int( page ) + 2 ) +
')]', image = next_thumb, url = u, isFolder = True, infoLabels = False)
xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
if name == settings.getLocalizedString( 30014 ):
setViewMode("500")
@@ -117,8 +135,8 @@ def build_topics_directory():
item = None
for results in data:
if item != results['name']:
- u = { 'mode': '0', 'name': urllib.quote_plus(
results['name'] ), 'topic': urllib.quote_plus( 'True' ) }
- ListItem(label = results['name'], image = topics_thumb,
url = u, isFolder = True, infoLabels = False)
+ u = { 'mode': '0', 'name': results['name'], 'topic':
'True' }
+ addListItem(label = results['name'], image =
topics_thumb, url = u, isFolder = True, infoLabels = False, fanart = fanart)
item = results['name']
xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
setViewMode("515")
@@ -138,7 +156,7 @@ def build_search_keyboard():
def build_search_directory( url, page ):
save_url = url.replace( ' ', '%20' )
url = 'http://www.pbs.org/search/?q=' + url.replace( ' ', '%20' ) +
'&ss=pbs&mediatype=Video&start=' + str( page * 10 )
- data = open_url( url )
+ data = getUrl( url )
title_id_thumb = re.compile('<a title="(.*?)" target="" rel="nofollow"
onclick="EZDATA\.trackGaEvent\(\'search\', \'navigation\', \'external\'\);"
href="(.*?)"><img src="(.*?)" class="ez-primaryThumb"').findall(data)
program = re.compile('<p class="ez-metaextra1
ez-icon">(.*?)</p>').findall(data)
plot = re.compile('<p class="ez-desc">(.*?)<div
class="(ez-snippets|ez-itemUrl)">', re.DOTALL).findall(data)
@@ -150,22 +168,27 @@ def build_search_directory( url, page ):
item_count = 0
for title, id, thumb in title_id_thumb:
infoLabels = { "Title": clean( title ) , "Director": "PBS",
"Studio": clean( program[item_count] ), "Plot": clean( plot[item_count][0] ) }
- u = { 'mode': '0', 'name': urllib.quote_plus( clean(
program[item_count] ) ), 'program_id': urllib.quote_plus( id.rsplit('/')[4] ),
'topic': urllib.quote_plus( 'False' ) }
- ListItem(label = clean( title ), image = thumb, url = u,
isFolder = False, infoLabels = infoLabels)
+ u = { 'mode': '0', 'name': clean( program[item_count] ),
'program_id': id.rsplit('/')[4], 'topic': 'False' }
+ addListItem(label = clean( title ), image = thumb, url = u,
isFolder = False, infoLabels = infoLabels, fanart = fanart)
item_count += 1
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ),
sortMethod=xbmcplugin.SORT_METHOD_STUDIO )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ),
sortMethod=xbmcplugin.SORT_METHOD_LABEL )
if page == 0:
build_programs_directory( save_url.replace( '%20', ' ' ), 0 )
if ( int( video_count[0] ) - ( 10 * int( page ) ) ) > 10:
- u = { 'mode': '6', 'page': str( int( page ) + 1 ), 'url':
urllib.quote_plus( save_url ) }
- ListItem(label = '[Next Page (' + str( int( page ) + 2 ) +
')]', image = next_thumb, url = u, isFolder = True, infoLabels = False)
+ u = { 'mode': '6', 'page': str( int( page ) + 1 ), 'url':
save_url }
+ addListItem(label = '[Next Page (' + str( int( page ) + 2 ) +
')]', image = next_thumb, url = u, isFolder = True, infoLabels = False, fanart
= fanart)
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ),
sortMethod=xbmcplugin.SORT_METHOD_STUDIO )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ),
sortMethod=xbmcplugin.SORT_METHOD_LABEL )
setViewMode("503")
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
+@retry(TypeError)
def find_videos( name, program_id, topic, page ):
+ if settings.getSetting("quality") == '0':
+ type = ['MPEG-4 500kbps', 'MP4 800k', HIGH]
+ else:
+ type = [HIGH, 'MP4 800k', 'MPEG-4 500kbps' ]
start = str( 200 * page )
url = 'None'
backup_url = None
@@ -189,35 +212,27 @@ def find_videos( name, program_id, topic, page ):
if len(data) <= 1:
data =
cove.videos.filter(fields='associated_images,mediafiles',filter_program=program_id,order_by='-airdate',filter_availability_status='Available',limit_start=start)
for results in data:
- playable = None
+ encoding = {}
if results['associated_images'] != None and
len(results['associated_images']) > 0:
thumb = results['associated_images'][0]['url']
else:
thumb = 'None'
- count = 0
for videos in results['mediafiles']:
- if
results['mediafiles'][count]['video_encoding']['name'] == 'MPEG-4 500kbps':
- playable = count
- count += 1
- if playable == None:
- playable = count - 1
- if playable != -1:
- if results['mediafiles'][playable]['video_data_url'] !=
None:
- url =
results['mediafiles'][playable]['video_data_url']
- mode = '5'
- if
results['mediafiles'][playable]['video_download_url'] != None:
- backup_url =
results['mediafiles'][playable]['video_download_url']
- else:
- backup_url = 'None'
- elif results['mediafiles'][playable]['video_data_url']
== None and results['mediafiles'][playable]['video_download_url'] == None:
- url = 'None'
- mode = '5'
- else:
- url =
results['mediafiles'][playable]['video_download_url']
- mode = '7'
- infoLabels = { "Title":
results['title'].encode('utf-8'), "Director": "PBS", "Studio": name, "Plot":
results['long_description'].encode('utf-8'), "Duration":
int(results['mediafiles'][0]['length_mseconds'])/1000, "Aired":
results['airdate'].rsplit(' ')[0] }
- u = { 'mode': mode, 'name': urllib.quote_plus(
results['title'].encode('utf-8') ), 'url': urllib.quote_plus( url ), 'thumb':
urllib.quote_plus( thumb ), 'plot': urllib.quote_plus(
results['long_description'].encode('utf-8') ), 'studio': urllib.quote_plus(
name ), 'backup_url': urllib.quote_plus( backup_url ) }
- ListItem(label = results['title'].encode('utf-8'),
image = thumb, url = u, isFolder = False, infoLabels = infoLabels)
+ encoding[clean_type(videos['video_encoding']['name'])]
= { 'url': videos['video_data_url'], 'backup_url': videos['video_download_url']
}
+ cycle = 0
+ while cycle <= 2:
+ if type[cycle] in encoding:
+ url = str(encoding[type[cycle]]['url'])
+ backup_url =
str(encoding[type[cycle]]['backup_url'])
+ break
+ cycle += 1
+ if cycle == 3:
+ url = str(encoding.items()[0][1]['url'])
+ backup_url = str(encoding.items()[0][1]['backup_url'])
+ if len(results['mediafiles']) != 0:
+ infoLabels = { "Title":
results['title'].encode('utf-8'), "Director": "PBS", "Studio": name, "Plot":
results['long_description'].encode('utf-8'), "Aired":
results['airdate'].rsplit(' ')[0], "Duration":
str((int(results['mediafiles'][0]['length_mseconds'])/1000)/60) }
+ u = { 'mode': '5', 'name':
results['title'].encode('utf-8'), 'url': url, 'thumb': thumb, 'plot':
results['long_description'].encode('utf-8'), 'studio': name, 'backup_url':
backup_url }
+ addListItem(label = results['title'].encode('utf-8'),
image = thumb, url = u, isFolder = False, infoLabels = infoLabels, fanart =
fanart, duration = str(int(results['mediafiles'][0]['length_mseconds'])/1000))
if topic == 'False':
play_video( results['title'].encode('utf-8'), url, thumb,
results['long_description'].encode('utf-8'), name.encode('utf-8'), None,
backup_url )
return
@@ -226,8 +241,8 @@ def find_videos( name, program_id, topic, page ):
ok = dialog.ok( plugin , settings.getLocalizedString( 30012 ) +
' ' + name + '.' )
return
if ( len(data) ) == 200:
- u = { 'mode': '0', 'name': urllib.quote_plus( name ),
'program_id': urllib.quote_plus( program_id ), 'topic': urllib.quote_plus(
topic ), 'page': str( int( page ) + 1 ) }
- ListItem(label = '[Next Page (' + str( int( page ) + 2 ) +
')]', image = next_thumb, url = u, isFolder = True, infoLabels = False)
+ u = { 'mode': '0', 'name': name, 'program_id': program_id,
'topic': topic, 'page': str( int( page ) + 1 ) }
+ addListItem(label = '[Next Page (' + str( int( page ) + 2 ) +
')]', image = next_thumb, url = u, isFolder = True, infoLabels = False, fanart
= fanart)
if topic == 'search':
build_programs_directory( name, 0 )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ),
sortMethod=xbmcplugin.SORT_METHOD_UNSORTED )
@@ -238,22 +253,39 @@ def find_videos( name, program_id, topic, page ):
def play_video( name, url, thumb, plot, studio, starttime, backup_url ):
if url == 'None':
- dialog = xbmcgui.Dialog()
- ok = dialog.ok( plugin , settings.getLocalizedString( 30008 ) )
- return
+ if backup_url != 'None':
+ if url.find('http://urs.pbs.org/redirect/') != -1:
+ play_video( name, backup_url, thumb, plot,
studio, None, 'None' )
+ else:
+ infoLabels = { "Title": name , "Studio": "PBS:
" + studio, "Plot": plot }
+ playListItem(label = name, image = thumb, path
= clean(backup_url), infoLabels = infoLabels, PlayPath = False)
+ return
+ else:
+ dialog = xbmcgui.Dialog()
+ ok = dialog.ok( plugin , settings.getLocalizedString(
30008 ) )
+ return
if url.find('http://urs.pbs.org/redirect/') != -1:
try:
import requests
- headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1;
WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1'}
- config = {'max_retries': 10}
- r = requests.head(url , headers=headers, config=config,
allow_redirects=False)
- new_url = r.headers['location']
- play_mp4( name, new_url, thumb, plot, studio, starttime
)
+ status = 0
+ headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.2;
WOW64; rv:17.0) Gecko/20100101 Firefox/17.0'}
+ while status <= 10:
+ if status != 0: time.sleep(3)
+ r = requests.head(url , headers=headers,
allow_redirects=False)
+ new_url = r.headers['location']
+ if new_url != None: break
+ status += 1
+ infoLabels = { "Title": name , "Studio": "PBS: " +
studio, "Plot": plot }
+ playListItem(label = name, image = thumb, path =
clean(new_url), infoLabels = infoLabels, PlayPath = False)
return
except Exception, e:
print 'PBS - Using backup_url'
if backup_url != 'None':
- play_mp4( name, backup_url, thumb, plot,
studio, starttime )
+ if url.find('http://urs.pbs.org/redirect/') !=
-1:
+ play_video( name, backup_url, thumb,
plot, studio, None, 'None' )
+ else:
+ infoLabels = { "Title": name ,
"Studio": "PBS: " + studio, "Plot": plot }
+ playListItem(label = name, image =
thumb, path = clean(backup_url), infoLabels = infoLabels, PlayPath = False)
return
else:
dialog = xbmcgui.Dialog()
@@ -264,7 +296,7 @@ def play_video( name, url, thumb, plot, studio, starttime,
backup_url ):
buggalo.addExtraData('info', studio + ' - ' +
name)
raise Exception("redirect_url ERROR")
return
- data = open_url( url + '&format=SMIL' )
+ data = getUrl( url + '&format=SMIL' )
print 'PBS - ' + studio + ' - ' + name
try:
print data
@@ -285,10 +317,15 @@ def play_video( name, url, thumb, plot, studio,
starttime, backup_url ):
pass
try:
base = re.compile( '<meta base="(.+?)" />' ).findall( data )[0]
+ src = re.compile( '<ref src="(.+?)" title="(.+?)" (author)?'
).findall( data )[0][0]
except:
print 'PBS - Using backup_url'
if backup_url != 'None':
- play_mp4( name, backup_url, thumb, plot, studio,
starttime )
+ if url.find('http://urs.pbs.org/redirect/') != -1:
+ play_video( name, backup_url, thumb, plot,
studio, None, 'None' )
+ else:
+ infoLabels = { "Title": name , "Studio": "PBS:
" + studio, "Plot": plot }
+ playListItem(label = name, image = thumb, path
= clean(backup_url), infoLabels = infoLabels, PlayPath = False)
return
else:
dialog = xbmcgui.Dialog()
@@ -298,7 +335,6 @@ def play_video( name, url, thumb, plot, studio, starttime,
backup_url ):
buggalo.addExtraData('info', studio + ' - ' + name)
raise Exception("backup_url ERROR")
return
- src = re.compile( '<ref src="(.+?)" title="(.+?)" (author)?' ).findall(
data )[0][0]
# if src.find('m3u8') != -1:
# dialog = xbmcgui.Dialog()
# ok = dialog.ok( plugin , settings.getLocalizedString( 30008 )
)
@@ -308,100 +344,16 @@ def play_video( name, url, thumb, plot, studio,
starttime, backup_url ):
src_data = src.split( "<break>" )
rtmp_url = src_data[0] + "mp4:" + src_data[1].replace('mp4:','')
elif base != 'http://ad.doubleclick.net/adx/' and base.find('http://')
!= -1:
- play_mp4( name, base+src.replace('mp4:',''), thumb, plot,
studio, starttime )
+ infoLabels = { "Title": name , "Studio": "PBS: " + studio,
"Plot": plot }
+ playListItem(label = name, image = thumb, path =
clean(base+src.replace('mp4:','')), infoLabels = infoLabels, PlayPath = False)
return
- elif src.find('.flv') != -1 or src.find('.mp4') != -1:
+ elif src.find('.flv') != -1 or base.find('http://') != -1:
rtmp_url = base + src
else:
rtmp_url = base
playpath = "mp4:" + src.replace('mp4:','')
- listitem = xbmcgui.ListItem( label = name, iconImage = thumb,
thumbnailImage = thumb, path = clean( rtmp_url ))
- listitem.setInfo( type="Video", infoLabels={ "Title": name ,
"Director": "PBS", "Studio": "PBS: " + studio, "Plot": plot } )
- if playpath != None:
- listitem.setProperty("PlayPath", playpath)
- xbmcplugin.setResolvedUrl( handle = int( sys.argv[1] ), succeeded =
True, listitem = listitem )
-
-def play_mp4( name, url, thumb, plot, studio, starttime ):
- listitem = xbmcgui.ListItem( label = name, iconImage = thumb,
thumbnailImage = thumb, path = clean( url ) )
- listitem.setInfo( type="Video", infoLabels={ "Title": name ,
"Director": "PBS", "Studio": "PBS: " + studio, "Plot": plot } )
- xbmcplugin.setResolvedUrl( handle = int( sys.argv[1] ), succeeded =
True, listitem = listitem )
-
-def ListItem(label, image, url, isFolder, infoLabels = False):
- listitem = xbmcgui.ListItem(label = label, iconImage = image,
thumbnailImage = image)
- listitem.setProperty('fanart_image', fanart)
- if infoLabels:
- listitem.setInfo( type = "Video", infoLabels = infoLabels )
- if "Duration" in infoLabels:
- if hasattr( listitem, "addStreamInfo" ):
- listitem.addStreamInfo('video', { 'duration':
infoLabels["Duration"] })
- else:
- listitem.setInfo( type="Video", infoLabels={
"Duration":
str(datetime.timedelta(milliseconds=int(infoLabels["Duration"])*1000)) } )
- if not isFolder:
- listitem.setProperty('IsPlayable', 'true')
- u = sys.argv[0] + '?'
- for key, value in url.items():
- u = u + key + '=' + value + '&'
- ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u,
listitem = listitem, isFolder = isFolder)
- return ok
-
-def open_url(url):
- retries = 0
- while retries < 11:
- data = {'content': None, 'error': None}
- try:
- if retries != 0:
- time.sleep(3)
- data = get_page(url)
- if data['content'] != None and data['error'] == None:
- return data['content']
- if data['error'].find('404:') != -1:
- break
- except Exception, e:
- data['error'] = str(e)
- retries += 1
- dialog = xbmcgui.Dialog()
- ret = dialog.yesno(plugin, settings.getLocalizedString( 30050 ),
data['error'], '', settings.getLocalizedString( 30052 ),
settings.getLocalizedString( 30053 ))
- if ret == False:
- open_url(url)
- else:
- ok = dialog.ok(plugin, settings.getLocalizedString( 30051 ))
- buggalo.addExtraData('url', url)
- buggalo.addExtraData('error', data['error'])
- raise Exception("open_url ERROR")
-
-def get_page(url):
- data = {'content': None, 'error': None}
- try:
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1;
WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1')
- content = urllib2.urlopen(req)
- html = content.read()
- content.close()
- try:
- data['content'] = html.decode("utf-8")
- return data
- except:
- data['content'] = html
- return data
- except Exception, e:
- data['error'] = str(e)
- return data
-
-def setViewMode(id):
- if xbmc.getSkinDir() == "skin.confluence":
- xbmcplugin.setContent(int( sys.argv[1] ), 'episodes')
- xbmc.executebuiltin("Container.SetViewMode(" + id + ")")
-
-def getParameters(parameterString):
- commands = {}
- splitCommands = parameterString[parameterString.find('?') + 1:].split('&')
- for command in splitCommands:
- if (len(command) > 0):
- splitCommand = command.split('=')
- key = splitCommand[0]
- value = splitCommand[1]
- commands[key] = value
- return commands
+ infoLabels = { "Title": name , "Studio": "PBS: " + studio, "Plot": plot
}
+ playListItem(label = name, image = thumb, path = rtmp_url, infoLabels =
infoLabels, PlayPath = playpath)
params = getParameters(sys.argv[2])
starttime = None
@@ -481,6 +433,7 @@ try:
elif mode == 6:
build_search_directory( url, page )
elif mode == 7:
- play_mp4( name, url, thumb, plot, studio, starttime )
+ infoLabels = { "Title": name , "Studio": "PBS: " + studio,
"Plot": plot }
+ playListItem(label = name, image = thumb, path = clean(url),
infoLabels = infoLabels, PlayPath = False)
except Exception:
buggalo.onExceptionRaised()
diff --git a/plugin.video.pbs/resources/language/English/strings.xml
b/plugin.video.pbs/resources/language/English/strings.xml
index 0a66229..17aea53 100644
--- a/plugin.video.pbs/resources/language/English/strings.xml
+++ b/plugin.video.pbs/resources/language/English/strings.xml
@@ -17,9 +17,13 @@
<string id="30014">PBS Kids</string>
<string id="30015">Sorry. You are not in a geographic region that
has</string>
<string id="30016">access to this content.</string>
+ <string id="30017">Preferred video quality:</string>
+ <string id="30018">2500k-1200k</string>
+ <string id="30019">800k-500k</string>
<string id="30050">There was a connection error:</string>
<string id="30051">If this problem persists, please submit the error
report.</string>
<string id="30052">Retry</string>
<string id="30053">Quit</string>
<string id="30054">There was an index error.</string>
+ <string id="30055">Enable default view for Confluence skin</string>
</strings>
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=b66e8fe3b0683f33a7b44fc492b2b4ee64aef0e4
commit b66e8fe3b0683f33a7b44fc492b2b4ee64aef0e4
Author: beenje <[email protected]>
Date: Mon Jan 14 21:39:33 2013 +0100
[plugin.video.tmz] updated to version 2.0.11
diff --git a/plugin.video.tmz/addon.xml b/plugin.video.tmz/addon.xml
index 8c410a0..d45e194 100644
--- a/plugin.video.tmz/addon.xml
+++ b/plugin.video.tmz/addon.xml
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.tmz"
name="TMZ"
- version="2.0.9"
+ version="2.0.11"
provider-name="stacked">
<requires>
<import addon="xbmc.python" version="2.0"/>
<import addon="script.module.buggalo" version="1.1.2"/>
- <import addon="script.module.parsedom" version="1.2.0"/>
+ <import addon="script.module.parsedom" version="1.3.0"/>
</requires>
<extension point="xbmc.python.pluginsource"
library="default.py">
diff --git a/plugin.video.tmz/changelog.txt b/plugin.video.tmz/changelog.txt
index fdc3675..7b64180 100644
--- a/plugin.video.tmz/changelog.txt
+++ b/plugin.video.tmz/changelog.txt
@@ -1,3 +1,16 @@
+[B]Version 2.0.11[/B]
+
+- Version bump for frodo
+- Fixed 'KeyError' in build_video_directory
+- Fixed ascii errors
+- Added setting for default view in Confluence skin
+
+[B]Version 2.0.10[/B]
+
+- Updated addon to support recent website changes.
+- Fixed duration time issue
+- Moved main functions to addonfunc.py
+
[B]Version 2.0.9[/B]
- Fixed 'Not a gzipped file' error
diff --git a/plugin.video.tmz/default.py b/plugin.video.tmz/default.py
index e8d3c2e..6fa42da 100644
--- a/plugin.video.tmz/default.py
+++ b/plugin.video.tmz/default.py
@@ -5,52 +5,20 @@ import simplejson as json
plugin = 'TMZ'
__author__ = 'stacked <[email protected]>'
__url__ = 'http://code.google.com/p/plugin/'
-__date__ = '12-10-2012'
-__version__ = '2.0.9'
+__date__ = '01-13-2013'
+__version__ = '2.0.11'
settings = xbmcaddon.Addon( id = 'plugin.video.tmz' )
dbg = False
dbglevel = 3
icon = os.path.join( settings.getAddonInfo( 'path' ), 'icon.png' )
-fanart_bg = os.path.join( settings.getAddonInfo( 'path' ), 'fanart.jpg' )
+fanart = os.path.join( settings.getAddonInfo( 'path' ), 'fanart.jpg' )
buggalo.SUBMIT_URL = 'http://www.xbmc.byethost17.com/submit.php'
import CommonFunctions
common = CommonFunctions
common.plugin = plugin + ' ' + __version__
-def retry(ExceptionToCheck, tries=11, delay=3, backoff=1, logger=None):
- def deco_retry(f):
- def f_retry(*args, **kwargs):
- mtries, mdelay = tries, delay
- try_one_last_time = True
- while mtries >= 0:
- if mtries == 0:
- dialog = xbmcgui.Dialog()
- ret = dialog.yesno(plugin,
settings.getLocalizedString( 30054 ), '', '', settings.getLocalizedString(
30052 ), settings.getLocalizedString( 30053 ))
- if ret == False:
- mtries, mdelay = tries, delay
- else:
- ok = dialog.ok(plugin,
settings.getLocalizedString( 30051 ))
- raise Exception("retry ERROR")
- try:
- return f(*args, **kwargs)
- try_one_last_time = False
- break
- except ExceptionToCheck, e:
- if mtries > 1:
- msg = "%s, Retrying in %d
seconds..." % (str(e), mdelay)
- if logger:
- logger.warning(msg)
- else:
- print msg
- time.sleep(mdelay)
- mdelay *= backoff
- mtries -= 1
- if try_one_last_time:
- return f(*args, **kwargs)
- return
- return f_retry
- return deco_retry
+from addonfunc import addListItem, playListItem, getUrl, getPage, setViewMode,
getParameters, retry
def clean( name ):
remove = [ ('&','&'), ('"','"'), (''','\''),
('u2013','-'), ('u201c','\"'), ('u201d','\"'), ('u2019','\''), ('u2026','...') ]
@@ -68,32 +36,31 @@ def build_main_directory():
( settings.getLocalizedString( 30003 ), '0' )
]
for name, mode in main:
- ListItem(name, icon, '', mode, True, False, True)
+ u = { 'mode': mode, 'name': name }
+ addListItem(label = name, image = icon, url = u, isFolder =
True, infoLabels = False, fanart = fanart)
xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
- xbmcplugin.setContent(int( sys.argv[1] ), 'episodes')
setViewMode("515")
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
@retry(IndexError)
def build_video_directory( name ):
- data = open_url( 'http://www.tmz.com/videos/' )
- content = re.compile('{ name: \'' + name.upper() + '\',( )?\n
allInitialJson: \[(.+?)\],\n', re.DOTALL).findall( data )
- match = re.compile('\n{\n (.+?)\n}', re.DOTALL).findall( content[0][1]
)
- for videos in match:
- epsdata = re.compile('title": "(.+?)",\n "duration":
"(.+?)",\n "url": "(.+?)",\n "videoUrl": "(.+?)",\n "manualThumbnailUrl":
"(.+?)",\n "thumbnailUrl": "(.+?)",\n "kalturaId": "(.+?)"',
re.DOTALL).findall(videos)
- title = clean(epsdata[0][0].replace("\\", ""))
- duration = epsdata[0][1].replace("\\", "")
- videoUrl = epsdata[0][3].replace("\\", "")
- thumb = epsdata[0][5].replace("\\", "") +
'/width/490/height/266/type/3'
+ data = getUrl( 'http://www.tmz.com/videos/', True )
+ textarea = '[' + re.compile('{ name: \'' + name.upper() + '\',( )?\n
allInitialJson: {(.+?)},\n (slug|noPaging)?', re.DOTALL).findall(
data )[0][1].replace('\n', '').rsplit('[')[1].rsplit(']')[0] + ']'
+ query = json.loads(textarea)
+ for videos in query:
+ title = clean(videos['title'].replace("\\",
"")).encode('ascii', 'ignore')
+ duration = videos['duration'].replace("\\", "")
+ videoUrl = videos['videoUrl'].replace("\\", "")
+ thumb = videos['thumbnailUrl'].replace("\\", "") +
'/width/490/height/266/type/3'
if videoUrl.find('http://cdnbakmi.kaltura.com') == -1:
if settings.getSetting("quality") == '0':
url = 'http://cdnapi.kaltura.com/p/' +
thumb.split('/')[4] + '/sp/' + thumb.split('/')[6] + '/playManifest/entryId/' +
videoUrl.split('_')[0].split('/')[-1:][0] + '_' + videoUrl.split('_')[1]
else:
url = 'http://cdnapi.kaltura.com/p/' +
thumb.split('/')[4] + '/sp/' + thumb.split('/')[6] + '/playManifest/entryId/' +
videoUrl.split('_')[0].split('/')[-1:][0] + '_' + videoUrl.split('_')[1] +
'/flavorId/0_' + videoUrl.split('_')[3]
- infoLabels = { "Title": title, "Director": "TMZ",
"Studio": name, "Plot": title, "Duration":
str(datetime.timedelta(seconds=int(duration))) }
- ListItem(title, thumb, url, '1', False, infoLabels,
True)
+ infoLabels = { "Title": title, "Plot": title,
"Duration": str(int(duration)/60) }
+ u = { 'mode': '1', 'name': title, 'url': url, 'studio':
name, 'thumb': thumb }
+ addListItem(label = title, image = thumb, url = u,
isFolder = False, infoLabels = infoLabels, fanart = fanart, duration = duration)
xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
- xbmcplugin.setContent(int( sys.argv[1] ), 'episodes')
setViewMode("503")
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
@@ -106,13 +73,13 @@ def build_search_directory():
return
while checking:
url = 'http://www.tmz.com/search/json/videos/' +
urllib.quote(string) + '/' + str(page) + '.json'
- data = get_page(url)
+ data = getPage(url)
if data['error'] == 'HTTP Error 404: Not Found':
dialog = xbmcgui.Dialog()
ok = dialog.ok( plugin , settings.getLocalizedString(
30009 ) + '\n' + settings.getLocalizedString( 30010 ) )
return
elif data['error'] != None:
- text = open_url( url )
+ text = getUrl( url, True )
else:
text = data['content']
jdata = json.loads(text)
@@ -126,10 +93,10 @@ def build_search_directory():
title = results['title'].encode('ascii', 'ignore')
videoUrl = results['URL'].replace("\\", "")
thumb = results['thumbnailUrl'].replace("\\", "") +
'/width/490/height/266/type/3'
- infoLabels = { "Title": title, "Director": "TMZ",
"Plot": title }
- ListItem(title, thumb, videoUrl, '3', False,
infoLabels, True)
+ infoLabels = { "Title": title, "Plot": title }
+ u = { 'mode': '3', 'name': title, 'url': videoUrl,
'thumb': thumb }
+ addListItem(label = title, image = thumb, url = u,
isFolder = False, infoLabels = infoLabels, fanart = fanart)
xbmcplugin.addSortMethod( handle = int(sys.argv[1]), sortMethod =
xbmcplugin.SORT_METHOD_NONE )
- xbmcplugin.setContent(int( sys.argv[1] ), 'episodes')
setViewMode("503")
xbmcplugin.endOfDirectory( int( sys.argv[1] ) )
@@ -137,108 +104,26 @@ def build_search_directory():
def get_search_url(name, url, thumb):
if settings.getSetting("quality") == '0' or len(url.split('/')[4]) > 10:
meta = 'http://cdnapi.kaltura.com/p/' + thumb.split('/')[4] +
'/sp/' + thumb.split('/')[6] + '/playManifest/entryId/' + thumb.split('/')[9]
- data = open_url( meta )
+ data = getUrl( meta, True )
url = re.compile('<media url=\"(.+?)\"').findall(data)[0]
else:
- data = open_url( url )
+ if len(url.rsplit('-')) == 2: url = url.replace('-', '_')
+ data = getUrl( url, True )
url = common.parseDOM(data, "meta", attrs = { "name":
"VideoURL" }, ret = "content")[0]
- play_video( name, url, thumb, 'TMZ' )
+ play_video( name, url, thumb, settings.getLocalizedString( 30007 ) )
@retry(IndexError)
def play_video( name, url, thumb, studio ):
- if studio != 'TMZ':
+ if studio != settings.getLocalizedString( 30007 ):
try:
- data = open_url( url )
+ data = getUrl( url, True )
url = re.compile('<media
url=\"(.+?)\"').findall(data)[0]
except:
- url = 'http://www.tmz.com/videos/' + url.split('/')[9]
- data = open_url( url )
+ url = 'http://www.tmz.com/videos/' + thumb.split('/')[9]
+ data = getUrl( url, True )
url = common.parseDOM(data, "meta", attrs = { "name":
"VideoURL" }, ret = "content")[0]
- listitem = xbmcgui.ListItem( label = name, iconImage =
"DefaultVideo.png", thumbnailImage = thumb, path = url )
- listitem.setInfo( type="Video", infoLabels={ "Title": name ,
"Director": "TMZ", "Studio": studio, "Plot": name } )
- xbmcplugin.setResolvedUrl( handle = int( sys.argv[1] ), succeeded =
True, listitem = listitem )
-
-def ListItem(label, image, url, mode, isFolder, infoLabels = False, fanart =
False):
- listitem = xbmcgui.ListItem(label = label, iconImage = image,
thumbnailImage = image)
- if fanart:
- listitem.setProperty('fanart_image', fanart_bg)
- if infoLabels:
- listitem.setInfo( type = "Video", infoLabels = infoLabels )
- if not isFolder:
- listitem.setProperty('IsPlayable', 'true')
- if mode == '1':
- u = sys.argv[0] + "?mode=1&name=" + urllib.quote_plus(label) +
"&url=" + urllib.quote_plus(url) + "&studio=" +
urllib.quote_plus(infoLabels['Studio']) + "&thumb=" + urllib.quote_plus(image)
- elif mode == '3':
- u = sys.argv[0] + "?mode=3&name=" + urllib.quote_plus(label) +
"&url=" + urllib.quote_plus(url) + "&thumb=" + urllib.quote_plus(image)
- else:
- u = sys.argv[0] + "?mode=" + mode + "&name=" +
urllib.quote_plus(label)
- ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u,
listitem = listitem, isFolder = isFolder)
- return ok
-
-def open_url(url):
- retries = 0
- while retries < 11:
- data = {'content': None, 'error': None}
- try:
- if retries != 0:
- time.sleep(3)
- data = get_page(url)
- if data['content'] != None and data['error'] == None:
- return data['content']
- if data['error'] == 'HTTP Error 404: Not Found':
- break
- except Exception, e:
- data['error'] = str(e)
- retries += 1
- dialog = xbmcgui.Dialog()
- ret = dialog.yesno(plugin, settings.getLocalizedString( 30050 ),
data['error'], '', settings.getLocalizedString( 30052 ),
settings.getLocalizedString( 30053 ))
- if ret == False:
- open_url(url)
- else:
- ok = dialog.ok(plugin, settings.getLocalizedString( 30051 ))
- buggalo.addExtraData('url', url)
- buggalo.addExtraData('error', data['error'])
- raise Exception("open_url ERROR")
-
-def get_page(url):
- data = {'content': None, 'error': None}
- try:
- req = urllib2.Request(url)
- req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1;
WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1')
- content = urllib2.urlopen(req)
- try:
- if content.info()['Content-Encoding'] == 'gzip':
- gzip_filehandle =
gzip.GzipFile(fileobj=StringIO.StringIO(content.read()))
- html = gzip_filehandle.read()
- else:
- html = content.read()
- except:
- html = content.read()
- content.close()
- try:
- data['content'] = html.decode("utf-8")
- return data
- except:
- data['content'] = html
- return data
- except Exception, e:
- data['error'] = str(e)
- return data
-
-def setViewMode(id):
- if xbmc.getSkinDir() == "skin.confluence" and
settings.getSetting('view') == 'true':
- xbmc.executebuiltin("Container.SetViewMode(" + id + ")")
-
-def getParameters(parameterString):
- commands = {}
- splitCommands = parameterString[parameterString.find('?') + 1:].split('&')
- for command in splitCommands:
- if (len(command) > 0):
- splitCommand = command.split('=')
- key = splitCommand[0]
- value = splitCommand[1]
- commands[key] = value
- return commands
+ infoLabels = { "Title": name , "Studio": "TMZ: " + studio, "Plot": name
}
+ playListItem(label = name, image = thumb, path = url, infoLabels =
infoLabels)
params = getParameters(sys.argv[2])
mode = None
diff --git a/plugin.video.tmz/resources/language/English/strings.xml
b/plugin.video.tmz/resources/language/English/strings.xml
index d47c56f..568fdf8 100644
--- a/plugin.video.tmz/resources/language/English/strings.xml
+++ b/plugin.video.tmz/resources/language/English/strings.xml
@@ -10,10 +10,10 @@
<string id="30007">Search</string>
<string id="30009">No videos found. Please check your spelling</string>
<string id="30010">or try again using different search words.</string>
- <string id="30021">Enable default view for Confluence skin</string>
<string id="30050">There was a connection error:</string>
<string id="30051">If this problem persists, please submit the error
report.</string>
<string id="30052">Retry</string>
<string id="30053">Quit</string>
<string id="30054">There was an index error.</string>
+ <string id="30055">Enable default view for Confluence skin</string>
</strings>
diff --git a/plugin.video.tmz/resources/settings.xml
b/plugin.video.tmz/resources/settings.xml
index da0b6ce..4a7d81f 100644
--- a/plugin.video.tmz/resources/settings.xml
+++ b/plugin.video.tmz/resources/settings.xml
@@ -1,4 +1,4 @@
<settings>
<setting id="quality" type="enum" label="30004" lvalues="30005|30006"
default="1"/>
- <setting id="view" type="bool" label="30021" default="true"/>
+ <setting id="view" type="bool" label="30055" default="true"/>
</settings>
-----------------------------------------------------------------------
Summary of changes:
plugin.video.pbs/addon.xml | 2 +-
.../addonfunc.py | 25 +--
plugin.video.pbs/changelog.txt | 19 ++
plugin.video.pbs/default.py | 241 ++++++++------------
.../resources/language/English/strings.xml | 4 +
plugin.video.pbs/resources/settings.xml | 4 +
plugin.video.tmz/addon.xml | 4 +-
.../addonfunc.py | 25 +--
plugin.video.tmz/changelog.txt | 13 +
plugin.video.tmz/default.py | 179 +++------------
.../resources/language/English/strings.xml | 2 +-
plugin.video.tmz/resources/settings.xml | 2 +-
12 files changed, 194 insertions(+), 326 deletions(-)
copy {plugin.video.nba.video => plugin.video.pbs}/addonfunc.py (91%)
create mode 100644 plugin.video.pbs/resources/settings.xml
copy {plugin.video.nba.video => plugin.video.tmz}/addonfunc.py (91%)
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons