コード例 #1
0
ファイル: default.py プロジェクト: ruuk/script.tvrage.com
 def findXBMCEpFile(self, show, season, eptitle):
     if self.json_use_http:
         jrapi = jsonrpc.jsonrpcAPI(url=self.http_address + '/jsonrpc',
                                    user=self.http_user,
                                    password=self.http_pass)
     else:
         jrapi = jsonrpc.jsonrpcAPI()
     labels = []
     ids = []
     for s in jrapi.VideoLibrary.GetTVShows()['tvshows']:
         labels.append(s['label'])
         ids.append(s['tvshowid'])
     mshow = difflib.get_close_matches(show, labels, 1, 0.7)
     if not mshow: return
     mshow = mshow[0]
     eplist = jrapi.VideoLibrary.GetEpisodes(
         tvshowid=ids[labels.index(mshow)],
         season=int(season),
         properties=['file'])
     if not 'episodes' in eplist: return
     labels = []
     files = []
     for e in eplist['episodes']:
         labels.append(e['label'])
         files.append(e['file'])
     mep = difflib.get_close_matches(eptitle, labels, 1, 0.7)
     if not mep: return
     #print mep
     #print labels
     efile = files[labels.index(mep[0])]
     #print efile
     return efile
コード例 #2
0
ファイル: default.py プロジェクト: 070499/repo-scripts
	def findXBMCEpFile(self,show,season,eptitle):
		if self.json_use_http:
			jrapi = jsonrpc.jsonrpcAPI(url=self.http_address + '/jsonrpc',user=self.http_user,password=self.http_pass)
		else:
			jrapi = jsonrpc.jsonrpcAPI()
		labels = []
		ids = []
		for s in jrapi.VideoLibrary.GetTVShows()['tvshows']:
			labels.append(s['label'])
			ids.append(s['tvshowid'])
		mshow = difflib.get_close_matches(show,labels,1,0.7)
		if not mshow: return
		mshow = mshow[0]
		eplist = jrapi.VideoLibrary.GetEpisodes(tvshowid=ids[labels.index(mshow)],season=season)
		if not 'episodes' in eplist: return
		labels = []
		files = []
		for e in eplist['episodes']:
			labels.append(e['label'])
			files.append(e['file'])
		mep = difflib.get_close_matches(eptitle,labels,1,0.7)
		if not mep: return
		#print mep
		#print labels
		efile = files[labels.index(mep[0])]
		#print efile
		return efile
コード例 #3
0
ファイル: default.py プロジェクト: ruuk/script.tvrage.com
 def addFromLibrary(self):
     pdialog = xbmcgui.DialogProgress()
     pdialog.create(__language__(32027))
     try:
         pdialog.update(0)
         if self.json_use_http:
             jrapi = jsonrpc.jsonrpcAPI(mode='http',
                                        url=self.http_address,
                                        user=self.http_user,
                                        password=self.http_pass)
             LOG("JSONRPCAPI: Using HTTP")
         else:
             jrapi = jsonrpc.jsonrpcAPI()
         try:
             shows = jrapi.VideoLibrary.GetTVShows()
             LOG("JSONRPCAPI returned successfully")
         except jsonrpc.UserPassError:
             xbmcgui.Dialog().ok(__language__(32031), __language__(32032),
                                 __language__(32033), __language__(32034))
             LOG("JSONRPCAPI user/pass error")
             return
         except jsonrpc.ConnectionError, e:
             xbmcgui.Dialog().ok(__language__(32031), __language__(32035),
                                 __language__(32036), __language__(32037))
             LOG("JSONRPCAPI error: {0}".format(e.message))
             return
         except Exception, e:
             LOG("JSONRPCAPI error: {0}".format(e.message))
             xbmcgui.Dialog().ok(__language__(32031), e.message)
コード例 #4
0
    def initialise(self, useSQL):
        self.useSQL = useSQL
        if (self.useSQL):
            self.useMySQL = False
            myVideoConfig = self.getVideoDBConfig()
            dbType = myVideoConfig["type"]
            dbName = myVideoConfig["name"]

            if (dbType == "mysql"):
                log("Using MySQL connector: %s" % myVideoConfig)
                self.useMySQL = True
                self.db_conn = mysql.connector.connect(
                    user=myVideoConfig["user"],
                    password=myVideoConfig["pass"],
                    host=myVideoConfig["host"],
                    port=myVideoConfig["port"],
                    database=dbName.encode("utf-8"))
            else:
                log("Using SQlite connector: %s" % myVideoConfig)
                dbName = "%s.db" % dbName
                self.video_db = os.path.join(
                    xbmc.translatePath("special://database"), dbName)
                self.db_conn = sqlite.connect(self.video_db)
            self.db_conn.row_factory = sqlite.Row
        else:
            self.json_api = jsonrpc.jsonrpcAPI()
コード例 #5
0
ファイル: default.py プロジェクト: miigotu/script.tvrage.com
	def addFromLibrary(self):
		pdialog = xbmcgui.DialogProgress()
		pdialog.create(__language__(32027))
		try:
			pdialog.update(0)
			if self.json_use_http:
				jrapi = jsonrpc.jsonrpcAPI(mode='http',url=self.http_address,user=self.http_user,password=self.http_pass)
				LOG("JSONRPCAPI: Using HTTP")
			else:
				jrapi = jsonrpc.jsonrpcAPI()
			try:
				shows = jrapi.VideoLibrary.GetTVShows()
				LOG("JSONRPCAPI returned successfully")
			except jsonrpc.UserPassError:
				xbmcgui.Dialog().ok(__language__(32031),__language__(32032),__language__(32033),__language__(32034))
				LOG("JSONRPCAPI user/pass error")
				return
			except jsonrpc.ConnectionError,e:
				xbmcgui.Dialog().ok(__language__(32031),__language__(32035),__language__(32036),__language__(32037))
				LOG("JSONRPCAPI error: {0}".format(e.message))
				return
			except Exception, e:
				LOG("JSONRPCAPI error: {0}".format(e.message))
				xbmcgui.Dialog().ok(__language__(32031), e.message)
