The branch, frodo has been updated
       via  687403c52d46644bc2afccb62e88b21611a20576 (commit)
      from  b36f76027a44e7bbb7e978586f11b5a4be885fa6 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=687403c52d46644bc2afccb62e88b21611a20576

commit 687403c52d46644bc2afccb62e88b21611a20576
Author: M. Kaijser <[email protected]>
Date:   Tue May 21 12:40:30 2013 +0200

    [script.randomandlastitems] 2.1.4

diff --git a/script.randomandlastitems/README.txt 
b/script.randomandlastitems/README.txt
index 02f4d0b..8de6765 100644
--- a/script.randomandlastitems/README.txt
+++ b/script.randomandlastitems/README.txt
@@ -3,15 +3,15 @@ Parameters (separated by comma , ):
 type = Movie/Episode/Music       | Script will request Movie database or 
Episode database
                                  | (/!\ Caution : upper and lower case are 
important)
 limit = #                        | # to limit returned results (default=10)
-method = Last/Random             | Last to get last added items and Random to 
get random items
+method = Last/Random/Playlist    | Last to get last added items, Random to get 
random items and Playlist to use the order of the playlist
 playlist = PathAndNameOfPlaylist | Name of the smartplaylist like 
special://masterprofile/playlists/video/children.xsp
                                  | or empty to request global database
                                  | If you set this parameter, you don't need 
to set type= because type will be read from playlist file
 menu =                           | Name of custom or standard menu which 
display the widget
 unwatched = True/False           | unwatched=True to filter only unwatched 
items
 resume = True/False              | resume=True to filter only partially 
watched items
-propertie = NameOfTheProperty    | You can overwrite the default properties 
names Playlist<method><type><menu> by using this parameter
-                                 | example : propertie=CustomMenu1Widget1
+property = NameOfTheProperty     | You can overwrite the default properties 
names Playlist<method><type><menu> by using this parameter
+                                 | example : property=CustomMenu1Widget1
 
 /!\ CAUTION /!\
 resume=True can slow down script when working on playlist
@@ -33,6 +33,7 @@ Properties return to Home window (id 10000) :
 %s.Count = Number of movies in library or playlist
 %s.Unwatched = Number of unwatched movies in library or playlist
 %s.Watched = Number of watched movies in library or playlist
+%s.Name = Name of the playlist
 %s.%d.DBID
 %s.%d.Title
 %s.%d.OriginalTitle
@@ -79,6 +80,7 @@ Properties return to Home window (id 10000) :
 %s.Unwatched = Number of unwatched episodes in library or playlist
 %s.Watched = Number of watched episodes in library or playlist
 %s.TvShows = Number of TV shows in library or playlist
+%s.Name = Name of the playlist
 %s.%d.DBID
 %s.%d.Title
 %s.%d.Episode
@@ -121,6 +123,7 @@ Properties return to Home window (id 10000) :
 %s.Artists = Number of artists in library or playlist
 %s.Albums = Number of albums in library or playlist
 %s.Songs = Nombre of songs in library or playlist
+%s.Name = Name of the playlist
 %s.%d.Title
 %s.%d.Artist
 %s.%d.Genre
diff --git a/script.randomandlastitems/addon.xml 
b/script.randomandlastitems/addon.xml
index d9a6640..46f0852 100644
--- a/script.randomandlastitems/addon.xml
+++ b/script.randomandlastitems/addon.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="script.randomandlastitems" name="Random and Last items script" 
version="2.1.2" provider-name="MikeBZH44|Martijn">
+<addon id="script.randomandlastitems" name="Random and Last items script" 
version="2.1.4" provider-name="MikeBZH44|Martijn|`Black">
     <requires>
         <import addon="xbmc.python" version="2.1.0"/>
         <import addon="xbmc.json" version="6.0.0"/>
diff --git a/script.randomandlastitems/changelog.txt 
b/script.randomandlastitems/changelog.txt
index 529e0b3..a42ebc8 100644
--- a/script.randomandlastitems/changelog.txt
+++ b/script.randomandlastitems/changelog.txt
@@ -1,3 +1,10 @@
+v2.1.4
+- Add %s.%d.Runtime property for episodes or TV shows
+- Add new method 'Playlist' which keeps the playlist order
+
+v2.1.3
+- Add %s.Name property for the playlist name
+
 v2.1.2
 - Fix script error on tvshow playlist
 - Also set MPAA and studio for episodes in some cases
diff --git a/script.randomandlastitems/randomandlastitems.py 
b/script.randomandlastitems/randomandlastitems.py
index 10dfe45..e44c179 100644
--- a/script.randomandlastitems/randomandlastitems.py
+++ b/script.randomandlastitems/randomandlastitems.py
@@ -17,10 +17,12 @@ from xml.dom.minidom import parse
 # Define global variables
 LIMIT = 20
 METHOD = "Random"
