Example #1
0
    def loadDefault(self):
        self.setName(kodiutil.getSetting('save.name', ''))

        if not self.name:
            savePath = self.defaultSavePath()
        else:
            savePath = self.savePath()
            if not xbmcvfs.exists(savePath):
                self.setName('')
                self.saveDefault(force=True)
                new = xbmcgui.Dialog().yesno(
                    T(32558, 'Missing'), T(32559, 'Previous save not found.'),
                    '', T(32560, 'Load the default or start a new sequence?'),
                    T(32322, 'Default'), T(32541, 'New'))
                if new:
                    self.setName('')
                    self.setFocusId(self.ADD_ITEM_LIST_ID)
                    return
                else:
                    savePath = self.defaultSavePath()

        kodiutil.DEBUG_LOG('Loading previous save: {0}'.format(savePath))

        self._load(savePath)

        kodiutil.DEBUG_LOG('Previous save loaded')
Example #2
0
def begin(movieid=None, episodeid=None, dbtype=None, selection=False, args=None):
    e = experience.ExperiencePlayer().create()
    seqPath = None

    if not e.hasFeatures() or selection or movieid or episodeid or dbtype:
        if dbtype:
            if not e.addDBFeature(dbtype, args[0][5:]):
                return showNoFeaturesDialog()
        elif not e.addSelectedFeature(selection=selection, movieid=movieid, episodeid=episodeid):
            return showNoFeaturesDialog()
    elif len(e.features) < 2 and kodiutil.getSetting('ignore.playlist.single', True) and e.selectionAvailable():
        if not e.addSelectedFeature(selection=True):
            return showNoFeaturesDialog()  # We shouldn't get here

    if not kodiutil.getSetting('hide.queue.dialog', False) or (kodiutil.getSetting('hide.queue.dialog.single', False) and len(e.features) > 1):
        if not args or 'nodialog' not in args:
            e.features, seqPath = featureComfirmationDialog(e.features)

    if not e.features:
        return

    if seqPath:
        kodiutil.DEBUG_LOG('Loading selected sequence: {0}'.format(repr(seqPath)))
    else:
        seqPath = cvutil.getSequencePath(for_3D=e.has3D)
        kodiutil.DEBUG_LOG('Loading sequence for {0}: {1}'.format(e.has3D and '3D' or '2D', repr(seqPath)))

    if xbmc.getCondVisibility('Window.IsVisible(MovieInformation)'):
        xbmc.executebuiltin('Dialog.Close(MovieInformation)')

    e.start(seqPath)
Example #3
0
def begin(movieid=None,
          episodeid=None,
          dbtype=None,
          selection=False,
          args=None):
    e = experience.ExperiencePlayer().create()
    seqPath = None

    feature = None
    if 'intercept' in args and len(args) >= 3:
        if args[1] == 'movie':
            feature = e.featureFromId(movieid=args[2])
        elif args[1] == 'episode':
            feature = e.featureFromId(episodeid=args[2])

    if feature is not None:
        if len(e.features) > 0:
            e.features[0] = feature
        else:
            e.features.append(feature)

    if not e.hasFeatures() or selection or movieid or episodeid or dbtype:
        if dbtype:
            if not e.addDBFeature(dbtype, args[0][5:]):
                return showNoFeaturesDialog()
        elif not e.addSelectedFeature(
                selection=selection, movieid=movieid, episodeid=episodeid):
            return showNoFeaturesDialog()
    elif len(e.features) < 2 and kodiutil.getSetting(
            'ignore.playlist.single', True) and e.selectionAvailable():
        if not e.addSelectedFeature(selection=True):
            return showNoFeaturesDialog()  # We shouldn't get here

    if not kodiutil.getSetting('hide.queue.dialog', False) or (
            kodiutil.getSetting('hide.queue.dialog.single', False)
            and len(e.features) > 1):
        if not args or 'nodialog' not in args:
            e.features, seqPath = featureComfirmationDialog(e.features, args)

    if not e.features:
        return

    if seqPath:
        kodiutil.DEBUG_LOG('Loading selected sequence: {0}'.format(
            repr(seqPath)))
    else:
        if feature is None:
            feature = e.features[0]
        seqData = cvutil.getMatchedSequence(feature)
        seqPath = seqData['path']
        kodiutil.DEBUG_LOG('Loading sequence for {0}: {1}'.format(
            feature.is3D and '3D' or '2D', repr(seqPath)))

    if xbmc.getCondVisibility('Window.IsVisible(MovieInformation)'):
        xbmc.executebuiltin('Dialog.Close(MovieInformation)')

    e.start(seqPath)
Example #4
0
 def moveItem(self):
     item = self.sequenceControl.getSelectedItem()
     if not item:
         return
     if self.move:
         kodiutil.DEBUG_LOG('Move item: Finished')
         self.move.setProperty('moving', '')
         self.move = None
         self.modified = True
     else:
         kodiutil.DEBUG_LOG('Move item: Started')
         self.move = item
         self.move.setProperty('moving', '1')