コード例 #6
0
 def initialise( self, useSQL ):
     self.useSQL = useSQL
     if (self.useSQL):
         self.useMySQL = False
         myVideoConfig = self.getVideoDBConfig()
         dbType = myVideoConfig["type"]
         dbName = myVideoConfig["name"]
         
         if (dbType == "mysql"):
             log( "Using MySQL connector: %s" % myVideoConfig )
             self.useMySQL = True
             self.db_conn = mysql.connector.connect(
                               user=myVideoConfig["user"], password=myVideoConfig["pass"],
                               host=myVideoConfig["host"], port=myVideoConfig["port"],
                               database=dbName.encode("utf-8"))
         else:
             log( "Using SQlite connector: %s" % myVideoConfig )
             dbName = "%s.db" % dbName
             self.video_db = os.path.join(xbmc.translatePath("special://database"), dbName)
             self.db_conn = sqlite.connect(self.video_db)
         self.db_conn.row_factory = sqlite.Row
     else:
         self.json_api = jsonrpc.jsonrpcAPI()
コード例 #7
0
ファイル: default.py プロジェクト: 070499/repo-scripts
	def addFromLibrary(self):
		pdialog = xbmcgui.DialogProgress()
		pdialog.create(__language__(30027))
		try:
			pdialog.update(0)
			if self.json_use_http:
				jrapi = jsonrpc.jsonrpcAPI(mode='http',url=self.http_address + '/jsonrpc',user=self.http_user,password=self.http_pass)
			else:
				jrapi = jsonrpc.jsonrpcAPI()
			try:
				shows = jrapi.VideoLibrary.GetTVShows()
			except jsonrpc.UserPassError:
				xbmcgui.Dialog().ok(__language__(30031),__language__(30032),__language__(30033),__language__(30034))
				return
			except jsonrpc.ConnectionError:
				xbmcgui.Dialog().ok(__language__(30031),__language__(30035),__language__(30036),__language__(30037))
				return
			if not 'tvshows' in shows: return #TODO put a dialog here
			tot = len(shows['tvshows'])
			ct=0.0
			added=0
			exist=0
			at_end = []
			for s in shows['tvshows']:
			#for s in [{'label':u'Fight Ippatsu! Jūden-chan!!'}]:
				title = s['label']
				pdialog.update(int((ct/tot)*100),title)
				dummy = False
				for c in self.shows:
					if difflib.get_close_matches(title,[c.name],1,0.7):
						LOG("SHOW: " + title + " - EXISTS AS: " + c.name)
						exist+=1
						if c.isDummy():
							dummy = True
							continue
						break
				else:
					result = API.search(title)
					close = None
					if result:
						matches = {}
						for f in result.findall('show'):
							matches[f.find('name').text] = f.find('showid').text
						close = difflib.get_close_matches(title,matches.keys(),1,0.8)
					if close:
						LOG("SHOW: " + title + " - MATCHES: " + close[0])
						pdialog.update(int((ct/tot)*100),__language__(30028) + title)
						self.doAddShow(matches[close[0]],skipCanceled=self.skip_canceled)
						added+=1
					else:
						if self.ask_on_no_match:
							if dummy:
								ct+=1
								continue
							at_end.append((title,result))
				ct+=1
		finally:
			pdialog.close()
		while at_end:
			left = []
			for s in at_end: left.append(__language__(30051) + s[0])
			idx = xbmcgui.Dialog().select(__language__(30052),['< %s >' % (__language__(30053))] + left)
			if idx < 1: break
			title,result = at_end.pop(idx-1)
			sid = self.userPickShow(result,append=title)
			if sid: added+=self.doAddShow(sid,skipCanceled=self.skip_canceled,name=title)
			
		#for s in at_end:
		#	title,result = s
		#	sid = self.userPickShow(result,append=title)
		#	if sid: added+=self.doAddShow(sid,skipCanceled=self.skip_canceled,name=title)
		self.saveData()
		self.updateDisplay()
		skipped = ct - (added + exist)
		xbmcgui.Dialog().ok(	__language__(30042),
								__language__(30043).replace('@NUMBER1@',str(added)).replace('@NUMBER2@',str(int(ct))),
								__language__(30044).replace('@NUMBER@',str(exist)),
								__language__(30045).replace('@NUMBER@',str(int(skipped))))