+REVERSE = False
 MENU = ""
 PLAYLIST = ""
 PROPERTY = ""
 RESUME = 'False'
+SORTBY = ""
 START_TIME = time.time()
 TYPE = ''
 UNWATCHED = 'False'
@@ -36,7 +38,10 @@ def log(txt):
     xbmc.log(msg=message, level=xbmc.LOGDEBUG)
 
 def _getPlaylistType ():
+    global METHOD
     global PLAYLIST
+    global REVERSE
+    global SORTBY
     global TYPE
     _doc = parse(xbmc.translatePath(PLAYLIST))
     _type = 
_doc.getElementsByTagName('smartplaylist')[0].attributes.item(0).value
@@ -46,6 +51,18 @@ def _getPlaylistType ():
        TYPE = 'Episode'
     if _type == 'songs' or _type == 'albums':
        TYPE = 'Music'
+    # get playlist name
+    _name = _doc.getElementsByTagName('name')[0].firstChild.nodeValue
+    if _name != "":
+        _setProperty( "%s.Name" % PROPERTY, str( _name ) )
+    # get playlist order
+        if METHOD == 'Playlist':
+            if _doc.getElementsByTagName('order'):
+                SORTBY = 
_doc.getElementsByTagName('order')[0].firstChild.nodeValue
+                if 
_doc.getElementsByTagName('order')[0].attributes.item(0).value == "descending":
+                    REVERSE = True
+            else:
+                METHOD = ""
 
 def _timeTook( t ):
     t = ( time.time() - t )
@@ -74,6 +91,8 @@ def _getMovies ( ):
     global PLAYLIST
     global PROPERTY
     global RESUME
+    global REVERSE
+    global SORTBY
     global UNWATCHED
     _result = []
     _total = 0
@@ -131,6 +150,8 @@ def _getMovies ( ):
         _count = 0
         if METHOD == 'Last':
             _result = sorted(_result, key=itemgetter('dateadded'), 
reverse=True)
+        elif METHOD == 'Playlist':
+            _result = sorted(_result, key=itemgetter(SORTBY), reverse=REVERSE)
         else:
             random.shuffle(_result, random.random)
         for _movie in _result:
@@ -214,6 +235,8 @@ def _getEpisodesFromPlaylist ( ):
     global METHOD
     global PLAYLIST
     global RESUME
+    global REVERSE
+    global SORTBY
     global UNWATCHED
     global PROPERTY
     _result = []
@@ -223,7 +246,7 @@ def _getEpisodesFromPlaylist ( ):
     _tvshows = 0
     _tvshowid = []
     # Request database using JSON
-    _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": 
"Files.GetDirectory", "params": {"directory": "%s", "media": "video", 
"properties": ["title", "playcount", "season", "episode", "showtitle", "plot", 
"file", "studio", "mpaa", "rating", "resume", "tvshowid", "art", 
"streamdetails", "dateadded"] }, "id": 1}' %(PLAYLIST))
+    _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": 
"Files.GetDirectory", "params": {"directory": "%s", "media": "video", 
"properties": ["title", "playcount", "season", "episode", "showtitle", "plot", 
"file", "studio", "mpaa", "rating", "resume", "runtime", "tvshowid", "art", 
"streamdetails", "dateadded"] }, "id": 1}' %(PLAYLIST))
     _json_query = unicode(_json_query, 'utf-8', errors='ignore')
     _json_pl_response = simplejson.loads(_json_query)
     _files = _json_pl_response.get( "result", {} ).get( "files" )
@@ -234,7 +257,7 @@ def _getEpisodesFromPlaylist ( ):
             if _file['type'] == 'tvshow':
                 _tvshows += 1
                 # Playlist return TV Shows - Need to get episodes
-                _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", 
"method": "VideoLibrary.GetEpisodes", "params": { "tvshowid": %s, "properties": 
["title", "playcount", "season", "episode", "showtitle", "plot", "file", 
"rating", "resume", "tvshowid", "art", "streamdetails", "dateadded"] }, "id": 
1}' %(_file['id']))
+                _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", 
"method": "VideoLibrary.GetEpisodes", "params": { "tvshowid": %s, "properties": 
["title", "playcount", "season", "episode", "showtitle", "plot", "file", 
"rating", "resume", "runtime", "tvshowid", "art", "streamdetails", "dateadded"] 
}, "id": 1}' %(_file['id']))
                 _json_query = unicode(_json_query, 'utf-8', errors='ignore')
                 _json_response = simplejson.loads(_json_query)
                 _episodes = _json_response.get( "result", {} ).get( "episodes" 
)
@@ -267,6 +290,8 @@ def _getEpisodesFromPlaylist ( ):
         _count = 0
         if METHOD == 'Last':
             _result = sorted(_result, key=itemgetter('dateadded'), 
reverse=True)
+        elif METHOD == 'Playlist':
+            _result = sorted(_result, key=itemgetter(SORTBY), reverse=REVERSE)
         else:
             random.shuffle(_result, random.random)
         for _episode in _result:
