Example #1
0
def setTheme(theme_path=None):
    global THEME

    default = os.path.join(kodiutil.ADDON_PATH, 'resources', 'themes',
                           'default') + '/'

    if theme_path is not None:
        kodiutil.setSetting('theme.path', theme_path)
    else:
        theme_path = kodiutil.getSetting('theme.path', default)

    cfg = cinemavision.util.pathJoin(theme_path, 'theme.json')
    try:
        with cinemavision.util.vfs.File(cfg, 'r') as f:
            THEME = json.loads(f.read().decode('utf-8'))
            THEME['theme.path'] = theme_path
    except:
        kodiutil.ERROR('Could not read {0}'.format(cfg))
        THEME = {
            'theme.name': '[I]Default[/I]',
            'theme.color.icon': 'FF9C2A2D',
            'theme.color.setting': 'FF9C2A2D',
            'theme.color.move': 'FF9C2A2D',
            'theme.color.button.selected': 'FF9C2A2D',
            'theme.path': default
        }

    kodiutil.setGlobalProperty('theme.color.icon', THEME['theme.color.icon'])
    kodiutil.setGlobalProperty('theme.color.setting',
                               THEME['theme.color.setting'])
    kodiutil.setGlobalProperty('theme.color.move', THEME['theme.color.move'])
    kodiutil.setGlobalProperty('theme.color.button.selected',
                               THEME['theme.color.button.selected'])
    kodiutil.setGlobalProperty('theme.path', THEME['theme.path'])
Example #2
0
def setScrapers():
    import cvutil
    import cinemavision

    selected = [
        s.strip().lower()
        for s in kodiutil.getSetting('trailer.scrapers', '').split(',')
    ]
    contentScrapers = cinemavision.util.contentScrapers()
    temp = [list(x) for x in cinemavision.sequence.Trailer._scrapers]
    options = []
    for s in temp:
        for ctype, c in contentScrapers:
            if ctype == 'trailers' and c == s[0]:
                s[2] = s[2] in selected
                options.append(s)
    options.sort(key=lambda i: i[0].lower() in selected and selected.index(i[
        0].lower()) + 1 or 99)

    result = cvutil.multiSelect(options, default=True)

    if result is False or result is None:
        return

    kodiutil.setSetting('trailer.scrapers', result)
Example #3
0
def createSettingsRSDirs():
    base = os.path.join(kodiutil.PROFILE_PATH, 'settings', 'ratings')
    if not os.path.exists(base):
        os.makedirs(base)
    defaultPath = os.path.join(kodiutil.PROFILE_PATH, 'settings',
                               'ratings_default')

    if os.path.exists(defaultPath):
        import shutil
        shutil.rmtree(defaultPath)

    defaultSystem = kodiutil.getSetting('rating.system.default', 'MPAA')

    for system in cinemavision.ratings.RATINGS_SYSTEMS.values():
        systemPaths = [os.path.join(base, system.name)]
        if system.name == defaultSystem:
            systemPaths.append(defaultPath)

        for path in systemPaths:
            if not os.path.exists(path):
                os.makedirs(path)

            for rating in system.ratings:
                with open(os.path.join(path,
                                       str(rating).replace(':', '.', 1)), 'w'):
                    pass

    kodiutil.setSetting('settings.ratings.initialized', 'true')
    kodiutil.setSetting('settings.ratings.initialized2', 'true')
Example #4
0
def createSettingsRSDirs():
    base = os.path.join(kodiutil.PROFILE_PATH, 'settings', 'ratings')
    if not os.path.exists(base):
        os.makedirs(base)
    defaultPath = os.path.join(kodiutil.PROFILE_PATH, 'settings', 'ratings_default')

    if os.path.exists(defaultPath):
        import shutil
        shutil.rmtree(defaultPath)

    defaultSystem = kodiutil.getSetting('rating.system.default', 'MPAA')

    for system in cinemavision.ratings.RATINGS_SYSTEMS.values():
        systemPaths = [os.path.join(base, system.name)]
        if system.name == defaultSystem:
            systemPaths.append(defaultPath)

        for path in systemPaths:
            if not os.path.exists(path):
                os.makedirs(path)

            for rating in system.ratings:
                with open(os.path.join(path, str(rating).replace(':', '.', 1)), 'w'):
                    pass

    kodiutil.setSetting('settings.ratings.initialized', 'true')
    kodiutil.setSetting('settings.ratings.initialized2', 'true')
Example #5
0
def setDefaultSequence(setting):
    import cvutil

    selection = cvutil.selectSequence()
    if not selection:
        return

    kodiutil.setSetting(setting, selection['name'])