コード例 #8
0
ファイル: database.py プロジェクト: Quihico/passion-xbmc
def getContainerMovieSets(infoSet=None):
    jsonapi = jsonrpc.jsonrpcAPI()
    # GET MOVIESETS
    json = jsonapi.VideoLibrary.GetMovieSets(properties=VIDEO_FIELDS_MOVIESET)

    movie_sets = json.get("sets", [])
    total = json.get("limits", {}).get("total") or len(movie_sets)
    # print total

    # dico for synchronize main container on VideoLibrary with virtual container of MovieSets
    moviesets = {}
    if infoSet is not None:
        # get only one user want info
        listitems = []
    else:
        # set dymmy listitem, label: container title , label2: total movie sets
        listitems = [xbmcgui.ListItem("Container MovieSets", str(total))]

    # reload addon settings
    try:
        ADDON = Addon("script.moviesets")
    except:
        pass
    # get user separator
    try:
        separator = " %s " % ADDON.getSetting("separator")
    except:
        separator = " / "
    # get user prefer order
    try:
        SORTTITLE["order"] = ("ascending", "descending")[int(ADDON.getSetting("order"))]
    except:
        pass

    # enum movie sets
    for countset, movieset in enumerate(movie_sets):
        # print movieset.keys()#[u'title', u'fanart', u'label', u'playcount', u'thumbnail', u'setid']
        try:
            idSet = movieset["setid"]
            # print ( idSet, infoSet, str( idSet ) != infoSet )
            if infoSet is not None and str(idSet) != infoSet:
                continue  # get only one user want info
            # get saga icon
            icon = movieset["thumbnail"]
            icon = ("", icon)[path_exists(translatePath(icon))]
            # get saga fanart
            # d, f = os.path.split( movieset[ 'thumbnail' ] )
            # c_fanart = "%sFanart/%s" % ( d[ :-1 ], f )
            c_fanart = movieset["fanart"]
            Fanart_Image = ("", c_fanart)[path_exists(translatePath(c_fanart))]
            # fixe me: xbmc not change/reload/refresh image if path is same
            if Fanart_Image:
                Fanart_Image = get_cached_thumb(Fanart_Image)
            if icon:
                icon = get_cached_thumb(icon)

            # set movieset listitem
            listitem = xbmcgui.ListItem(movieset["label"], str(idSet), icon, icon)
            # listitem.setPath( "ActivateWindow(10025,videodb://1/7/%i/)" % idSet )

            # get movies list of movieset
            # not good, return only Video.Fields.MovieSet. [use Files.GetDirectory for more fields]
            # json = jsonapi.VideoLibrary.GetMovieSetDetails( setid=idSet, properties=VIDEO_FIELDS_MOVIESET )
            json = jsonapi.Files.GetDirectory(
                directory="videodb://1/7/%i/" % idSet, properties=VIDEO_FIELDS_MOVIE, sort=SORTTITLE, media="video"
            )
            movies = json.get("files", [])
            total_movies = json.get("limits", {}).get("total") or len(movies)
            # set base variables
            watched, unwatched = 0, total_movies
            rating, votes = 0.0, 0
            plotset = ""
            mpaa = set()
            studios = set()
            genres = set()
            years = set()
            # fanartsets = set()
            countries = set()
            stackpath = []
            stacktrailer = []
            duration = 0.1
            iWidth = 0
            iHeight = 0
            aspect = 0.0

            # enum movies
            for count, movie in enumerate(movies):
                if not bool(movie):
                    continue
                # print movie.keys()#[u'rating', u'set', u'filetype', u'file', u'year', u'id', u'streamDetails', u'plot', u'votes', u'title', u'fanart', u'mpaa', u'writer', u'label', u'type', u'thumbnail', u'plotoutline', u'resume', u'director', u'imdbnumber', u'studio', u'showlink', u'genre', u'productioncode', u'country', u'premiered', u'originaltitle', u'cast', u'tagline', u'playcount', u'runtime', u'top250', u'trailer']
                # for more infos
                # print jsonapi.VideoLibrary.GetMovieDetails( movieid=int(movie["id"]), properties=VIDEO_FIELDS_MOVIE )
                # print movie[ "votes" ]
                # continue
                try:
                    # optional
                    try:
                        sdv = movie["streamdetails"].get("video", [{}])
                        duration += sum(d.get("duration", 0) for d in sdv)
                        iWidth += sum(w.get("width", 0) for w in sdv)
                        iHeight += sum(h.get("height", 0) for h in sdv)
                        aspect += sum(a.get("aspect", 0) for a in sdv)
                    except:
                        pass
                    # update mpaa
                    if movie.get("mpaa"):
                        mpaa.add(movie["mpaa"])
                    # set watched count
                    # print movie.get( "playcount" )
                    if bool(movie["playcount"]):
                        watched += 1
                    # update genres and years
                    if movie["year"] > 0:
                        years.add(str(movie["year"]))
                    try:
                        genres.update(movie["genre"].split(" / "))
                    except:
                        genres.update(movie["genre"])
                    genres.discard("")
                    # add country
                    if movie.get("country"):
                        try:
                            countries.update(movie["country"].split(" / "))
                        except:
                            countries.update(movie["country"])
                    countries.discard("")
                    # add studio
                    if movie.get("studio"):
                        try:
                            studios.update(movie["studio"].split(" / "))
                        except:
                            studios.update(movie["studio"])
                    studios.discard("")
                    # add plot movie to plotset
                    plotset += "[B]%(title)s (%(year)s)[/B][CR]%(plot)s[CR][CR]" % movie
                    # set stack, add movie path and trailer
                    if movie.get("trailer"):
                        stacktrailer.append(movie["trailer"])
                    stackpath.append(movie["file"])
                    # use first path if stacked. for prevent this [WARNING: XFILE::CFileFactory::CreateLoader - Unsupported protocol(stack) in path_exists( moviepath + "extrafanart" )]
                    if "stack://" in movie["file"]:
                        movie["file"] = movie["file"][8:].split(" , ")[0]
                    # set RatingAndVotes info
                    rating += movie.get("rating", 0.0)
                    try:
                        votes += int(movie.get("votes", "0").replace(",", ""))
                    except:
                        pass

                    # set movies properties 'plot', 'votes', 'rating', 'fanart', 'title', 'label',
                    # 'file', 'year', 'genre','playcount', 'runtime', 'thumbnail', 'trailer'
                    b_property = "movie.%i." % (count + 1)
                    moviepath = os.path.dirname(movie["file"]) + ("/", "\\")[not movie["file"].count("/")]
                    listitem.setProperty(b_property + "Title", movie["title"])
                    listitem.setProperty(b_property + "sortTitle", movie.get("sorttitle", ""))
                    listitem.setProperty(b_property + "Filename", os.path.basename(movie["file"]))
                    listitem.setProperty(b_property + "Path", moviepath)
                    listitem.setProperty(b_property + "Plot", movie["plot"])
                    listitem.setProperty(b_property + "Year", str(movie["year"] or ""))
                    listitem.setProperty(b_property + "Trailer", movie.get("trailer", ""))
                    # set icon property
                    icon = movie["thumbnail"]
                    icon = ("", icon)[path_exists(translatePath(icon))]
                    # print repr( icon )
                    if not icon:  # check for auto-
                        _path, _file = os.path.split(icon)
                        a_icon = os.path.join(_path, "auto-" + _file)
                        icon = ("", a_icon)[path_exists(translatePath(a_icon))]
                    listitem.setProperty(b_property + "Icon", icon)
                    # set fanart property
                    fanart = movie["fanart"]
                    fanart = ("", fanart)[path_exists(translatePath(fanart))]
                    listitem.setProperty(b_property + "Fanart", fanart)
                    if fanart and not Fanart_Image:
                        Fanart_Image = fanart
                    # set extrafanart: if not exists set empty
                    extrafanart = moviepath + "extrafanart"
                    extrafanart = ("", extrafanart)[path_exists(extrafanart)]
                    listitem.setProperty(b_property + "ExtraFanart", extrafanart)
                    # set extrafanart for movieset if exists set first found
                    # fanartsets.add( os.path.dirname( os.path.dirname( moviepath ) ) )
                    if listitem.getProperty("ExtraFanart"):
                        continue
                    fanartset = os.path.dirname(os.path.dirname(moviepath))
                    fanartset += ("/", "\\")[not fanartset.count("/")] + "extrafanart"
                    if path_exists(fanartset):
                        listitem.setProperty("ExtraFanart", fanartset)
                    elif extrafanart:
                        listitem.setProperty("ExtraFanart", extrafanart)

                    # print _encode(movie[ "file" ]), _encode(moviepath), _encode(fanartset)
                    # print "-"*100
                except:
                    LOGGER.error.print_exc()

            # set movieset properties
            listitem.setProperty("IsSet", "true")
            listitem.setProperty("idSet", str(idSet))
            listitem.setProperty("WatchedMovies", str(watched))
            listitem.setProperty("UnWatchedMovies", str(unwatched - watched))
            listitem.setProperty("TotalMovies", str(total_movies))
            listitem.setProperty("Fanart_Image", Fanart_Image)
            listitem.setProperty("Years", separator.join(sorted(years, reverse=(SORTTITLE["order"] == "descending"))))
            try:
                listitem.setProperty("StarRating", getStarRating(rating / float(total_movies)))
            except:
                listitem.setProperty("StarRating", "rating0.png")
            listitem.setProperty("Countries", separator.join(countries))
            listitem.setProperty(
                "VideoResolution",
                VideoDimsToResolutionDescription(int(iWidth / total_movies), int(iHeight / total_movies)),
            )
            listitem.setProperty("VideoAspect", VideoAspectToAspectDescription(float(aspect / total_movies)))

            # set stack path
            stackpath = " ; ".join(stackpath)
            if " ; " in stackpath:
                stackpath = "stackset://" + stackpath
            listitem.setPath(quote_plus(_encode(stackpath)))
            # set stack trailer
            stacktrailer = " , ".join(stacktrailer)
            if " , " in stacktrailer:
                stacktrailer = "stack://" + stacktrailer

            # set listitem infoslabels
            listitem.setInfo(
                "video",
                {
                    "plot": plotset,
                    "votes": str(votes),
                    "title": movieset["label"],
                    "studio": separator.join(studios),
                    # "duration": str( round( duration / 60.0, 2 ) ),
                    "duration": str(int(duration / 60.0)),
                    "rating": (rating / float(total_movies)),
                    "genre": separator.join(sorted([g.strip() for g in genres])),
                    "mpaa": separator.join([m.strip() for m in mpaa]),
                    "trailer": stacktrailer,
                },
            )

            moviesets[_encode(movieset["label"])] = countset + 1
            listitems.append(listitem)

            if infoSet is not None and idSet == infoSet:
                moviesets[movieset["label"]] = 0
                break  # get only one user want info
        except:
            LOGGER.error.print_exc()

    return listitems, moviesets
