Esempio n. 1
0
    def get_trakt_username(cls):
        if Environment.get_pref('username'):
            return Environment.get_pref('username')

        if Environment.dict['trakt.username']:
            return Environment.dict['trakt.username']

        return None
Esempio n. 2
0
    def get(cls, key, normalize_values=True):
        value = Environment.get_pref(key)
        if not value:
            return None, None

        value = value.strip()

        # Allow all if wildcard (*) or blank
        if not value or value == '*':
            return None, None

        values = value.split(',')

        allow, deny = [], []

        for value in [v.strip() for v in values]:
            inverted = False

            # Check if this is an inverted value
            if value.startswith('-'):
                inverted = True
                value = value[1:]

            # Normalize values (if enabled)
            if normalize_values:
                value = cls.normalize(value)

            # Append value to list
            if not inverted:
                allow.append(value)
            else:
                deny.append(value)

        return allow, deny
Esempio n. 3
0
    def create_trakt_basic_credential(cls, trakt_account):
        if not Environment.dict['trakt.token']:
            return False

        try:
            TraktBasicCredential.create(
                account=trakt_account,
                password=Environment.get_pref('password'),

                token=Environment.dict['trakt.token']
            )
        except (apsw.ConstraintError, peewee.IntegrityError), ex:
            log.debug('Ignoring basic credential update for %r, already exists (%s)', trakt_account, ex)
            return False
Esempio n. 4
0
# ------------------------------------------------
# Environment
# ------------------------------------------------
from plugin.core.environment import Environment
import locale
import os

Environment.setup(Core, Dict, Platform, Prefs)

# plex.database.py
os.environ['LIBRARY_DB'] = os.path.join(
    Environment.path.plugin_support, 'Databases',
    'com.plexapp.plugins.library.db'
)

# locale
try:
    Log.Debug('Using locale: %s', locale.setlocale(locale.LC_ALL, ''))
except Exception, ex:
    Log.Warn('Unable to update locale: %s', ex)
# ------------------------------------------------
# FS Migrator
# ------------------------------------------------
from fs_migrator import FSMigrator

FSMigrator.run()
# ------------------------------------------------
# Logger
# ------------------------------------------------
from plugin.core.logger import LoggerManager
Esempio n. 5
0
# ------------------------------------------------
# Environment
# ------------------------------------------------
from plugin.core.environment import Environment, translate as _
import os

Environment.setup(Core, Dict, Platform, Prefs)

# plex.database.py
os.environ["LIBRARY_DB"] = os.path.join(Environment.path.plugin_support, "Databases", "com.plexapp.plugins.library.db")

# ------------------------------------------------
# FS Migrator
# ------------------------------------------------
from fs_migrator import FSMigrator

FSMigrator.run()

# ------------------------------------------------
# Logger
# ------------------------------------------------

from plugin.core.logger import LoggerManager

LoggerManager.setup(storage=False)

# ------------------------------------------------
# Interface messages
# ------------------------------------------------

from plugin.core.message import InterfaceMessages
Esempio n. 6
0
# ------------------------------------------------
# IMPORTANT
# Configure environment module before we import other modules (that could depend on it)
# ------------------------------------------------
from plugin.core.environment import Environment

# Configure environment
Environment.setup(Core)
# ------------------------------------------------

# ------------------------------------------------
# IMPORTANT
# These modules need to be loaded here first
# ------------------------------------------------
import core
import data
import pts
import sync
import interface
# ------------------------------------------------


from core.cache import CacheManager
from core.configuration import Configuration
from core.header import Header
from core.logger import Logger
from core.logging_handler import PlexHandler
from core.logging_reporter import RAVEN
from core.helpers import spawn, get_pref, schedule, get_class_name, md5
from core.plugin import ART, NAME, ICON
from core.update_checker import UpdateChecker
Esempio n. 7
0
# Update `sys.path`
sys.path.insert(0, os.path.join(LIBRARIES_DIR, 'Shared'))
sys.path.insert(0, CODE_DIR)

#
# Environment
#

from plex_mock.framework import Core
from plugin.core.environment import Environment
from plugin.core.constants import PLUGIN_IDENTIFIER

# Setup environment
Environment.setup(Core(CODE_DIR), {
    'trakt.token': 'trakt.token'
}, None, {
    'username': '******',
    'password': '******'
})

# Build directory structure for "Plug-in Support"
PLUGIN_SUPPORT = os.path.join(TEMP_DIR, 'Plug-in Support')

os.makedirs(os.path.join(PLUGIN_SUPPORT, 'Caches', PLUGIN_IDENTIFIER))
os.makedirs(os.path.join(PLUGIN_SUPPORT, 'Data', PLUGIN_IDENTIFIER))
os.makedirs(os.path.join(PLUGIN_SUPPORT, 'Databases'))

Environment.path.plugin_support = PLUGIN_SUPPORT

# Setup native libraries
from plugin.core.libraries import LibrariesManager
Esempio n. 8
0
# Update `sys.path`
sys.path.insert(0, os.path.join(LIBRARIES_DIR, 'Shared'))
sys.path.insert(0, CODE_DIR)

#
# Environment
#

from plex_mock.framework import Core
from plugin.core.environment import Environment
from plugin.core.constants import PLUGIN_IDENTIFIER

# Setup environment
Environment.setup(Core(CODE_DIR), {
    'trakt.token': 'trakt.token'
}, None, {
    'username': '******',
    'password': '******'
})

# Build directory structure for "Plug-in Support"
PLUGIN_SUPPORT = os.path.join(TEMP_DIR, 'Plug-in Support')

os.makedirs(os.path.join(PLUGIN_SUPPORT, 'Caches', PLUGIN_IDENTIFIER))
os.makedirs(os.path.join(PLUGIN_SUPPORT, 'Data', PLUGIN_IDENTIFIER))
os.makedirs(os.path.join(PLUGIN_SUPPORT, 'Databases'))

Environment.path.plugin_support = PLUGIN_SUPPORT

# Setup native libraries
from plugin.core.libraries.manager import LibrariesManager