def addSelectedFeature(self,
                           movieid=None,
                           episodeid=None,
                           selection=False):
        if selection or movieid or episodeid:
            return self.addFromID(movieid, episodeid, selection)

        if xbmc.getCondVisibility('ListItem.IsCollection'):
            kodiutil.DEBUG_LOG('Selection is a collection')
            return self.addCollectionMovies()

        title = kodiutil.infoLabel('ListItem.Title')
        if not title:
            return False
        feature = cinemavision.sequenceprocessor.Feature(
            kodiutil.infoLabel('ListItem.FileNameAndPath'))
        feature.title = title

        ratingString = cvutil.ratingParser().getActualRatingFromMPAA(
            kodiutil.infoLabel('ListItem.Mpaa'), debug=True)
        if ratingString:
            feature.rating = ratingString

        feature.ID = kodiutil.intOrZero(xbmc.getInfoLabel('ListItem.DBID'))
        feature.dbType = xbmc.getInfoLabel('ListItem.DBTYPE')
        feature.genres = kodiutil.infoLabel('ListItem.Genre').split(' / ')
        feature.thumb = kodiutil.infoLabel('ListItem.Thumb')
        feature.year = kodiutil.infoLabel('ListItem.Year')

        try:
            feature.runtime = kodiutil.intOrZero(
                xbmc.getInfoLabel('ListItem.Duration')) * 60
        except TypeError:
            pass

        feature.is3D = xbmc.getCondVisibility('ListItem.IsStereoscopic')

        if not feature.is3D:
            tags3DRegEx = kodiutil.getSetting('3D.tag.regex',
                                              cvutil.DEFAULT_3D_RE)

            feature.is3D = bool(re.search(tags3DRegEx, feature.path))

        codec = xbmc.getInfoLabel('ListItem.AudioCodec')
        channels = kodiutil.intOrZero(
            xbmc.getInfoLabel('ListItem.AudioChannels'))

        if codec:
            feature.audioFormat = AUDIO_FORMATS.get(codec)
            feature.codec = codec
            feature.channels = channels
            DEBUG_LOG('CODEC ({0}): {1} ({2} channels)'.format(
                kodiutil.strRepr(feature.title), codec, channels or '?'))
        else:
            DEBUG_LOG('CODEC ({0}): NOT DETECTED'.format(
                kodiutil.strRepr(feature.title)))

        self.features.append(feature)
        return True
    def addFromID(self, movieid=None, episodeid=None, selection=False):
        DEBUG_LOG(
            'Adding from id: movieid={0} episodeid={1} selection={2}'.format(
                movieid, episodeid, selection))
        if selection:
            stype = xbmc.getInfoLabel('ListItem.DBTYPE')
            ID = xbmc.getInfoLabel('ListItem.DBID')
            if stype == 'movie':
                movieid = ID
            elif stype == 'tvshow':
                episodeid = ID
            else:
                return False

        self.features = []

        if movieid:
            for movieid in str(movieid).split(
                    '|'):  # ID could be int or \ seperated int string
                movieid = kodiutil.intOrZero(movieid)
                if not movieid:
                    continue

                r = rpc.VideoLibrary.GetMovieDetails(movieid=movieid,
                                                     properties=[
                                                         'file', 'genre',
                                                         'mpaa',
                                                         'streamdetails',
                                                         'title', 'thumbnail',
                                                         'runtime', 'year'
                                                     ])['moviedetails']
                r['type'] = 'movie'

                feature = self.featureFromJSON(r)
                self.features.append(feature)
        elif episodeid:
            for episodeid in str(episodeid).split(
                    '|'):  # ID could be int or \ seperated int string
                episodeid = kodiutil.intOrZero(episodeid)
                if not episodeid:
                    continue

                r = rpc.VideoLibrary.GetEpisodeDetails(episodeid=episodeid,
                                                       properties=[
                                                           'file',
                                                           'streamdetails',
                                                           'title',
                                                           'thumbnail',
                                                           'runtime'
                                                       ])['episodedetails']
                r['type'] = 'tvshow'
                feature = self.featureFromJSON(r)
                self.features.append(feature)

        if not self.features:
            return False

        return True
    def addSelectedFeature(self, movieid=None, episodeid=None, selection=False):
        if selection or movieid or episodeid:
            return self.addFromID(movieid, episodeid, selection)

        if xbmc.getCondVisibility('ListItem.IsCollection'):
            kodiutil.DEBUG_LOG('Selection is a collection')
            return self.addCollectionMovies()

        title = kodiutil.infoLabel('ListItem.Title')
        if not title:
            return False
        feature = cinemavision.sequenceprocessor.Feature(kodiutil.infoLabel('ListItem.FileNameAndPath'))
        feature.title = title

        ratingString = cvutil.ratingParser().getActualRatingFromMPAA(kodiutil.infoLabel('ListItem.Mpaa'), debug=True)
        if ratingString:
            feature.rating = ratingString

        feature.ID = kodiutil.intOrZero(xbmc.getInfoLabel('ListItem.DBID'))
        feature.dbType = xbmc.getInfoLabel('ListItem.DBTYPE')
        feature.genres = kodiutil.infoLabel('ListItem.Genre').split(' / ')
        feature.thumb = kodiutil.infoLabel('ListItem.Thumb')
        feature.year = kodiutil.infoLabel('ListItem.Year')

        try:
            feature.runtime = kodiutil.intOrZero(xbmc.getInfoLabel('ListItem.Duration')) * 60
        except TypeError:
            pass

        feature.is3D = xbmc.getCondVisibility('ListItem.IsStereoscopic')

        if not feature.is3D:
            tags3DRegEx = kodiutil.getSetting('3D.tag.regex', cvutil.DEFAULT_3D_RE)

            feature.is3D = bool(re.search(tags3DRegEx, feature.path))

        codec = xbmc.getInfoLabel('ListItem.AudioCodec')
        channels = kodiutil.intOrZero(xbmc.getInfoLabel('ListItem.AudioChannels'))

        if codec:
            feature.audioFormat = AUDIO_FORMATS.get(codec)
            feature.codec = codec
            feature.channels = channels
            DEBUG_LOG('CODEC ({0}): {1} ({2} channels)'.format(kodiutil.strRepr(feature.title), codec, channels or '?'))
        else:
            DEBUG_LOG('CODEC ({0}): NOT DETECTED'.format(kodiutil.strRepr(feature.title)))

        self.features.append(feature)
        return True
    def addFromID(self, movieid=None, episodeid=None, selection=False):
        DEBUG_LOG('Adding from id: movieid={0} episodeid={1} selection={2}'.format(movieid, episodeid, selection))
        if selection:
            stype = xbmc.getInfoLabel('ListItem.DBTYPE')
            ID = xbmc.getInfoLabel('ListItem.DBID')
            if stype == 'movie':
                movieid = ID
            elif stype == 'tvshow':
                episodeid = ID
            else:
                return False

        self.features = []

        if movieid:
            for movieid in str(movieid).split('|'):  # ID could be int or \ seperated int string
                movieid = kodiutil.intOrZero(movieid)
                if not movieid:
                    continue

                r = rpc.VideoLibrary.GetMovieDetails(
                    movieid=movieid,
                    properties=['file', 'genre', 'mpaa', 'streamdetails', 'title', 'thumbnail', 'runtime', 'year']
                )['moviedetails']
                r['type'] = 'movie'

                feature = self.featureFromJSON(r)
                self.features.append(feature)
        elif episodeid:
            for episodeid in str(episodeid).split('|'):  # ID could be int or \ seperated int string
                episodeid = kodiutil.intOrZero(episodeid)
                if not episodeid:
                    continue

                r = rpc.VideoLibrary.GetEpisodeDetails(
                    episodeid=episodeid,
                    properties=['file', 'streamdetails', 'title', 'thumbnail', 'runtime']
                )['episodedetails']
                r['type'] = 'tvshow'
                feature = self.featureFromJSON(r)
                self.features.append(feature)

        if not self.features:
            return False

        return True