コード例 #9
0
ファイル: database.py プロジェクト: mrbusta/passion-xbmc
    def getContainerMovieSets(self, infoSet=None):
        jrapi = jsonrpc.jsonrpcAPI()
        # GET MOVIESETS
        json = jrapi.Files.GetDirectory(directory="videodb://1/7/",
                                        media="video")
        movie_sets = json.get('directories', [])
        total = json.get("total") or len(movie_sets)

        # dico for synchronize container
        moviesets = {}
        # set dymmy listitem label: container title , label2: total movie sets
        if infoSet is not None: listitems = []  # get only one user want info
        else: listitems = [xbmcgui.ListItem("Movie Sets", str(total))]

        # get user separator
        try:
            separator = " %s " % ADDON.getSetting("separator")
        except:
            separator = " / "
        # get user prefer order
        try:
            sorttitle["order"] = ("ascending",
                                  "descending")[int(ADDON.getSetting("order"))]
        except:
            pass

        # enum movie sets
        for countset, movieset in enumerate(movie_sets):
            #print movieset.keys()
            try:
                idSet = movieset["file"][14:-1]
                if infoSet is not None and idSet != infoSet:
                    continue  # get only one user want info
                # get saga icon and fanart
                icon = ("", movieset['thumbnail'])[os.path.exists(
                    translatePath(movieset['thumbnail']))]
                d, f = os.path.split(movieset['thumbnail'])
                c_fanart = "%sFanart/%s" % (d[:-1], f)
                Fanart_Image = ("", c_fanart)[os.path.exists(
                    translatePath(c_fanart))]
                # fixe me: xbmc not change/reload/refresh image if path is same
                if Fanart_Image:
                    Fanart_Image = self.get_cached_thumb(Fanart_Image)
                if icon: icon = self.get_cached_thumb(icon)
                # set movieset listitem
                listitem = xbmcgui.ListItem(movieset['label'], idSet, icon,
                                            icon)
                #listitem.setPath( "ActivateWindow(10025,%s)" % movieset[ "file" ] )

                # get list of movieset
                json = jrapi.Files.GetDirectory(directory=movieset["file"],
                                                fields=fields,
                                                sort=sorttitle,
                                                media="video")
                movies = json.get('files', [])
                total_movies = json.get("total") or len(movies)
                # set base variables
                watched, unwatched = 0, total_movies
                rating, votes = 0.0, 0
                plotset = ""
                studios = set()
                genres = set()
                years = set()
                fanartsets = set()
                countries = set()
                stackpath = []
                stacktrailer = []

                # enum movies
                for count, movie in enumerate(movies):
                    #print movie.keys()
                    try:
                        # set watched count
                        #print movie.get( "playcount" )
                        if bool(movie["playcount"]): watched += 1
                        # update genres and years
                        if movie["year"] > 0:
                            years.add(str(movie["year"]))
                        genres.update(movie["genre"].split(" / "))
                        # add country
                        if movie.get("country"):
                            countries.update(movie["country"].split(" / "))
                        # add studio
                        if movie.get("studio"):
                            studios.update(movie["studio"].split(" / "))
                        # add plot movie to plotset
                        plotset += "[B]%(title)s (%(year)s)[/B][CR]%(plot)s[CR][CR]" % movie
                        # set stack, add movie path and trailer
                        if movie.get("trailer"):
                            stacktrailer.append(movie["trailer"])
                        stackpath.append(movie["file"])
                        # set RatingAndVotes info
                        rating += movie.get("rating", 0.0)
                        votes += int(movie.get("votes", "0").replace(",", ""))

                        # set movies properties 'plot', 'votes', 'rating', 'fanart', 'title', 'label',
                        # 'dbid', 'file', 'year', 'genre','playcount', 'runtime', 'thumbnail', 'trailer'
                        b_property = "movie.%i." % (count + 1)
                        #for key in movie.keys(): listitem.setProperty( b_property + key, str( movie[ key ] ) )
                        moviepath = os.path.dirname(movie["file"]) + (
                            "/", "\\")[not movie["file"].count("/")]
                        listitem.setProperty(b_property + "Title",
                                             movie["title"])
                        listitem.setProperty(b_property + "sortTitle",
                                             movie.get("sorttitle", ""))
                        listitem.setProperty(b_property + "Filename",
                                             os.path.basename(movie["file"]))
                        listitem.setProperty(b_property + "Path", moviepath)
                        listitem.setProperty(b_property + "Plot",
                                             movie["plot"])
                        listitem.setProperty(b_property + "Year",
                                             str(movie["year"] or ""))
                        listitem.setProperty(b_property + "Trailer",
                                             movie.get("trailer", ""))
                        # set icon property
                        icon = ("", movie['thumbnail'])[os.path.exists(
                            translatePath(movie['thumbnail']))]
                        #print repr( icon )
                        if not icon:  # check for auto-
                            _path, _file = os.path.split(movie['thumbnail'])
                            a_icon = os.path.join(_path, "auto-" + _file)
                            icon = ("", a_icon)[os.path.exists(
                                translatePath(a_icon))]
                        listitem.setProperty(b_property + "Icon", icon)
                        # set fanart property
                        fanart = ("", movie['fanart'])[os.path.exists(
                            translatePath(movie['fanart']))]
                        listitem.setProperty(b_property + "Fanart", fanart)
                        if fanart and not Fanart_Image: Fanart_Image = fanart
                        # set extrafanart: if not exists set empty
                        extrafanart = moviepath + "extrafanart"
                        extrafanart = (
                            "", extrafanart)[os.path.exists(extrafanart)]
                        listitem.setProperty(b_property + "ExtraFanart",
                                             extrafanart)
                        # set extrafanart for movieset if exists set first found
                        #fanartsets.add( os.path.dirname( os.path.dirname( moviepath ) ) )
                        if listitem.getProperty("ExtraFanart"): continue
                        fanartset = os.path.dirname(os.path.dirname(moviepath))
                        fanartset += (
                            "/",
                            "\\")[not fanartset.count("/")] + "extrafanart"
                        if os.path.exists(fanartset):
                            listitem.setProperty("ExtraFanart", fanartset)
                    except:
                        log.error.exc_info(sys.exc_info(), self)

                # set movieset properties
                listitem.setProperty("HasMovieSets", "true")
                listitem.setProperty("WatchedMovies", str(watched))
                listitem.setProperty("UnWatchedMovies",
                                     str(unwatched - watched))
                listitem.setProperty("TotalMovies", str(total_movies))
                listitem.setProperty("Fanart_Image", Fanart_Image)
                listitem.setProperty("Years", separator.join(sorted(years)))
                listitem.setProperty(
                    "StarRating", getStarRating(rating / float(total_movies)))
                listitem.setProperty("Countries", separator.join(countries))

                # set stack path
                stackpath = " , ".join(stackpath)
                if " , " in stackpath: stackpath = "stack://" + stackpath
                listitem.setPath(quote_plus(_encode(stackpath)))
                # set stack trailer
                stacktrailer = " , ".join(stacktrailer)
                if " , " in stacktrailer:
                    stacktrailer = "stack://" + stacktrailer

                # set listitem infoslabels
                listitem.setInfo(
                    "video", {
                        "plot":
                        plotset,
                        "votes":
                        str(votes),
                        "title":
                        movieset['label'],
                        "studio":
                        separator.join(studios),
                        "duration":
                        self.getDurationOfSet(idSet),
                        "rating": (rating / float(total_movies)),
                        "genre":
                        separator.join(sorted([g.strip() for g in genres])),
                        "trailer":
                        stacktrailer,
                    })

                moviesets[movieset['label']] = countset + 1
                listitems.append(listitem)

                if infoSet is not None and idSet == infoSet:
                    moviesets[movieset['label']] = 0
                    break  # get only one user want info
            except:
                log.error.exc_info(sys.exc_info(), self)
        return listitems, moviesets