Example #5
0
    def getActualRatingFromMPAA(self, rating, debug=False):
        if debug:
            kodiutil.DEBUG_LOG('Rating from Kodi: {0}'.format(
                kodiutil.strRepr(rating)))

        if not rating:
            return 'UNKNOWN:NR'

        # Try a definite match
        for system, ratingRE in self.SYSTEM_RATING_REs.items():
            m = re.search(ratingRE, rating)
            if m:
                return '{0}:{1}'.format(system, m.group('rating'))

        rating = rating.upper().replace('RATED', '').strip(': ')

        # Try to match against default system if set
        defaultSystem = cinemavision.ratings.DEFAULT_RATING_SYSTEM
        if defaultSystem and defaultSystem in self.RATING_REs:
            m = re.search(self.RATING_REs[defaultSystem], rating)
            if m:
                return '{0}:{1}'.format(defaultSystem, m.group('rating'))

        # Try to extract rating from know ratings systems
        for system, ratingRE in self.RATING_REs.items():
            m = re.search(ratingRE, rating)
            if m:
                return m.group('rating')

        # Just return what we have
        return rating
    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
Example #7
0
    def onPlayBackStarted(self):
        if self.playStatus == self.PLAYING_MUSIC:
            DEBUG_LOG('MUSIC STARTED')
            return

        self.playStatus = time.time()
        if self.DUMMY_FILE_PREV in self.getPlayingFile():
            self.playStatus = self.PLAYING_DUMMY_PREV
            kodiutil.DEBUG_LOG('Stopping for PREV dummy')
            self.stop()
            return
        elif self.DUMMY_FILE_NEXT in self.getPlayingFile():
            self.playStatus = self.PLAYING_DUMMY_NEXT
            kodiutil.DEBUG_LOG('Stopping for NEXT dummy')
            self.stop()
            return
        else:
            self.hasFullscreened = False

        DEBUG_LOG('PLAYBACK STARTED')
Example #8
0
    def _save(self, full_path, temp=False):
        items = [li.dataSource for li in self.sequenceControl if li.dataSource]

        if not cinemavision.sequence.sequenceHasFeature(items):
            yes = xbmcgui.Dialog().yesno(
                T(32603, 'No Feature'),
                T(
                    32604,
                    'Sequence does not have a feature module, which is required to play items selected in Kodi.'
                ), T(32605, 'Continue?'))
            if not yes:
                return

        xmlString = cinemavision.sequence.getSaveString(items)

        kodiutil.DEBUG_LOG('Saving to: {0}'.format(full_path))

        success = True
        if cinemavision.util.vfs.exists(full_path):
            cinemavision.util.vfs.delete(full_path)

        with cinemavision.util.vfs.File(full_path, 'w') as f:
            success = f.write(xmlString)

        if not success:
            xbmcgui.Dialog().ok(
                T(32573, 'Failed'), T(32606, 'Failed to write sequence file!'),
                T(32607, 'Kodi may be unable to write to this location.'))
            return

        if not temp:
            self.modified = False
            self.saveDefault()

            sequence2D = kodiutil.getSetting('sequence.2D')
            sequence3D = kodiutil.getSetting('sequence.3D')
            if not sequence2D or (self.name != sequence2D
                                  and self.name != sequence3D):
                yes = xbmcgui.Dialog().yesno(
                    T(32555, 'Set Default'),
                    T(
                        32556,
                        'Would you like to set this as the default for playback?'
                    ))
                if yes:
                    as3D = xbmcgui.Dialog().yesno('2D/3D',
                                                  T(32557, 'For 2D or 3D?'),
                                                  nolabel='2D',
                                                  yeslabel='3D')
                    if as3D:
                        kodiutil.setSetting('sequence.3D', self.name)
                    else:
                        kodiutil.setSetting('sequence.2D', self.name)
Example #9
0
def getMatchedSequence(feature):
    priority = [
        'type', 'ratings', 'year', 'studio', 'director', 'actor', 'genre',
        'tags', 'dates', 'times'
    ]

    contentPath = getSequencesContentPath()
    if not contentPath:
        return getDefaultSequenceData(feature)

    sequencesPath = cinemavision.util.pathJoin(contentPath, 'Sequences')

    sequences = getActiveSequences()

    if not sequences:
        return getDefaultSequenceData(feature)

    out = 'Active sequences:\n'
    for seq in sequences:
        out += '{0}\n'.format(seq.conditionsStr())

    kodiutil.DEBUG_LOG(out)

    matches = [[s, 0] for s in sequences]
    for attr in priority:
        for seq in matches[:]:
            match = seq[0].matchesFeatureAttr(attr, feature)
            if match >= 0:
                seq[1] += match
            else:
                matches.remove(seq)

        if not matches:
            break

    if matches:
        out = 'MATCHES: '
        out += ', '.join([
            '{0}({1})'.format(kodiutil.strRepr(m[0].name), m[1])
            for m in matches
        ])
        kodiutil.DEBUG_LOG(out)
        seqData = max(matches, key=lambda x: x[1])[0]
    else:
        seqData = None

    kodiutil.DEBUG_LOG('.')
    kodiutil.DEBUG_LOG('CHOICE: {0}'.format(seqData.name))
    kodiutil.DEBUG_LOG('.')
    kodiutil.DEBUG_LOG(feature)

    if not seqData:
        return getDefaultSequenceData(feature)

    path = cinemavision.util.pathJoin(sequencesPath,
                                      '{0}.cvseq'.format(seqData.name))
    return {'path': path, 'sequence': seqData}