Example #6
0
def removeContentDatabase():
    import os
    import xbmcgui

    dbFile = os.path.join(kodiutil.PROFILE_PATH, 'content.db')
    if os.path.exists(dbFile):
        os.remove(dbFile)

    kodiutil.setSetting('content.initialized', False)

    xbmcgui.Dialog().ok(T(32515, 'Done'), ' ', T(32584, 'Database reset.'))
Example #7
0
 def checkForContentDB(self):
     if kodiutil.getSetting('content.path'):
         kodiutil.setGlobalProperty('DEMO_MODE', '')
         if kodiutil.getSetting('content.initialized', False) and kodiutil.getSetting('content.path') == kodiutil.getSetting('content.last.path'):
             return True
         else:
             kodiutil.setSetting('content.last.path', kodiutil.getSetting('content.path'))
             return False
     else:
         kodiutil.setGlobalProperty('DEMO_MODE', '1')
         return True
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 checkForContentDB(self):
     if kodiutil.getSetting('content.path'):
         kodiutil.setGlobalProperty('DEMO_MODE', '')
         if kodiutil.getSetting('content.initialized',
                                False) and kodiutil.getSetting(
                                    'content.path') == kodiutil.getSetting(
                                        'content.last.path'):
             return True
         else:
             kodiutil.setSetting('content.last.path',
                                 kodiutil.getSetting('content.path'))
             return False
     else:
         kodiutil.setGlobalProperty('DEMO_MODE', '1')
         return True
Example #10
0
def setRatingBumperStyle():
    import xbmcgui

    styles = cinemavision.sequence.Feature.DBChoices('ratingStyle')

    if not styles:
        xbmcgui.Dialog().ok(T(32508, 'No Content'), '', T(32509, 'No content found for current rating system.'))
        return

    idx = xbmcgui.Dialog().select(T(32510, 'Select Style'), [x[1] for x in styles])

    if idx < 0:
        return

    kodiutil.setSetting('feature.ratingStyle', styles[idx][0])
Example #11
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 #12
0
def setRatingBumperStyle():
    import xbmcgui

    styles = cinemavision.sequence.Feature.DBChoices('ratingStyle')

    if not styles:
        xbmcgui.Dialog().ok(
            T(32508, 'No Content'), '',
            T(32509, 'No content found for current rating system.'))
        return

    idx = xbmcgui.Dialog().select(T(32510, 'Select Style'),
                                  [x[1] for x in styles])

    if idx < 0:
        return

    kodiutil.setSetting('feature.ratingStyle', styles[idx][0])
Example #13
0
def getContentPath(from_load=False):
    contentPath = kodiutil.getSetting('content.path')
    demoPath = os.path.join(kodiutil.PROFILE_PATH, 'demo')

    if contentPath:
        kodiutil.setSetting('content.initialized', True)
        if os.path.exists(demoPath):
            try:
                import shutil
                shutil.rmtree(demoPath)
            except:
                kodiutil.ERROR()

        return contentPath
    else:
        if not os.path.exists(demoPath):
            copyDemoContent()
            downloadDemoContent()
            if not from_load:
                loadContent()
        return demoPath
Example #14
0
def getContentPath(from_load=False):
    contentPath = kodiutil.getPathSetting('content.path')
    demoPath = os.path.join(kodiutil.PROFILE_PATH, 'demo')

    if contentPath:
        kodiutil.setSetting('content.initialized', True)
        if os.path.exists(demoPath):
            try:
                import shutil
                shutil.rmtree(demoPath)
            except Exception:
                kodiutil.ERROR()

        return contentPath
    else:
        if not os.path.exists(demoPath):
            copyDemoContent()
            downloadDemoContent()
            if not from_load:
                loadContent()
        return demoPath
Example #15
0
def setScrapers():
    import cvutil
    import cinemavision

    selected = [s.strip().lower() for s in kodiutil.getSetting('trailer.scrapers', '').split(',')]
    contentScrapers = cinemavision.util.contentScrapers()
    temp = [list(x) for x in cinemavision.sequence.Trailer._scrapers]
    options = []
    for s in temp:
        for ctype, c in contentScrapers:
            if ctype == 'trailers' and c == s[0]:
                s[2] = s[2] in selected
                options.append(s)
    options.sort(key=lambda i: i[0].lower() in selected and selected.index(i[0].lower())+1 or 99)

    result = cvutil.multiSelect(options, default=True)

    if result is False or result is None:
        return

    kodiutil.setSetting('trailer.scrapers', result)
Example #16
0
 def saveDefault(self, force=True):
     if (not self.name or not self.path) and not force:
         return
     kodiutil.setSetting('save.name', self.name)
     kodiutil.setSetting('save.path', self.path)
Example #17
0
 def saveDefault(self, force=True):
     if (not self.name or not self.path) and not force:
         return
     kodiutil.setSetting('save.name', self.name)
     kodiutil.setSetting('save.path', self.path)