コード例 #10
0
    "playcount", "fanart", "director", "trailer", "tagline", "plot",
    "plotoutline", "originaltitle", "lastplayed", "writer", "studio",
    "mpaa", "cast", "country", "imdbnumber", "premiered", "productioncode",
    "runtime", "set", "showlink", "streamdetails", "top250", "votes",
    "firstaired", "season", "episode", "showtitle", "thumbnail", "file", "resume" ]

Video_Fields_Movie = [ "title", "genre", "year", "rating", "director", "trailer",
    "tagline", "plot", "plotoutline", "originaltitle", "lastplayed",
    "playcount", "writer", "studio", "mpaa", "cast", "country",
    "imdbnumber", "premiered", "productioncode", "runtime", "set",
    "showlink", "streamdetails", "top250", "votes",
    "fanart", "thumbnail", "file", "resume" ] # "sorttitle" not supported :( !!! and "lastplayed" not returned


infoSet = None
jsonapi = jsonrpcAPI()
#print jsonapi.VideoLibrary.GetRecentlyAddedMovies( properties=["setid"] )
#raise
# GET MOVIESETS
json = jsonapi.VideoLibrary.GetMovieSets( properties=Video_Fields_MovieSet )

movie_sets = json.get( 'sets', [] )
total = json.get( "limits", {} ).get( "total" ) or len( movie_sets )
#print total

# dico for synchronize main container on VideoLibrary with virtual container of MovieSets
moviesets = {}
if infoSet is not None:
    # get only one user want info
    listitems = []