示例#5
0
    def featureFromJSON(self, r):
        tags3DRegEx = kodiutil.getSetting('3D.tag.regex', cvutil.DEFAULT_3D_RE)

        feature = cinemavision.sequenceprocessor.Feature(r['file'])
        feature.title = r.get('title') or r.get('label', '')
        ratingString = cvutil.ratingParser().getActualRatingFromMPAA(
            r.get('mpaa', ''), debug=True)
        if ratingString:
            feature.rating = ratingString
        feature.ID = kodiutil.intOrZero(
            r.get('movieid', r.get('episodeid', r.get('id', 0))))
        feature.dbType = r.get('type', '')
        feature.genres = r.get('genre', [])
        feature.tags = r.get('tag', [])
        feature.studios = r.get('studio', [])
        feature.directors = r.get('director', [])
        feature.cast = r.get('cast', [])
        feature.thumb = r.get('thumbnail', '')
        feature.runtime = r.get('runtime', 0)
        feature.year = r.get('year', 0)

        try:
            stereomode = r['streamdetails']['video'][0]['stereomode']
        except:
            stereomode = ''

        if stereomode not in ('mono', ''):
            feature.is3D = True
        else:
            feature.is3D = bool(re.search(tags3DRegEx, r['file']))

        try:
            codec, channels = self.getCodecAndChannelsFromStreamDetails(
                r['streamdetails'])
            DEBUG_LOG('CODEC ({0}): {1} ({2} channels)'.format(
                kodiutil.strRepr(feature.title), codec, channels or '?'))
            DEBUG_LOG('STREAMDETAILS: \n{0}'.format(
                self.formatStreamDetails(r.get('streamdetails'))))

            feature.audioFormat = AUDIO_FORMATS.get(codec)
            feature.codec = codec
            feature.channels = channels
        except:
            kodiutil.ERROR()
            DEBUG_LOG('CODEC ({0}): NOT DETECTED'.format(
                kodiutil.strRepr(feature.title)))
            DEBUG_LOG('STREAMDETAILS: {0}'.format(repr(
                r.get('streamdetails'))))

        return feature
    def featureFromId(self, movieid=None, episodeid=None):
        if movieid:
            for movieid in str(movieid).split(
                    '|'):  # ID could be int or \ seperated int string
                movieid = kodiutil.intOrZero(movieid)
                if not movieid:
                    continue

                r = rpc.VideoLibrary.GetMovieDetails(
                    movieid=movieid,
                    properties=[
                        'file', 'genre', 'tag', 'mpaa', 'streamdetails',
                        'title', 'thumbnail', 'runtime', 'year', 'studio',
                        'director', 'cast'
                    ])['moviedetails']
                r['type'] = 'movie'

                return self.featureFromJSON(r)
        elif episodeid:
            for episodeid in str(episodeid).split(
                    '|'):  # ID could be int or \ seperated int string
                episodeid = kodiutil.intOrZero(episodeid)
                if not episodeid:
                    continue

                r = rpc.VideoLibrary.GetEpisodeDetails(episodeid=episodeid,
                                                       properties=[
                                                           'file',
                                                           'streamdetails',
                                                           'title',
                                                           'thumbnail',
                                                           'runtime'
                                                       ])['episodedetails']
                r['type'] = 'tvshow'
                return self.featureFromJSON(r)

        return None
    def addCollectionMovies(self):
        DBID = kodiutil.intOrZero(xbmc.getInfoLabel('ListItem.DBID'))

        try:
            details = rpc.VideoLibrary.GetMovieSetDetails(setid=DBID)
            for m in details['setdetails']['movies']:
                try:
                    r = rpc.VideoLibrary.GetMovieDetails(
                        movieid=m['movieid'], properties=['file', 'genre', 'mpaa', 'streamdetails', 'title', 'thumbnail', 'runtime', 'year']
                    )['moviedetails']
                    feature = self.featureFromJSON(r)
                    self.features.append(feature)
                except:
                    kodiutil.ERROR()
        except:
            kodiutil.ERROR()
            return False

        return True
    def addCollectionMovies(self):
        DBID = kodiutil.intOrZero(xbmc.getInfoLabel('ListItem.DBID'))

        try:
            details = rpc.VideoLibrary.GetMovieSetDetails(setid=DBID)
            for m in details['setdetails']['movies']:
                try:
                    r = rpc.VideoLibrary.GetMovieDetails(
                        movieid=m['movieid'],
                        properties=[
                            'file', 'genre', 'mpaa', 'streamdetails', 'title',
                            'thumbnail', 'runtime', 'year'
                        ])['moviedetails']
                    feature = self.featureFromJSON(r)
                    self.features.append(feature)
                except:
                    kodiutil.ERROR()
        except:
            kodiutil.ERROR()
            return False

        return True
    def featureFromJSON(self, r):
        tags3DRegEx = kodiutil.getSetting('3D.tag.regex', cvutil.DEFAULT_3D_RE)

        feature = cinemavision.sequenceprocessor.Feature(r['file'])
        feature.title = r.get('title') or r.get('label', '')
        ratingString = cvutil.ratingParser().getActualRatingFromMPAA(r.get('mpaa', ''), debug=True)
        if ratingString:
            feature.rating = ratingString
        feature.ID = kodiutil.intOrZero(r.get('movieid', r.get('episodeid', r.get('id', 0))))
        feature.dbType = r.get('type', '')
        feature.genres = r.get('genre', [])
        feature.thumb = r.get('thumbnail', '')
        feature.runtime = r.get('runtime', 0)
        feature.year = r.get('year', 0)

        try:
            stereomode = r['streamdetails']['video'][0]['stereomode']
        except:
            stereomode = ''

        if stereomode not in ('mono', ''):
            feature.is3D = True
        else:
            feature.is3D = bool(re.search(tags3DRegEx, r['file']))

        try:
            codec, channels = self.getCodecAndChannelsFromStreamDetails(r['streamdetails'])

            DEBUG_LOG('CODEC ({0}): {1} ({2} channels)'.format(kodiutil.strRepr(feature.title), codec, channels or '?'))
            DEBUG_LOG('STREAMDETAILS: {0}'.format(repr(r.get('streamdetails'))))

            feature.audioFormat = AUDIO_FORMATS.get(codec)
            feature.codec = codec
            feature.channels = channels
        except:
            DEBUG_LOG('CODEC ({0}): NOT DETECTED'.format(kodiutil.strRepr(feature.title)))
            DEBUG_LOG('STREAMDETAILS: {0}'.format(repr(r.get('streamdetails'))))

        return feature