Example #10
0
    def _save(self, full_path, temp=False):
        items = [li.dataSource for li in self.sequenceControl if li.dataSource]

        if not cinemavision.sequence.sequenceHasFeature(items):
            yes = xbmcgui.Dialog().yesno(
                T(32603, 'No Feature'),
                T(
                    32604,
                    'Sequence does not have a feature module, which is required to play items selected in Kodi.'
                ), T(32605, 'Continue?'))
            if not yes:
                return

        self.sequenceData.setItems(items)

        kodiutil.DEBUG_LOG('Saving to: {0}'.format(full_path))

        try:
            success = self.sequenceData.save(full_path)
        except cinemavision.exceptions.SequenceWriteReadEmptyException:
            xbmcgui.Dialog().ok(
                T(32573,
                  'Failed'), 'Failed to verify sequence file after write!',
                'Kodi may be unable to save to this location.')
            return
        except cinemavision.exceptions.SequenceWriteReadBadException:
            xbmcgui.Dialog().ok(
                T(32573,
                  'Failed'), 'Bad sequence file verification after write!',
                'The sequence file seems to have been corrupted when saving.')
            return
        except cinemavision.exceptions.SequenceWriteReadUnknownException:
            xbmcgui.Dialog().ok(
                T(32573, 'Failed'),
                'Unknown error when verifying sequence file after write!',
                'The sequence file may not have been saved.')
            return
        if not success:
            xbmcgui.Dialog().ok(
                T(32573, 'Failed'), T(32606, 'Failed to write sequence file!'),
                T(32607, 'Kodi may be unable to save to this location.'))
            return

        if not temp:
            self.modified = False
            self.saveDefault()
Example #11
0
    def stopMusic(self, image_queue=None):
        try:
            rpc.Playlist.Clear(playlistid=xbmc.PLAYLIST_MUSIC)

            if image_queue and image_queue.music:
                self.volume.set(1,
                                fade_time=int(image_queue.musicFadeOut * 1000))
                while self.volume.fading(
                ) and not self.abortFlag.isSet() and not kodiutil.wait(0.1):
                    if self.window.hasAction(
                    ) and self.window.action != 'RESUME':
                        break

            kodiutil.DEBUG_LOG('Stopping music')
            self.stop()
            self.waitForPlayStop()
            self.playStatus = self.NOT_PLAYING
        finally:
            self.volume.restore(delay=500)
Example #12
0
    def _start(self, sequence_path):
        import cvutil

        self.processor = cinemavision.sequenceprocessor.SequenceProcessor(
            sequence_path, content_path=cvutil.getContentPath())
        [self.processor.addFeature(f) for f in self.features]

        kodiutil.DEBUG_LOG('\n.')
        DEBUG_LOG(
            '[ -- Started --------------------------------------------------------------- ]'
        )

        self.openWindow()
        self.processor.process()
        self.setSkinFeatureVars()
        self.next()
        self.waitLoop()

        del self.window
        self.window = None
Example #13
0
def loadContent(from_settings=False, bg=False):
    import xbmcgui

    if from_settings and not kodiutil.getPathSetting('content.path'):
        xbmcgui.Dialog().ok(T(32503, 'No Content Path'), ' ',
                            T(32504, 'Content path not set or not applied'))
        return

    contentPath = getContentPath(from_load=True)

    kodiutil.DEBUG_LOG('Loading content...')

    with kodiutil.Progress(T(32505, 'Loading Content'), bg=bg) as p:
        cinemavision.content.UserContent(contentPath,
                                         callback=p.msg,
                                         trailer_sources=kodiutil.getSetting(
                                             'trailer.scrapers',
                                             '').split(','))

    createSettingsRSDirs()
Example #14
0
 def videoPreDelay(self):
     delay = kodiutil.getSetting('video.preDelay', 0)
     if delay:
         kodiutil.DEBUG_LOG('Video pre-dalay: {0}ms'.format(delay))
         xbmc.sleep(delay)
Example #15
0
def DEBUG_LOG(msg):
    kodiutil.DEBUG_LOG('Experience: {0}'.format(msg))
Example #16
0
 def debug_log(msg):
     kodiutil.DEBUG_LOG('PASTEBIN: {0}'.format(msg))
Example #17
0
 def __init__(self):
     kodiutil.DEBUG_LOG('Language: {0}'.format(self.LANGUAGE))
     self.setRatingDefaults()