else:
コード例 #11
0
ファイル: database.py プロジェクト: Quihico/passion-xbmc
    def getContainerMovieSets( self, infoSet=None ):
        jrapi = jsonrpc.jsonrpcAPI()
        # GET MOVIESETS
        json = jrapi.Files.GetDirectory( directory="videodb://1/7/", media="video" )
        movie_sets = json.get( 'directories', [] )
        total = json.get( "total" ) or len( movie_sets )

        # dico for synchronize container
        moviesets = {}
        # set dymmy listitem label: container title , label2: total movie sets
        if infoSet is not None: listitems = [] # get only one user want info
        else: listitems = [ xbmcgui.ListItem( "Movie Sets", str( total ) ) ]

        # get user separator
        try: separator = " %s " % ADDON.getSetting( "separator" )
        except: separator = " / "
        # get user prefer order
        try: sorttitle[ "order" ] = ( "ascending", "descending" )[ int( ADDON.getSetting( "order" ) ) ]
        except: pass

        # enum movie sets
        for countset, movieset in enumerate( movie_sets ):
            #print movieset.keys()
            try:
                idSet = movieset[ "file" ][ 14:-1 ]
                if infoSet is not None and idSet != infoSet:
                    continue # get only one user want info
                # get saga icon and fanart
                icon = ( "", movieset[ 'thumbnail' ] )[ os.path.exists( translatePath( movieset[ 'thumbnail' ] ) ) ]
                d, f = os.path.split( movieset[ 'thumbnail' ] )
                c_fanart = "%sFanart/%s" % ( d[ :-1 ], f )
                Fanart_Image = ( "", c_fanart )[ os.path.exists( translatePath( c_fanart ) ) ]
                # fixe me: xbmc not change/reload/refresh image if path is same
                if Fanart_Image: Fanart_Image = self.get_cached_thumb( Fanart_Image )
                if icon: icon = self.get_cached_thumb( icon )
                # set movieset listitem
                listitem = xbmcgui.ListItem( movieset[ 'label' ], idSet, icon, icon )
                #listitem.setPath( "ActivateWindow(10025,%s)" % movieset[ "file" ] )

                # get list of movieset
                json = jrapi.Files.GetDirectory( directory=movieset[ "file" ], fields=fields, sort=sorttitle, media="video" )
                movies = json.get( 'files', [] )
                total_movies = json.get( "total" ) or len( movies )
                # set base variables
                watched, unwatched = 0, total_movies
                rating, votes = 0.0, 0
                plotset = ""
                studios = set()
                genres  = set()
                years   = set()
                fanartsets = set()
                countries  = set()
                stackpath  = []
                stacktrailer = []

                # enum movies
                for count, movie in enumerate( movies ):
                    #print movie.keys()
                    try:
                        # set watched count
                        #print movie.get( "playcount" )
                        if bool( movie[ "playcount" ] ): watched += 1
                        # update genres and years
                        if movie[ "year" ] > 0:
                            years.add( str( movie[ "year" ] ) )
                        genres.update( movie[ "genre" ].split( " / " ) )
                        # add country
                        if movie.get( "country" ):
                            countries.update( movie[ "country" ].split( " / " ) )
                        # add studio
                        if movie.get( "studio" ):
                            studios.update( movie[ "studio" ].split( " / " ) )
                        # add plot movie to plotset
                        plotset += "[B]%(title)s (%(year)s)[/B][CR]%(plot)s[CR][CR]" % movie
                        # set stack, add movie path and trailer
                        if movie.get( "trailer" ): stacktrailer.append( movie[ "trailer" ] )
                        stackpath.append( movie[ "file" ] )
                        # set RatingAndVotes info
                        rating += movie.get( "rating", 0.0 )
                        votes += int( movie.get( "votes", "0" ).replace( ",", "" ) )

                        # set movies properties 'plot', 'votes', 'rating', 'fanart', 'title', 'label',
                        # 'dbid', 'file', 'year', 'genre','playcount', 'runtime', 'thumbnail', 'trailer'
                        b_property = "movie.%i." % ( count + 1 )
                        #for key in movie.keys(): listitem.setProperty( b_property + key, str( movie[ key ] ) )
                        moviepath = os.path.dirname( movie[ "file" ] ) + ( "/", "\\" )[ not movie[ "file" ].count( "/" ) ]
                        listitem.setProperty( b_property + "Title",     movie[ "title" ] )
                        listitem.setProperty( b_property + "sortTitle", movie.get( "sorttitle", "" ) )
                        listitem.setProperty( b_property + "Filename",  os.path.basename( movie[ "file" ] ) )
                        listitem.setProperty( b_property + "Path",      moviepath )
                        listitem.setProperty( b_property + "Plot",      movie[ "plot" ] )
                        listitem.setProperty( b_property + "Year",      str( movie[ "year" ] or "" ) )
                        listitem.setProperty( b_property + "Trailer",   movie.get( "trailer", "" ) )
                        # set icon property
                        icon = ( "", movie[ 'thumbnail' ] )[ os.path.exists( translatePath( movie[ 'thumbnail' ] ) ) ]
                        #print repr( icon )
                        if not icon: # check for auto-
                            _path, _file = os.path.split( movie[ 'thumbnail' ] )
                            a_icon = os.path.join( _path, "auto-" + _file )
                            icon = ( "", a_icon )[ os.path.exists( translatePath( a_icon ) ) ]
                        listitem.setProperty( b_property + "Icon", icon )
                        # set fanart property
                        fanart = ( "", movie[ 'fanart' ] )[ os.path.exists( translatePath( movie[ 'fanart' ] ) ) ]
                        listitem.setProperty( b_property + "Fanart", fanart )
                        if fanart and not Fanart_Image: Fanart_Image = fanart
                        # set extrafanart: if not exists set empty
                        extrafanart = moviepath + "extrafanart"
                        extrafanart = ( "", extrafanart )[ os.path.exists( extrafanart ) ]
                        listitem.setProperty( b_property + "ExtraFanart", extrafanart )
                        # set extrafanart for movieset if exists set first found
                        #fanartsets.add( os.path.dirname( os.path.dirname( moviepath ) ) )
                        if listitem.getProperty( "ExtraFanart" ): continue
                        fanartset = os.path.dirname( os.path.dirname( moviepath ) )
                        fanartset += ( "/", "\\" )[ not fanartset.count( "/" ) ] + "extrafanart"
                        if os.path.exists( fanartset ): listitem.setProperty( "ExtraFanart", fanartset )
                    except:
                        log.error.exc_info( sys.exc_info(), self )

                # set movieset properties
                listitem.setProperty( "HasMovieSets",    "true" )
                listitem.setProperty( "WatchedMovies",   str( watched ) )
                listitem.setProperty( "UnWatchedMovies", str( unwatched - watched ) )
                listitem.setProperty( "TotalMovies",     str( total_movies ) )
                listitem.setProperty( "Fanart_Image",    Fanart_Image )
                listitem.setProperty( "Years",           separator.join( sorted( years ) ) )
                listitem.setProperty( "StarRating",      getStarRating( rating / float( total_movies ) ) )
                listitem.setProperty( "Countries",       separator.join( countries ) )

                # set stack path
                stackpath = " , ".join( stackpath )
                if " , " in stackpath: stackpath = "stack://" + stackpath
                listitem.setPath( quote_plus( _encode( stackpath ) ) )
                # set stack trailer
                stacktrailer = " , ".join( stacktrailer )
                if " , " in stacktrailer: stacktrailer = "stack://" + stacktrailer

                # set listitem infoslabels
                listitem.setInfo( "video", {
                    "plot":     plotset,
                    "votes":    str( votes ),
                    "title":    movieset[ 'label' ],
                    "studio":   separator.join( studios  ),
                    "duration": self.getDurationOfSet( idSet ),
                    "rating":   ( rating / float( total_movies ) ),
                    "genre":    separator.join( sorted( [ g.strip() for g in genres ] ) ),
                    "trailer":  stacktrailer,
                    } )

                moviesets[ movieset[ 'label' ] ] = countset + 1
                listitems.append( listitem )

                if infoSet is not None and idSet == infoSet:
                    moviesets[ movieset[ 'label' ] ] = 0
                    break # get only one user want info
            except:
                log.error.exc_info( sys.exc_info(), self )
        return listitems, moviesets
