Advertisement
Guest User

Untitled

a guest
Nov 26th, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 31.79 KB | None | 0 0
  1. from time import strptime, mktime, gmtime, strftime, localtime
  2. from operator import itemgetter
  3. import itertools
  4. import sys, itertools, re, os, random, inspect
  5. import copy
  6. if sys.version_info < (2, 7):
  7.     import simplejson
  8. else:
  9.     import json as simplejson
  10. import xbmc, xbmcgui, xbmcaddon
  11. # http://mail.python.org/pipermail/python-list/2009-June/596197.html
  12. import _strptime
  13. from threading import Thread
  14. import aioupdate
  15. from aioupdate import Uprandom
  16.  
  17. __addon__        = xbmcaddon.Addon()
  18. __addonid__      = __addon__.getAddonInfo('id')
  19. __addonversion__ = __addon__.getAddonInfo('version')
  20. __settings__   = xbmcaddon.Addon(id='script.allinone')
  21.  
  22.  
  23.  
  24. def log(message):
  25.     xbmc.log(msg=message)
  26. class Main:
  27.     def __init__( self ):
  28.         log("iniciou o aiorecents")
  29.         self._init_vars()
  30.         self._fetch_info()
  31.        
  32.     def _init_vars( self ):
  33.         self.WINDOW = xbmcgui.Window( 10000 )          
  34.         self.rctmovies = __settings__.getSetting("MoviesRecents")
  35.         self.rctmoviesunwatched = __settings__.getSetting("MoviesRecentsHideWatched")
  36.         self.rctepisodes = __settings__.getSetting("EpisodeRecents")
  37.         self.rctepisodesfirst = __settings__.getSetting("EpisodeRecentsFirst")
  38.         self.rctmusic = __settings__.getSetting("MusicRecents")
  39.         self.rctconcerts = __settings__.getSetting("ConcertsRecents")
  40.         self.LIMIT = 10
  41.         log("terminou o aiorecents")
  42.     def _fetch_info( self ):
  43.         if self.rctmovies == 'false':
  44.            self._clearproperties_moviesrecents()
  45.            self._setproperties_moviesrecentslatest()
  46.         if self.rctepisodes == 'false':
  47.            self._clearproperties_episodesrecents()
  48.            self._setproperties_episodesrecentslatest()
  49.         if self.rctconcerts == 'false':
  50.            self._clearproperties_musicvideosrecents()
  51.            self._setproperties_musicvideosrecentslatest()
  52.         if self.rctmusic == 'false' :
  53.            self._clearproperties_songsrecents()
  54.            self._clearproperties_albunsrecents
  55.            self._setproperties_songsrecentslatest()
  56.            self._setproperties_albunsrecentslatest()  
  57.         if self.rctmovies == 'true':
  58.            self._fetch_moviesrecents ()          
  59.         if self.rctepisodes == 'true':
  60.            self._fetch_episodesrecents()
  61.         if self.rctconcerts == 'true':
  62.            self._fetch_musicvideosrecents()
  63.         if self.rctmusic == 'true':
  64.            self._fetch_songsrecents()
  65.            self._fetch_albunsrecents ()
  66.         if self.rctmovies == 'true':
  67.            self._clearproperties_moviesrecents()
  68.            self._setproperties_moviesrecents()
  69.         if self.rctepisodes == 'true':
  70.            self._clearproperties_episodesrecents()
  71.            self._setproperties_episodesrecents()
  72.         if self.rctconcerts == 'true':
  73.            self._clearproperties_musicvideosrecents()
  74.            self._setproperties_musicvideosrecents()
  75.         if self.rctmusic == 'true':
  76.            self._clearproperties_songsrecents()
  77.            self._clearproperties_albunsrecents()
  78.            self._setproperties_songsrecents()
  79.            self._setproperties_albunsrecents()
  80.                      
  81.     def _fetch_moviesrecents( self ):
  82.         self.moviesrecents = []
  83.         self.moviesrecentsall = []
  84.         json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetRecentlyAddedMovies", "params": { "properties": ["title", "genre", "studio", "tagline", "runtime", "fanart", "thumbnail", "file", "plot", "plotoutline", "year", "lastplayed", "rating", "trailer", "playcount", "mpaa"] }, "id": 1}' )
  85.         json_query = unicode(json_query, 'utf-8', errors='ignore')
  86.         json_response = simplejson.loads(json_query)
  87.         if json_response.has_key('result') and json_response['result'].has_key('movies'):
  88.             for count, recentitem in enumerate(json_response['result']['movies']):
  89.                     title = recentitem['title']
  90.                     year = str(recentitem['year'])
  91.                     genre = recentitem['genre']
  92.                     studio = recentitem['studio']
  93.                     plot = recentitem['plot']
  94.                     plotoutline = recentitem['plotoutline']
  95.                     tagline = recentitem['tagline']
  96.                     runtime = str(recentitem['runtime'] / 60)
  97.                     fanart = recentitem['fanart']
  98.                     thumbnail = recentitem['thumbnail']
  99.                     path = recentitem['file']
  100.                     rating = str(round(float(recentitem['rating']),1))
  101.                     trailer = recentitem['trailer']
  102.                     mpaa = recentitem['mpaa']
  103.                     if int(recentitem['playcount']) == 0:
  104.                        self.moviesrecents.append([title, year, genre, studio, plot, plotoutline, tagline, runtime, fanart, thumbnail, path, rating, trailer, mpaa])
  105.                     self.moviesrecentsall.append([title, year, genre, studio, plot, plotoutline, tagline, runtime, fanart, thumbnail, path, rating, trailer, mpaa])
  106.         for index in range(len(self.moviesrecentsall)):
  107.             xbmc.log(msg="fimes recents %s" % self.moviesrecentsall[index])
  108.  
  109.     def _fetch_seasonthumb( self, tvshowid, seasonnumber ):
  110.         json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": {"properties": ["season", "thumbnail"], "tvshowid":%s }, "id": 1}' % tvshowid)
  111.         json_query = unicode(json_query, 'utf-8', errors='ignore')
  112.         json_response = simplejson.loads(json_query)
  113.         if json_response.has_key('result') and json_response['result'].has_key('seasons'):
  114.             for item in json_response['result']['seasons']:
  115.                 season = "%.2d" % float(item['season'])
  116.                 if season == seasonnumber:
  117.                     thumbnail = item['thumbnail']
  118.                     xbmc.log(msg="retornou o thumbnail")
  119.                     return thumbnail
  120.     def _fetch_episodepercent( self, tvshowid, seasonnumber, episodenumber ):
  121.         json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"properties": ["episode", "season", "resume"], "tvshowid":%s }, "id": 1}' % tvshowid)
  122.         json_query = unicode(json_query, 'utf-8', errors='ignore')
  123.         json_response = simplejson.loads(json_query)
  124.         if json_response.has_key('result') and json_response['result'] != None and json_response['result'].has_key('episodes'):
  125.             for epipercent in json_response['result']['episodes']:
  126.                 season = "%.2d" % float(epipercent['season'])
  127.                 episode = "%.2d" % float(epipercent['episode'])
  128.                 if season == seasonnumber and episode == episodenumber:
  129.                     try:
  130.                        percentplayed = str(int(epipercent['resume']['position']*100) / int(epipercent['resume']['total']))
  131.                        return percentplayed
  132.                     except:
  133.                        percentplayed = "0"
  134.                        return percentplayed    
  135.     def _fetch_episodesrecents( self ):
  136.         self.episodesrecents = []
  137.         self.episodesrecentsall = []
  138.         json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetRecentlyAddedEpisodes", "params": {"properties": ["title", "playcount", "plot", "season", "episode", "showtitle", "thumbnail", "file", "lastplayed", "rating", "fanart", "tvshowid"] }, "id": 1}' )
  139.         json_query = unicode(json_query, 'utf-8', errors='ignore')
  140.         json_response = simplejson.loads(json_query)
  141.         if json_response.has_key('result') and json_response['result'] != None and json_response['result'].has_key('episodes'):
  142.             for count,recentitem in enumerate(json_response['result']['episodes']):
  143.                     title = recentitem['title']
  144.                     episode = "%.2d" % float(recentitem['episode'])
  145.                     path = recentitem['file']
  146.                     plot = recentitem['plot']
  147.                     season = "%.2d" % float(recentitem['season'])
  148.                     thumb = recentitem['thumbnail']
  149.                     showtitle = recentitem['showtitle']
  150.                     rating = str(round(float(recentitem['rating']),1))
  151.                     episodeno = "s%se%s" % ( season,  episode, )
  152.                     fanart = recentitem['fanart']
  153.                     tvshowid = recentitem['tvshowid']
  154.                     seasonthumb = ''
  155.                     if int(recentitem['playcount']) == 0:
  156.                        self.episodesrecents.append([title, showtitle, season, episode, rating, plot, path, thumb, fanart, episodeno, seasonthumb, tvshowid])
  157.                     self.episodesrecentsall.append([title, showtitle, season, episode, rating, plot, path, thumb, fanart, episodeno, seasonthumb, tvshowid])
  158.         for count,episode in enumerate( self.episodesrecents ):
  159.             count += 1
  160.             tvshowid = episode[11]
  161.             season = episode[2]
  162.             episodenumber = episode[3]
  163.             episode[10] = self._fetch_seasonthumb(tvshowid, season)
  164.             if count == self.LIMIT:
  165.                 # stop here if our list contains more items
  166.                 break
  167.         for count,episodeall in enumerate( self.episodesrecentsall ):
  168.             count += 1
  169.             tvshowid = episodeall[11]
  170.             season = episodeall[2]
  171.             episodenumber = episodeall[3]
  172.             episodeall[10] = self._fetch_seasonthumb(tvshowid, season)
  173.             if count == self.LIMIT:
  174.                 # stop here if our list contains more items
  175.                 break        
  176.    
  177.     def _fetch_musicvideosrecents( self ):
  178.         self.musicvideosrecents = []
  179.         self.musicvideosrecentsall = []
  180.         json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetRecentlyAddedMusicVideos", "params": {"properties": ["title", "resume", "genre", "studio", "runtime", "fanart", "thumbnail", "file", "plot", "year", "lastplayed", "playcount"]}, "id": 1}')
  181.         json_query = unicode(json_query, 'utf-8', errors='ignore')
  182.         json_response = simplejson.loads(json_query)
  183.         if json_response.has_key('result') and json_response['result'] != None and  json_response['result'].has_key('musicvideos'):
  184.             for recentitem in json_response['result']['musicvideos']:
  185.                     title = recentitem['title']
  186.                     year = str(recentitem['year'])
  187.                     genre = recentitem['genre']
  188.                     studio = recentitem['studio']
  189.                     plot = recentitem['plot']
  190.                     runtime = str(recentitem['runtime'] / 60)
  191.                     fanart = recentitem['fanart']
  192.                     thumbnail = recentitem['thumbnail']
  193.                     path = recentitem['file']
  194.                     if recentitem.has_key('resume'):
  195.                         # catch exceptions where the lastplayed isn't returned by json-rpc (bug?)
  196.                         try:
  197.                            percentplayed = str(int(recentitem['resume']['position']*100) / int(recentitem['resume']['total']))
  198.                         except:
  199.                            percentplayed = '0'
  200.                         lastplayed = recentitem['lastplayed']
  201.                     else:
  202.                         lastplayed = ''
  203.                     if lastplayed == '':
  204.                         # catch exceptions where the item has been partially played, but playdate wasn't stored in the db
  205.                         lastplayed = '0'
  206.                     else:
  207.                         datetime = strptime(lastplayed, "%Y-%m-%d %H:%M:%S")
  208.                         lastplayed = str(mktime(datetime))
  209.                     if int(recentitem['playcount']) == 0:
  210.                        self.musicvideosrecents.append([title, year, genre, studio, plot, runtime, fanart, thumbnail, path, percentplayed, lastplayed])
  211.                     self.musicvideosrecentsall.append([title, year, genre, studio, plot, runtime, fanart, thumbnail, path, percentplayed, lastplayed])                                                                      
  212.            
  213.     def _fetch_songsrecents( self ):
  214.         self.songsrecents = []
  215.         json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioLibrary.GetRecentlyAddedSongs", "params": {"properties": ["title", "artist", "fanart", "thumbnail", "year", "genre", "file", "albumid"]}, "id": 1}')
  216.         json_query = unicode(json_query, 'utf-8', errors='ignore')
  217.         json_response = simplejson.loads(json_query)
  218.         if json_response.has_key('result') and (json_response['result'] != None) and  (json_response['result'].has_key('songs')):
  219.             for count,recentitem in enumerate(json_response['result']['songs']):
  220.                     title = recentitem['title']
  221.                     artist = recentitem['artist']
  222.                     fanart = recentitem['fanart']
  223.                     thumbnail = recentitem['thumbnail']
  224.                     year = str(recentitem['year'])
  225.                     genre = recentitem['genre']
  226.                     countrecent = str(count)
  227.                     path = recentitem['file']
  228.                     albumid = str(recentitem['albumid'])
  229.                     playlistpath = 'XBMC.RunScript(' + __addonid__ + ',songrecent=' + countrecent + ')'
  230.                     self.songsrecents.append([title, artist, fanart, thumbnail, year, genre, countrecent, path, albumid])                
  231.                     if count == 200:
  232.                        break
  233.     def _fetch_albunsrecents( self ):
  234.         self.albunsrecents = []
  235.         repeatalbum = {}
  236.         for count, albumsongs in enumerate( self.songsrecents ):
  237.            json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbumDetails", "params": {"properties": ["title", "artist", "fanart", "thumbnail", "year", "genre", "albumlabel"], "albumid":%s }, "id": 1}' % albumsongs[8])
  238.            json_query = unicode(json_query, 'utf-8', errors='ignore')
  239.            json_response = simplejson.loads(json_query)
  240.            if json_response.has_key('result') and (json_response['result'] != None) and  (json_response['result'].has_key('albumdetails')):
  241.                     recentitem = json_response['result']['albumdetails']
  242.                     albumlabel = recentitem['albumlabel']
  243.                     title = recentitem['title']
  244.                     artist = recentitem['artist']
  245.                     fanart = recentitem['fanart']
  246.                     thumbnail = recentitem['thumbnail']
  247.                     year = str(recentitem['year'])
  248.                     genre = recentitem['genre']
  249.                     albumid = albumsongs[8]
  250.                     if albumid in repeatalbum:
  251.                        continue
  252.                     #path = recentitem['albumid']
  253.                     repeatalbum[albumid] = 1
  254.                     playlistpath = "musicdb://3/%s/" % albumid
  255.                     #playlistpath = 'XBMC.RunScript(' + __addonid__ + ',albumid=' + albumid + ')'
  256.                     self.albunsrecents.append([title, artist, fanart, thumbnail, year, genre, playlistpath, albumid ])                            
  257.                
  258.     def _setproperties_moviesrecents( self ):
  259.         if (len(self.moviesrecents) > 0) and self.rctmoviesunwatched == 'true':
  260.            listtouse = self.moviesrecents
  261.         else:
  262.            listtouse = self.moviesrecentsall
  263.         for count, movie in enumerate( listtouse ):
  264.             count += 1
  265.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Title" % ( count ), movie[0] )
  266.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Year" % ( count ), movie[1] )
  267.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Genre" % ( count ), movie[2][0] )
  268.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Studio" % ( count ), movie[3][0] )
  269.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Plot" % ( count ), movie[4] )
  270.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.PlotOutline" % ( count ), movie[5] )
  271.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Tagline" % ( count ), movie[6] )
  272.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.RunningTime" % ( count ), movie[7] )
  273.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Fanart" % ( count ), movie[8] )
  274.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Thumb" % ( count ), movie[9] )
  275.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Path" % ( count ), movie[10] )
  276.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Rating" % ( count ), movie[11] )
  277.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Trailer" % ( count ), movie[12] )
  278.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.MPAA" % ( count ), movie[13] )
  279.             if count == self.LIMIT:
  280.                break
  281.                
  282.     def _setproperties_moviesrecentslatest( self ):
  283.         count = 0        
  284.         while count < self.LIMIT:
  285.             count += 1
  286.             Title = self.WINDOW.getProperty('LatestMovie.%d.Title' % count)
  287.             Year = ""
  288.             Genre = ""
  289.             Studio = ""
  290.             PlotOutline = ""
  291.             Tagline = ""
  292.             Plot = self.WINDOW.getProperty("LatestMovie.%d.Plot" % count )
  293.             RunningTime = self.WINDOW.getProperty("LatestMovie.%d.RunningTime" % count)
  294.             Fanart = self.WINDOW.getProperty("LatestMovie.%d.Fanart" % count)
  295.             Thumb = self.WINDOW.getProperty("LatestMovie.%d.Thumb" % count)
  296.             Path = self.WINDOW.getProperty("LatestMovie.%d.Path" % count)
  297.             Rating = self.WINDOW.getProperty("LatestMovie.%d.Rating" % count)
  298.             Trailer = self.WINDOW.getProperty("LatestMovie.%d.Trailer" % count)
  299.             MPAA = ""
  300.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Title" % ( count ), Title )
  301.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Year" % ( count ), Year )
  302.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Genre" % ( count ), Genre )
  303.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Studio" % ( count ), Studio )
  304.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Plot" % ( count ), Plot )
  305.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.PlotOutline" % ( count ), PlotOutline )
  306.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Tagline" % ( count ), Tagline )
  307.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.RunningTime" % ( count ), RunningTime )
  308.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Fanart" % ( count ), Fanart )
  309.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Thumb" % ( count ), Thumb )
  310.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Path" % ( count ), Path )
  311.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Rating" % ( count ), Rating )
  312.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.Trailer" % ( count ), Trailer )
  313.             self.WINDOW.setProperty( "AllinOne_MovieRecents.%d.MPAA" % ( count ), MPAA )
  314.                    
  315.     def _setproperties_episodesrecents( self ):
  316.         if len(self.episodesrecents) > 0:
  317.            listtouse = self.episodesrecents
  318.         else:
  319.            listtouse = self.episodesrecentsall
  320.         for count, episode in enumerate( listtouse ):
  321.             count += 1
  322.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Title" % ( count ), episode[0] )
  323.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Episode" % ( count ), episode[3] )
  324.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Season" % ( count ), episode[2] )
  325.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Plot" % ( count ), episode[5] )
  326.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.TVShowTitle" % ( count ), episode[1] )
  327.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Path" % ( count ), episode[6] )
  328.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Thumb" % ( count ), episode[7] )
  329.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Fanart" % ( count ), episode[8] )
  330.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.EpisodeNo" % ( count ), episode[9] )
  331.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.SeasonThumb" % ( count ), episode[10] )
  332.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Rating" % ( count ), episode[4] )
  333.             xbmc.log(msg="episodes recents")                          
  334.             if count == self.LIMIT:
  335.                break
  336.                
  337.     def _setproperties_episodesrecentslatest( self ):
  338.         count = 0        
  339.         while count < self.LIMIT:
  340.             count += 1
  341.             EpisodeTitle = self.WINDOW.getProperty('LatestEpisode.%d.EpisodeTitle' % count)
  342.             Episode = ""
  343.             Season = ""
  344.             Plot = self.WINDOW.getProperty('LatestEpisode.%d.Plot' % count)
  345.             ShowTitle = self.WINDOW.getProperty('LatestEpisode.%d.ShowTitle' % count)
  346.             Path = self.WINDOW.getProperty('LatestEpisode.%d.Path' % count)                        
  347.             Thumb = self.WINDOW.getProperty('LatestEpisode.%d.Thumb' % count)
  348.             Fanart = self.WINDOW.getProperty('LatestEpisode.%d.Fanart' % count)
  349.             EpisodeNo = self.WINDOW.getProperty('LatestEpisode.%d.EpisodeNo' % count)
  350.             SeasonThumb = ""
  351.             Rating = self.WINDOW.getProperty('LatestEpisode.%d.Rating' % count)            
  352.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Title" % ( count ), EpisodeTitle )
  353.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Episode" % ( count ), Episode )
  354.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Season" % ( count ), Season )
  355.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Plot" % ( count ), Plot )
  356.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.TVShowTitle" % ( count ), ShowTitle )
  357.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Path" % ( count ), Path )
  358.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Thumb" % ( count ), Thumb )
  359.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Fanart" % ( count ), Fanart )
  360.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.EpisodeNo" % ( count ), EpisodeNo )
  361.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.SeasonThumb" % ( count ), SeasonThumb )
  362.             self.WINDOW.setProperty( "AllinOne_EpisodeRecents.%d.Rating" % ( count ), Rating )          
  363.                
  364.     def _setproperties_musicvideosrecents( self ):
  365.         if len(self.musicvideosrecents) > 0:
  366.            listtouse = self.musicvideosrecents
  367.         else:
  368.            listtouse = self.musicvideosrecentsall
  369.         for count, musicvideo in enumerate( listtouse ):
  370.             count += 1
  371.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Title" % ( count ), musicvideo[0] )
  372.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Year" % ( count ), musicvideo[1] )
  373.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Genre" % ( count ), musicvideo[2][0] )
  374.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Studio" % ( count ), musicvideo[3][0] )
  375.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Plot" % ( count ), musicvideo[4] )
  376.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.RunningTime" % ( count ), musicvideo[5] )
  377.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Fanart" % ( count ), musicvideo[6] )
  378.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Thumb" % ( count ), musicvideo[7] )
  379.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Path" % ( count ), musicvideo[8] )
  380.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.PercentPlayed" % ( count ) , musicvideo[9] )
  381.             if count == self.LIMIT:
  382.                break
  383.                
  384.     def _setproperties_musicvideosrecentslatest( self ):                                
  385.         count = 0        
  386.         while count < self.LIMIT:
  387.             count += 1
  388.             Title = self.WINDOW.getProperty('LatestMusicVideo.%d.Title' % count)
  389.             Year = self.WINDOW.getProperty('LatestMusicVideo.%d.Year' % count)
  390.             Genre = ""
  391.             Studio = ""
  392.             Plot = self.WINDOW.getProperty('LatestMusicVideo.%d.Plot' % count)
  393.             RunningTime = self.WINDOW.getProperty('LatestMusicVideo.%d.RunningTime' % count)
  394.             Fanart = self.WINDOW.getProperty('LatestMusicVideo.%d.Fanart' % count)
  395.             Thumb = self.WINDOW.getProperty('LatestMusicVideo.%d.Thumb' % count)
  396.             Path = self.WINDOW.getProperty('LatestMusicVideo.%d.Path' % count)
  397.             PercentPlayed = ""
  398.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Title" % ( count ), Title )
  399.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Year" % ( count ), Year )
  400.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Genre" % ( count ), Genre )
  401.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Studio" % ( count ), Studio )
  402.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Plot" % ( count ), Plot )
  403.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.RunningTime" % ( count ), RunningTime )
  404.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Fanart" % ( count ), Fanart )
  405.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Thumb" % ( count ), Thumb )
  406.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.Path" % ( count ), Path)
  407.             self.WINDOW.setProperty( "AllinOne_MusicVideoRecents.%d.PercentPlayed" % ( count ) , PercentPlayed )
  408.            
  409.            
  410.     def _setproperties_songsrecents( self ):
  411.         for count, songs in enumerate( self.songsrecents ):
  412.             count += 1
  413.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Title" % ( count ), songs[0] )
  414.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Artist" % ( count ), songs[1][0] )
  415.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Genre" % ( count ), songs[5][0] )          
  416.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Year" % ( count ), songs[4] )
  417.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Thumb" % ( count ), songs[3] )
  418.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Fanart" % ( count ), songs[2] )
  419.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Path" % ( count ), songs[7] )
  420.             xbmc.log(msg="songs recents")
  421.             if count == int(self.LIMIT):
  422.                 # stop here if our list contains more items
  423.                 break
  424.    
  425.     def _setproperties_songsrecentslatest( self ):
  426.         count = 0
  427.         while count < self.LIMIT:
  428.             count += 1
  429.             Title = self.WINDOW.getProperty('LatestSong.%d.Title' % count)
  430.             Artist = self.WINDOW.getProperty('LatestSong.%d.Artist' % count)
  431.             Genre = self.WINDOW.getProperty('LatestSong.%d.Genre' % count)
  432.             Year = self.WINDOW.getProperty('LatestSong.%d.Year' % count)
  433.             Thumb = self.WINDOW.getProperty('LatestSong.%d.Thumb' % count)
  434.             Fanart = self.WINDOW.getProperty('LatestSong.%d.Fanart' % count)
  435.             Path = self.WINDOW.getProperty('LatestSong.%d.Path' % count)                
  436.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Title" % ( count ), Title )
  437.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Artist" % ( count ), Artist )
  438.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Genre" % ( count ), Genre)          
  439.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Year" % ( count ), Year )
  440.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Thumb" % ( count ), Thumb )
  441.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Fanart" % ( count ), Fanart )
  442.             self.WINDOW.setProperty( "AllinOne_SongRecents.%d.Path" % ( count ), Path )
  443.                
  444.     def _setproperties_albunsrecents( self ):
  445.         for count, album in enumerate( self.albunsrecents ):
  446.             count += 1
  447.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Title" % ( count ), album[0] )
  448.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Artist" % ( count ), album[1][0] )
  449.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Genre" % ( count ), album[5][0] )
  450.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Year" % ( count ), album[4] )
  451.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Thumb" % ( count ), album[3] )
  452.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Fanart" % ( count ), album[2] )
  453.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Path" % ( count ), album[6] )
  454.             xbmc.log(msg="albuns recents")
  455.             if count == int(self.LIMIT):
  456.                 # stop here if our list contains more items
  457.                 break                                                            
  458.    
  459.     def _setproperties_albunsrecentslatest( self ):
  460.         count = 0
  461.         while count < self.LIMIT:
  462.             count += 1
  463.             Title = self.WINDOW.getProperty('LatestAlbum.%d.Title' % count)
  464.             Artist = self.WINDOW.getProperty('LatestAlbum.%d.Artist' % count)
  465.             Genre = self.WINDOW.getProperty('LatestAlbum.%d.Genre' % count)
  466.             Year = self.WINDOW.getProperty('LatestAlbum.%d.Year' % count)
  467.             Thumb = self.WINDOW.getProperty('LatestAlbum.%d.Thumb' % count)
  468.             Fanart = self.WINDOW.getProperty('LatestAlbum.%d.Fanart' % count)
  469.             Path = self.WINDOW.getProperty('LatestAlbum.%d.Path' % count)
  470.             xbmc.log(msg=Path)
  471.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Title" % ( count ), Title)
  472.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Artist" % ( count ), Artist )
  473.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Genre" % ( count ), Genre )
  474.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Year" % ( count ), Year )
  475.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Thumb" % ( count ), Thumb )
  476.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Fanart" % ( count ), Fanart )
  477.             self.WINDOW.setProperty( "AllinOne_AlbumRecents.%d.Path" % ( count ), Path )
  478.  
  479.     def _clearproperties_moviesrecents( self ):
  480.         for count in range (self.LIMIT):
  481.             count += 1
  482.             self.WINDOW.clearProperty( "AllinOne_MovieRecents.%d.Title" % ( count ) )          
  483.            
  484.     def _clearproperties_episodesrecents( self ):
  485.         for count in range((self.LIMIT) ):
  486.             count += 1
  487.             self.WINDOW.clearProperty( "AllinOne_EpisodeRecents.%d.Title" % ( count ) )
  488.            
  489.     def _clearproperties_musicvideosrecents( self ):
  490.         for count in range((self.LIMIT) ):
  491.             count += 1
  492.             self.WINDOW.clearProperty( "AllinOne_MusicVideoRecents.%d.Title" % ( count ) )                                              
  493.    
  494.     def _clearproperties_songsrecents( self ):
  495.         for count in range((self.LIMIT) ):
  496.             count += 1
  497.             self.WINDOW.clearProperty( "AllinOne_SongRecents.%d.Title" % ( count ) )
  498.    
  499.     def _clearproperties_albunsrecents( self ):
  500.         for count in range((self.LIMIT) ):
  501.             count += 1
  502.             self.WINDOW.clearProperty( "AllinOne_AlbumRecents.%d.Title" % ( count ) )          
  503.          
  504. class fetchrecents(Thread):
  505.     def __init__ (self, fetchrecent, clearrecent, setrecent):
  506.         self.fetchrecent = fetchrecent
  507.         self.clearrecent = clearrecent
  508.         self.setrecent = setrecent
  509.         Thread.__init__(self)
  510.     def run(self):
  511.         self.fetchrecent()
  512.         self.clearrecent()
  513.         self.setrecent()
  514.                                              
  515. if ( __name__ == "__main__" ):
  516.     log('script version %s started' % __addonversion__)
  517.     Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement