The branch, frodo has been updated
       via  daa4b95cfd56b68a42fc4a19c219438677c3bff3 (commit)
       via  1c409c6173d2c22abb2c76320d6259522bb05621 (commit)
       via  8783d32282f7ab88fee474f9d6fa6548f53cc3c7 (commit)
       via  e72ea2767f63b06302ad96d9e5896e31ea08aa36 (commit)
      from  ce507898d177ccdbc6c43b4ef667ca863f434d17 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=daa4b95cfd56b68a42fc4a19c219438677c3bff3


http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=1c409c6173d2c22abb2c76320d6259522bb05621


http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=8783d32282f7ab88fee474f9d6fa6548f53cc3c7

commit 8783d32282f7ab88fee474f9d6fa6548f53cc3c7
Author: beenje <[email protected]>
Date:   Sun Dec 30 22:01:17 2012 +0100

    [plugin.video.pbs] updated to version 2.0.8

diff --git a/plugin.video.pbs/addon.xml b/plugin.video.pbs/addon.xml
index deaa6f5..7b70f90 100644
--- a/plugin.video.pbs/addon.xml
+++ b/plugin.video.pbs/addon.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="plugin.video.pbs"
        name="PBS"
-       version="2.0.6"
+       version="2.0.8"
        provider-name="stacked">
   <requires>
-       <import addon="xbmc.python" version="2.0"/>
+       <import addon="xbmc.python" version="2.1.0"/>
        <import addon="script.module.simplejson" version="2.0.10"/>
        <import addon="script.module.buggalo" version="1.1.2"/>
        <import addon="script.module.parsedom" version="1.3.0"/>
diff --git a/plugin.video.pbs/changelog.txt b/plugin.video.pbs/changelog.txt
index 1446f17..31cfc18 100644
--- a/plugin.video.pbs/changelog.txt
+++ b/plugin.video.pbs/changelog.txt
@@ -1,3 +1,14 @@
+[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..45978e1 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-29-2012'
+__version__ = '2.0.8'
 settings = xbmcaddon.Addon( id = 'plugin.video.pbs' )
 buggalo.SUBMIT_URL = 'http://www.xbmc.byethost17.com/submit.php'
 dbg = False
@@ -24,6 +24,8 @@ import CommonFunctions
 common = CommonFunctions
 common.plugin = plugin + ' ' + __version__
 
+from addonfunc import addListItem, playListItem, getUrl, setViewMode, 
getParameters, retry
+
 def clean( string ):
        list = [( '&amp;', '&' ), ( '&quot;', '"' ), ( '&#39;', '\'' ), ( 
'\n','' ), ( '\r', ''), ( '\t', ''), ( '</p>', '' ), ( '<br />', ' ' ), 
                        ( '<br/>', ' ' ), ( '<b>', '' ), ( '</b>', '' ), ( 
'<p>', '' ), ( '<div>', '' ), ( '</div>', '' ), ( '<strong>', ' ' ), 
@@ -42,7 +44,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 +55,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 +67,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:
@@ -101,10 +104,10 @@ def build_programs_directory( name, page ):
                                        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)
+                                       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")
@@ -118,7 +121,7 @@ def build_topics_directory():
        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)
+                       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 +141,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)
@@ -151,7 +154,7 @@ def build_search_directory( url, page ):
        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)
+               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 )
@@ -159,12 +162,13 @@ def build_search_directory( url, page ):
                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)
+               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 ):
        start = str( 200 * page )
        url = 'None'
@@ -215,9 +219,9 @@ def find_videos( name, program_id, topic, page ):
                        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] }
+                       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': 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)
+                       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
@@ -227,7 +231,7 @@ def find_videos( name, program_id, topic, page ):
                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)
+               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 )
@@ -244,16 +248,22 @@ def play_video( name, url, thumb, plot, studio, 
starttime, backup_url ):
        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 )
+                               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 +274,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
@@ -288,7 +298,8 @@ def play_video( name, url, thumb, plot, studio, starttime, 
backup_url ):
        except:
                print 'PBS - Using backup_url'
                if backup_url != 'None':
-                       play_mp4( name, backup_url, thumb, plot, studio, 
starttime )
+                       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()
@@ -308,100 +319,18 @@ def play_video( name, url, thumb, plot, studio, 
starttime, backup_url ):
                src_data = src.split( "&lt;break&gt;" )
                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:
                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 = clean( rtmp_url ), 
infoLabels = infoLabels, PlayPath = playpath)
 
 params = getParameters(sys.argv[2])
 starttime = None
@@ -481,6 +410,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()

http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=e72ea2767f63b06302ad96d9e5896e31ea08aa36

commit e72ea2767f63b06302ad96d9e5896e31ea08aa36
Author: beenje <[email protected]>
Date:   Sun Dec 30 22:01:15 2012 +0100

    [plugin.video.tmz] updated to version 2.0.10

diff --git a/plugin.video.tmz/addon.xml b/plugin.video.tmz/addon.xml
index 8c410a0..f6bd43c 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.10"
        provider-name="stacked">
   <requires>