コード例 #12
0
ファイル: test.py プロジェクト: mrbusta/passion-xbmc
    "plotoutline", "originaltitle", "lastplayed", "writer", "studio", "mpaa",
    "cast", "country", "imdbnumber", "premiered", "productioncode", "runtime",
    "set", "showlink", "streamdetails", "top250", "votes", "firstaired",
    "season", "episode", "showtitle", "thumbnail", "file", "resume"
]

Video_Fields_Movie = [
    "title", "genre", "year", "rating", "director", "trailer", "tagline",
    "plot", "plotoutline", "originaltitle", "lastplayed", "playcount",
    "writer", "studio", "mpaa", "cast", "country", "imdbnumber", "premiered",
    "productioncode", "runtime", "set", "showlink", "streamdetails", "top250",
    "votes", "fanart", "thumbnail", "file", "resume"
]  # "sorttitle" not supported :( !!! and "lastplayed" not returned

infoSet = None
jsonapi = jsonrpcAPI()
#print jsonapi.VideoLibrary.GetRecentlyAddedMovies( properties=["setid"] )
#raise
# GET MOVIESETS
json = jsonapi.VideoLibrary.GetMovieSets(properties=Video_Fields_MovieSet)

movie_sets = json.get('sets', [])
total = json.get("limits", {}).get("total") or len(movie_sets)
#print total

# dico for synchronize main container on VideoLibrary with virtual container of MovieSets
moviesets = {}
if infoSet is not None:
    # get only one user want info
    listitems = []