示例#10
0
 def selectionAvailable(self):
     return bool(kodiutil.intOrZero(xbmc.getInfoLabel('ListItem.DBID')))
示例#11
0
    def addFromID(self,
                  movieid=None,
                  episodeid=None,
                  selection=False,
                  dbtype=None,
                  dbid=None):
        if selection:
            DEBUG_LOG('Adding from selection')
            stype, ID = self.getDBTypeAndID()
            if stype == 'movie':
                movieid = ID
            elif stype in ('tvshow', 'episode'):
                episodeid = ID
            else:
                return False
        elif dbtype:
            DEBUG_LOG('Adding from DB: dbtype={0} dbid={1}'.format(
                dbtype, dbid))
            if dbtype == 'movie':
                movieid = dbid
            elif dbtype in ('tvshow', 'episode'):
                episodeid = dbid
        else:
            DEBUG_LOG('Adding from id: movieid={0} episodeid={1}'.format(
                movieid, episodeid))

        self.features = []

        if movieid:
            for movieid in str(movieid).split(
                    '|'):  # ID could be int or \ seperated int string
                movieid = kodiutil.intOrZero(movieid)
                if not movieid:
                    continue

                r = rpc.VideoLibrary.GetMovieDetails(
                    movieid=movieid,
                    properties=[
                        'file', 'genre', 'tag', 'mpaa', 'streamdetails',
                        'title', 'thumbnail', 'runtime', 'year', 'studio',
                        'director', 'cast'
                    ])['moviedetails']
                r['type'] = 'movie'

                feature = self.featureFromJSON(r)
                self.features.append(feature)
        elif episodeid:
            for episodeid in str(episodeid).split(
                    '|'):  # ID could be int or \ seperated int string
                episodeid = kodiutil.intOrZero(episodeid)
                if not episodeid:
                    continue

                r = rpc.VideoLibrary.GetEpisodeDetails(episodeid=episodeid,
                                                       properties=[
                                                           'file',
                                                           'streamdetails',
                                                           'title',
                                                           'thumbnail',
                                                           'runtime'
                                                       ])['episodedetails']
                r['type'] = 'tvshow'
                feature = self.featureFromJSON(r)
                self.features.append(feature)

        if not self.features:
            return False

        return True
示例#12
0
 def selectionAvailable(self):
     return bool(kodiutil.intOrZero(xbmc.getInfoLabel('ListItem.DBID')))