@@ -293,6 +318,8 @@ def _getEpisodes ( ):
     global LIMIT
     global METHOD
     global RESUME
+    global REVERSE
+    global SORTBY
     global UNWATCHED
     _result = []
     _total = 0
@@ -301,7 +328,7 @@ def _getEpisodes ( ):
     _tvshows = 0
     _tvshowid = []
     # Request database using JSON
-    _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": 
"VideoLibrary.GetEpisodes", "params": { "properties": ["title", "playcount", 
"season", "episode", "showtitle", "plot", "file", "studio", "mpaa", "rating", 
"resume", "tvshowid", "art", "streamdetails", "dateadded"]}, "id": 1}')
+    _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": 
"VideoLibrary.GetEpisodes", "params": { "properties": ["title", "playcount", 
"season", "episode", "showtitle", "plot", "file", "studio", "mpaa", "rating", 
"resume", "runtime", "tvshowid", "art", "streamdetails", "dateadded"]}, "id": 
1}')
     _json_query = unicode(_json_query, 'utf-8', errors='ignore')
     _json_pl_response = simplejson.loads(_json_query)
     # If request return some results
@@ -322,6 +349,8 @@ def _getEpisodes ( ):
         _count = 0
         if METHOD == 'Last':
             _result = sorted(_result, key=itemgetter('dateadded'), 
reverse=True)
+        elif METHOD == 'Playlist':
+            _result = sorted(_result, key=itemgetter(SORTBY), reverse=REVERSE)
         else:
             random.shuffle(_result, random.random)
         for _episode in _result:
@@ -341,6 +370,8 @@ def _getAlbumsFromPlaylist ( ):
     global LIMIT
     global METHOD
     global PLAYLIST
+    global REVERSE
+    global SORTBY
     _result = []
     _artists = 0
     _artistsid = []
@@ -355,6 +386,11 @@ def _getAlbumsFromPlaylist ( ):
         _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": 
"Files.GetDirectory", "params": {"directory": "%s", "media": "music", 
"properties": ["dateadded"], "sort": {"method": "random"}}, "id": 1}' 
%(PLAYLIST))
     elif METHOD == 'Last':
         _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": 
"Files.GetDirectory", "params": {"directory": "%s", "media": "music", 
"properties": ["dateadded"], "sort": {"order": "descending", "method": 
"dateadded"}}, "id": 1}' %(PLAYLIST))
+    elif METHOD == 'Playlist':
+        order = "ascending"
+        if REVERSE:
+            order = "descending"
+        _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": 
"Files.GetDirectory", "params": {"directory": "%s", "media": "music", 
"properties": ["dateadded"], "sort": {"order": "%s", "method": "%s"}}, "id": 
1}' %(PLAYLIST, order, SORTBY))
     else:
         _json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": 
"Files.GetDirectory", "params": {"directory": "%s", "media": "music", 
"properties": ["dateadded"]}, "id": 1}' %(PLAYLIST))
     _json_query = unicode(_json_query, 'utf-8', errors='ignore')
@@ -500,6 +536,7 @@ def _setEpisodeProperties ( _episode, _count ):
         art = _episode['art']
         path = media_path(_episode['file'])
         play = 'XBMC.RunScript(' + __addonid__ + ',episodeid=' + 
str(_episode.get('id')) + ')'
+        runtime = str(int((_episode['runtime'] / 60) + 0.5))
         streaminfo = 
media_streamdetails(_episode['file'].encode('utf-8').lower(),
                                          _episode['streamdetails'])
         _setProperty("%s.%d.DBID"                  % ( PROPERTY, _count ), 
str(_episode.get('id')))
@@ -524,6 +561,7 @@ def _setEpisodeProperties ( _episode, _count ):
         _setProperty("%s.%d.Art(clearart)"         % ( PROPERTY, _count ), 
art.get('tvshow.clearart',''))
         _setProperty("%s.%d.Art(landscape)"        % ( PROPERTY, _count ), 
art.get('tvshow.landscape',''))
         _setProperty("%s.%d.Resume"                % ( PROPERTY, _count ), 
resume)
+        _setProperty("%s.%d.Runtime"               % ( PROPERTY, _count ), 
runtime)
         _setProperty("%s.%d.PercentPlayed"         % ( PROPERTY, _count ), 
played)
         _setProperty("%s.%d.File"                  % ( PROPERTY, _count ), 
_episode['file'])
         _setProperty("%s.%d.MPAA"                  % ( PROPERTY, _count ), 
_episode['mpaa'])

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

Summary of changes:
 script.randomandlastitems/README.txt            |    9 +++--
 script.randomandlastitems/addon.xml             |    2 +-
 script.randomandlastitems/changelog.txt         |    7 ++++
 script.randomandlastitems/randomandlastitems.py |   44 +++++++++++++++++++++--
 4 files changed, 55 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to