else:
コード例 #13
0
def getContainerMovieSets(infoSet=None):
    jsonapi = jsonrpc.jsonrpcAPI()
    # GET MOVIESETS
    json = jsonapi.VideoLibrary.GetMovieSets(properties=VIDEO_FIELDS_MOVIESET)

    movie_sets = json.get('sets', [])
    total = json.get("limits", {}).get("total") or len(movie_sets)
    #print total

    # dico for synchronize main container on VideoLibrary with virtual container of MovieSets
    moviesets = {}
    if infoSet is not None:
        # get only one user want info
        listitems = []
    else:
        # set dymmy listitem, label: container title , label2: total movie sets
        listitems = [xbmcgui.ListItem("Container MovieSets", str(total))]

    # reload addon settings
    try:
        ADDON = Addon("script.moviesets")
    except:
        pass
    # get user separator
    try:
        separator = " %s " % ADDON.getSetting("separator")
    except:
        separator = " / "
    # get user prefer order
    try:
        SORTTITLE["order"] = ("ascending",
                              "descending")[int(ADDON.getSetting("order"))]
    except:
        pass

    # enum movie sets
    for countset, movieset in enumerate(movie_sets):
        #print movieset.keys()#[u'title', u'fanart', u'label', u'playcount', u'thumbnail', u'setid']
        try:
            idSet = movieset["setid"]
            #print ( idSet, infoSet, str( idSet ) != infoSet )
            if infoSet is not None and str(idSet) != infoSet:
                continue  # get only one user want info
            # get saga icon
            icon = movieset["thumbnail"]
            icon = ("", icon)[path_exists(translatePath(icon))]
            # get saga fanart
            #d, f = os.path.split( movieset[ 'thumbnail' ] )
            #c_fanart = "%sFanart/%s" % ( d[ :-1 ], f )
            c_fanart = movieset["fanart"]
            Fanart_Image = ("", c_fanart)[path_exists(translatePath(c_fanart))]
            # fixe me: xbmc not change/reload/refresh image if path is same
            if Fanart_Image: Fanart_Image = get_cached_thumb(Fanart_Image)
            if icon: icon = get_cached_thumb(icon)

            # set movieset listitem
            listitem = xbmcgui.ListItem(movieset['label'], str(idSet), icon,
                                        icon)
            #listitem.setPath( "ActivateWindow(10025,videodb://1/7/%i/)" % idSet )

            # get movies list of movieset
            # not good, return only Video.Fields.MovieSet. [use Files.GetDirectory for more fields]
            #json = jsonapi.VideoLibrary.GetMovieSetDetails( setid=idSet, properties=VIDEO_FIELDS_MOVIESET )
            json = jsonapi.Files.GetDirectory(directory="videodb://1/7/%i/" %
                                              idSet,
                                              properties=VIDEO_FIELDS_MOVIE,
                                              sort=SORTTITLE,
                                              media="video")
            movies = json.get('files', [])
            total_movies = json.get("limits", {}).get("total") or len(movies)
            # set base variables
            watched, unwatched = 0, total_movies
            rating, votes = 0.0, 0
            plotset = ""
            mpaa = set()
            studios = set()
            genres = set()
            years = set()
            #fanartsets = set()
            countries = set()
            stackpath = []
            stacktrailer = []
            duration = 0.1
            iWidth = 0
            iHeight = 0
            aspect = 0.0

            # enum movies
            for count, movie in enumerate(movies):
                if not bool(movie): continue
                #print movie.keys()#[u'rating', u'set', u'filetype', u'file', u'year', u'id', u'streamDetails', u'plot', u'votes', u'title', u'fanart', u'mpaa', u'writer', u'label', u'type', u'thumbnail', u'plotoutline', u'resume', u'director', u'imdbnumber', u'studio', u'showlink', u'genre', u'productioncode', u'country', u'premiered', u'originaltitle', u'cast', u'tagline', u'playcount', u'runtime', u'top250', u'trailer']
                # for more infos
                #print jsonapi.VideoLibrary.GetMovieDetails( movieid=int(movie["id"]), properties=VIDEO_FIELDS_MOVIE )
                #print movie[ "votes" ]
                #continue
                try:
                    #optional
                    try:
                        sdv = movie["streamdetails"].get("video", [{}])
                        duration += sum(d.get("duration", 0) for d in sdv)
                        iWidth += sum(w.get("width", 0) for w in sdv)
                        iHeight += sum(h.get("height", 0) for h in sdv)
                        aspect += sum(a.get("aspect", 0) for a in sdv)
                    except:
                        pass
                    # update mpaa
                    if movie.get("mpaa"):
                        mpaa.add(movie["mpaa"])
                    # set watched count
                    #print movie.get( "playcount" )
                    if bool(movie["playcount"]): watched += 1
                    # update genres and years
                    if movie["year"] > 0:
                        years.add(str(movie["year"]))
                    try:
                        genres.update(movie["genre"].split(" / "))
                    except:
                        genres.update(movie["genre"])
                    genres.discard("")
                    # add country
                    if movie.get("country"):
                        try:
                            countries.update(movie["country"].split(" / "))
                        except:
                            countries.update(movie["country"])
                    countries.discard("")
                    # add studio
                    if movie.get("studio"):
                        try:
                            studios.update(movie["studio"].split(" / "))
                        except:
                            studios.update(movie["studio"])
                    studios.discard("")
                    # add plot movie to plotset
                    plotset += "[B]%(title)s (%(year)s)[/B][CR]%(plot)s[CR][CR]" % movie
                    # set stack, add movie path and trailer
                    if movie.get("trailer"):
                        stacktrailer.append(movie["trailer"])
                    stackpath.append(movie["file"])
                    # use first path if stacked. for prevent this [WARNING: XFILE::CFileFactory::CreateLoader - Unsupported protocol(stack) in path_exists( moviepath + "extrafanart" )]
                    if "stack://" in movie["file"]:
                        movie["file"] = movie["file"][8:].split(" , ")[0]
                    # set RatingAndVotes info
                    rating += movie.get("rating", 0.0)
                    try:
                        votes += int(movie.get("votes", "0").replace(",", ""))
                    except:
                        pass

                    # set movies properties 'plot', 'votes', 'rating', 'fanart', 'title', 'label',
                    # 'file', 'year', 'genre','playcount', 'runtime', 'thumbnail', 'trailer'
                    b_property = "movie.%i." % (count + 1)
                    moviepath = os.path.dirname(movie["file"]) + (
                        "/", "\\")[not movie["file"].count("/")]
                    listitem.setProperty(b_property + "Title", movie["title"])
                    listitem.setProperty(b_property + "sortTitle",
                                         movie.get("sorttitle", ""))
                    listitem.setProperty(b_property + "Filename",
                                         os.path.basename(movie["file"]))
                    listitem.setProperty(b_property + "Path", moviepath)
                    listitem.setProperty(b_property + "Plot", movie["plot"])
                    listitem.setProperty(b_property + "Year",
                                         str(movie["year"] or ""))
                    listitem.setProperty(b_property + "Trailer",
                                         movie.get("trailer", ""))
                    # set icon property
                    icon = movie['thumbnail']
                    icon = ("", icon)[path_exists(translatePath(icon))]
                    #print repr( icon )
                    if not icon:  # check for auto-
                        _path, _file = os.path.split(icon)
                        a_icon = os.path.join(_path, "auto-" + _file)
                        icon = ("", a_icon)[path_exists(translatePath(a_icon))]
                    listitem.setProperty(b_property + "Icon", icon)
                    # set fanart property
                    fanart = movie['fanart']
                    fanart = ("", fanart)[path_exists(translatePath(fanart))]
                    listitem.setProperty(b_property + "Fanart", fanart)
                    if fanart and not Fanart_Image: Fanart_Image = fanart
                    # set extrafanart: if not exists set empty
                    extrafanart = moviepath + "extrafanart"
                    extrafanart = ("", extrafanart)[path_exists(extrafanart)]
                    listitem.setProperty(b_property + "ExtraFanart",
                                         extrafanart)
                    # set extrafanart for movieset if exists set first found
                    #fanartsets.add( os.path.dirname( os.path.dirname( moviepath ) ) )
                    if listitem.getProperty("ExtraFanart"): continue
                    fanartset = os.path.dirname(os.path.dirname(moviepath))
                    fanartset += (
                        "/", "\\")[not fanartset.count("/")] + "extrafanart"
                    if path_exists(fanartset):
                        listitem.setProperty("ExtraFanart", fanartset)
                    elif extrafanart:
                        listitem.setProperty("ExtraFanart", extrafanart)

                    #print _encode(movie[ "file" ]), _encode(moviepath), _encode(fanartset)
                    #print "-"*100
                except:
                    LOGGER.error.print_exc()

            # set movieset properties
            listitem.setProperty("IsSet", "true")
            listitem.setProperty("idSet", str(idSet))
            listitem.setProperty("WatchedMovies", str(watched))
            listitem.setProperty("UnWatchedMovies", str(unwatched - watched))
            listitem.setProperty("TotalMovies", str(total_movies))
            listitem.setProperty("Fanart_Image", Fanart_Image)
            listitem.setProperty(
                "Years",
                separator.join(
                    sorted(years,
                           reverse=(SORTTITLE["order"] == "descending"))))
            try:
                listitem.setProperty(
                    "StarRating", getStarRating(rating / float(total_movies)))
            except:
                listitem.setProperty("StarRating", "rating0.png")
            listitem.setProperty("Countries", separator.join(countries))
            listitem.setProperty(
                "VideoResolution",
                VideoDimsToResolutionDescription(int(iWidth / total_movies),
                                                 int(iHeight / total_movies)))
            listitem.setProperty(
                "VideoAspect",
                VideoAspectToAspectDescription(float(aspect / total_movies)))

            # set stack path
            stackpath = " ; ".join(stackpath)
            if " ; " in stackpath: stackpath = "stackset://" + stackpath
            listitem.setPath(quote_plus(_encode(stackpath)))
            # set stack trailer
            stacktrailer = " , ".join(stacktrailer)
            if " , " in stacktrailer: stacktrailer = "stack://" + stacktrailer

            # set listitem infoslabels
            listitem.setInfo(
                "video",
                {
                    "plot": plotset,
                    "votes": str(votes),
                    "title": movieset['label'],
                    "studio": separator.join(studios),
                    #"duration": str( round( duration / 60.0, 2 ) ),
                    "duration": str(int(duration / 60.0)),
                    "rating": (rating / float(total_movies)),
                    "genre": separator.join(sorted([g.strip()
                                                    for g in genres])),
                    "mpaa": separator.join([m.strip() for m in mpaa]),
                    "trailer": stacktrailer,
                })

            moviesets[_encode(movieset['label'])] = countset + 1
            listitems.append(listitem)

            if infoSet is not None and idSet == infoSet:
                moviesets[movieset['label']] = 0
                break  # get only one user want info
        except:
            LOGGER.error.print_exc()

    return listitems, moviesets