-       <import addon="xbmc.python" version="2.0"/>
+       <import addon="xbmc.python" version="2.1.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..b07ea8f 100644
--- a/plugin.video.tmz/changelog.txt
+++ b/plugin.video.tmz/changelog.txt
@@ -1,3 +1,9 @@
+[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..8cda23b 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__ = '12-29-2012'
+__version__ = '2.0.10'
 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 = [ ('&amp;','&'), ('&quot;','"'), ('&#39;','\''), 
('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': urllib.quote_plus(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 ).encode('ascii', 
'ignore')
+       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.decode('latin1').encode('utf8'))
+       for videos in query:
+               title = clean(videos['title'].replace("\\", ""))
+               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': urllib.quote_plus(title), 
'url': urllib.quote_plus(url), 'studio': urllib.quote_plus(name), 'thumb': 
urllib.quote_plus(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': urllib.quote_plus(title), 
'url': urllib.quote_plus(videoUrl), 'thumb': urllib.quote_plus(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 )
+                       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..1c14f79 100644
--- a/plugin.video.tmz/resources/language/English/strings.xml
+++ b/plugin.video.tmz/resources/language/English/strings.xml
@@ -10,7 +10,6 @@
        <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>
diff --git a/plugin.video.tmz/resources/settings.xml 
b/plugin.video.tmz/resources/settings.xml
index da0b6ce..25ca008 100644
--- a/plugin.video.tmz/resources/settings.xml
+++ b/plugin.video.tmz/resources/settings.xml
@@ -1,4 +1,3 @@
 <settings>
        <setting id="quality" type="enum" label="30004" lvalues="30005|30006" 
default="1"/>
-       <setting id="view" type="bool" label="30021" default="true"/>
 </settings>

-----------------------------------------------------------------------

Summary of changes:
 .../LICENSE.txt                                    |    0
 plugin.video.bilmagasinettv.dk/addon.py            |   86 ++++++++++
 plugin.video.bilmagasinettv.dk/addon.xml           |   20 +++
 plugin.video.bilmagasinettv.dk/changelog.txt       |    5 +
 plugin.video.bilmagasinettv.dk/icon.png            |  Bin 0 -> 27249 bytes
 .../LICENSE.txt                                    |    0
 plugin.video.medi1tv/Medi1TVScraper.py             |  145 ++++++++++++++++
 plugin.video.medi1tv/Medi1Utils.py                 |   92 ++++++++++
 plugin.video.medi1tv/README.md                     |   12 ++
 plugin.video.medi1tv/addon.py                      |   90 ++++++++++
 plugin.video.medi1tv/addon.xml                     |   60 +++++++
 plugin.video.medi1tv/icon.png                      |  Bin 0 -> 16372 bytes
 .../resources/__init__.py                          |    0
 .../resources/lib}/__init__.py                     |    0
 plugin.video.pbs/addon.xml                         |    4 +-
 plugin.video.pbs/addonfunc.py                      |  140 ++++++++++++++++
 plugin.video.pbs/changelog.txt                     |   11 ++
 plugin.video.pbs/default.py                        |  150 +++++------------
 plugin.video.tmz/addon.xml                         |    6 +-
 plugin.video.tmz/addonfunc.py                      |  140 ++++++++++++++++
 plugin.video.tmz/changelog.txt                     |    6 +
 plugin.video.tmz/default.py                        |  177 ++++----------------
 .../resources/language/English/strings.xml         |    1 -
 plugin.video.tmz/resources/settings.xml            |    1 -
 24 files changed, 883 insertions(+), 263 deletions(-)
 copy {plugin.audio.abradio.cz => plugin.video.bilmagasinettv.dk}/LICENSE.txt 
(100%)
 create mode 100644 plugin.video.bilmagasinettv.dk/addon.py
 create mode 100644 plugin.video.bilmagasinettv.dk/addon.xml
 create mode 100644 plugin.video.bilmagasinettv.dk/changelog.txt
 create mode 100644 plugin.video.bilmagasinettv.dk/icon.png
 copy {plugin.audio.dradio => plugin.video.medi1tv}/LICENSE.txt (100%)
 create mode 100644 plugin.video.medi1tv/Medi1TVScraper.py
 create mode 100644 plugin.video.medi1tv/Medi1Utils.py
 create mode 100644 plugin.video.medi1tv/README.md
 create mode 100644 plugin.video.medi1tv/addon.py
 create mode 100644 plugin.video.medi1tv/addon.xml
 create mode 100644 plugin.video.medi1tv/icon.png
 copy {plugin.audio.radio_de => plugin.video.medi1tv}/resources/__init__.py 
(100%)
 copy {plugin.audio.radio_de/resources => 
plugin.video.medi1tv/resources/lib}/__init__.py (100%)
 create mode 100644 plugin.video.pbs/addonfunc.py
 create mode 100644 plugin.video.tmz/addonfunc.py


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. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to