def initialize(cls):
        cls.thread = Thread(target=cls.process)

        Activity.on('logging.action.played', cls.on_played)\
                .on('logging.action.unplayed', cls.on_unplayed)

        WatchSession.configure(cls)
Ejemplo n.º 2
0
    def run(self):
        # Check for authentication token
        log.info('X-Plex-Token: %s',
                 'available' if os.environ.get('PLEXTOKEN') else 'unavailable')

        # Process server startup state
        self.process_server_state()

        # Start new-style modules
        module_start()

        # Start modules
        names = []

        for module in self.modules:
            if not hasattr(module, 'start'):
                continue

            names.append(get_class_name(module))

            module.start()

        log.info('Started %s modules: %s', len(names), ', '.join(names))

        ModuleManager.start()

        # Start plex.activity.py
        Activity.start(ACTIVITY_MODE.get(Preferences.get('activity.mode')))
Ejemplo n.º 3
0
    def run(self):
        # Check for authentication token
        log.info('X-Plex-Token: %s', 'available' if os.environ.get('PLEXTOKEN') else 'unavailable')

        # Process server startup state
        self.process_server_state()

        # Start new-style modules
        module_start()

        # Start modules
        names = []

        for module in self.modules:
            if not hasattr(module, 'start'):
                continue

            names.append(get_class_name(module))

            module.start()

        log.info('Started %s modules: %s', len(names), ', '.join(names))

        ModuleManager.start()

        # Start plex.activity.py
        Activity.start(ACTIVITY_MODE.get(Preferences.get('activity.mode')))
Ejemplo n.º 4
0
    def __init__(self):
        self._accounts = {}
        self._accounts_lock = Lock()

        self._started_at = None

        # Bind to activity events
        Activity.on('websocket.scanner.started', self.on_started)
        Activity.on('websocket.timeline.created', self.on_added)
Ejemplo n.º 5
0
    def start(self):
        activity_sources_enabled = None

        if config.plex_token:
            from plex import Plex
            Plex.configuration.defaults.authentication(config.plex_token)
            activity_sources_enabled = ["websocket"]
            Activity.on('websocket.playing', self.on_playing)

        if activity_sources_enabled:
            Activity.start(activity_sources_enabled)
Ejemplo n.º 6
0
    def initialize(cls):
        cls.thread = threading.Thread(target=cls.run, name="SyncManager")
        cls.lock = threading.Lock()

        cls.handlers = dict([(h.key, h(cls)) for h in HANDLERS])
        cls.statistics = SyncStatistics(cls)

        # Load/setup matcher cache
        Plex.configuration.defaults.cache(
            matcher=CacheManager.get('matcher', persistent=True)
        )

        # Bind activity events
        Activity.on('websocket.scanner.finished', cls.scanner_finished)

        EG['SyncManager.current'].set(lambda: cls.current)

        cls.initialized = True
Ejemplo n.º 7
0
    def start(self):
        # Check for authentication token
        log.info('X-Plex-Token: %s', 'available' if os.environ.get('PLEXTOKEN') else 'unavailable')

        # Validate username/password
        spawn(self.authenticate)

        # Start modules
        names = []

        for module in self.modules:
            if not hasattr(module, 'start'):
                continue

            names.append(get_class_name(module))

            module.start()

        log.info('Started %s modules: %s', len(names), ', '.join(names))

        ModuleManager.start()

        # Start plex.activity.py
        Activity.start(ACTIVITY_MODE.get(Prefs['activity_mode']))
    def __init__(self, sync):
        super(LibraryUpdateTrigger, self).__init__(sync)

        self._activity_at = None
        self._lock = Lock()

        self._thread = None

        # Bind to scanner/timeline events
        Activity.on('websocket.scanner.finished', self.trigger)

        Activity.on('websocket.timeline.loading', self.trigger)
        Activity.on('websocket.timeline.finished', self.trigger)
Ejemplo n.º 9
0
    def __init__(self, sync):
        super(LibraryUpdateTrigger, self).__init__(sync)

        self._state = LibraryState()
        self._trigger_lock = Lock()

        self._activity_at = None
        self._thread = None

        # Bind to scanner/timeline events
        Activity.on('websocket.scanner.finished', self.trigger)
        Activity.on('websocket.timeline.loading', self.trigger)
        Activity.on('websocket.timeline.finished', self.trigger)
Ejemplo n.º 10
0
    def __init__(self, types=None):
        if types is not None:
            self.types = types
        else:
            self.types = DEFAULT_TYPES

        self.cache = None
        self.client = None

        # Private
        self._lock = Condition()

        # Bind activity events
        Activity.on('websocket.timeline.created', self.timeline_created)
        Activity.on('websocket.timeline.deleted', self.timeline_deleted)
        Activity.on('websocket.timeline.finished', self.timeline_finished)
Ejemplo n.º 11
0
    def __init__(self, types=None):
        if types is not None:
            self.types = types
        else:
            self.types = DEFAULT_TYPES

        self.cache = None
        self.client = None

        # Private
        self._lock = Condition()

        # Bind activity events
        Activity.on('websocket.timeline.created', self.timeline_created)
        Activity.on('websocket.timeline.deleted', self.timeline_deleted)
        Activity.on('websocket.timeline.finished', self.timeline_finished)
Ejemplo n.º 12
0
    def start(self):
        activity_sources_enabled = None

        if config.universal_plex_token:
            from plex import Plex
            Plex.configuration.defaults.authentication(
                config.universal_plex_token)
            activity_sources_enabled = ["websocket"]
            Activity.on('websocket.playing', self.on_playing)

        elif config.server_log_path:
            Activity_Logging.add_hint(config.server_log_path, None)
            activity_sources_enabled = ["logging"]
            Activity.on('logging.playing', self.on_playing)

        if activity_sources_enabled:
            Activity.start(activity_sources_enabled)
Ejemplo n.º 13
0
    def __init__(self):
        Activity.on('logging.playing', self.on_playing)

        self.engine = SessionEngine()
Ejemplo n.º 14
0
    def __init__(self):
        Activity.on('websocket.playing', self.on_playing)

        self.engine = SessionEngine()
Ejemplo n.º 15
0


if __name__ == '__main__':
    # Set authentication token
    Plex.configuration.defaults.authentication(
        raw_input('Authentication token: ')
    )

    # Bind events
    @Activity.on('websocket.playing')
    def ws_playing(info):
        print "[websocket.playing]", info

    @Activity.on('logging.playing')
    def lo_playing(info):
        print "[logging.playing]", info

    @Activity.on('logging.action.played')
    def on_played(info):
        print "[logging.action.played]", info

        metadata = Metadata.get(info.get('rating_key'))
        print metadata

    @Activity.on('logging.action.unplayed')
    def on_unplayed(info):
        print "[logging.action.unplayed]", info

    Activity.start()
    def __init__(self):
        super(WebSocketScrobbler, self).__init__()

        Activity.on('websocket.playing', self.update)
    def __init__(self):
        super(LoggingScrobbler, self).__init__()

        Activity.on('logging.playing', self.update)
Ejemplo n.º 18
0
from plex import Plex
from plex_activity import Activity
from plex_metadata import Metadata

import os

if __name__ == '__main__':
    Plex.configuration.defaults.authentication(os.environ.get('PLEXTOKEN'))

    @Activity.on('websocket.playing')
    def ws_playing(info):
        print "[websocket.playing]", info

    @Activity.on('logging.playing')
    def lo_playing(info):
        print "[logging.playing]", info

    @Activity.on('logging.action.played')
    def on_played(info):
        print "[logging.action.played]", info

        metadata = Metadata.get(info.get('rating_key'))
        print metadata

    @Activity.on('logging.action.unplayed')
    def on_unplayed(info):
        print "[logging.action.unplayed]", info

    Activity.start()
Ejemplo n.º 19
0
    def __init__(self):
        Activity.on('websocket.playing', self.on_playing)

        self.engine = SessionEngine()
Ejemplo n.º 20
0
    def __init__(self):
        Activity.on('logging.playing', self.on_playing)

        self.engine = SessionEngine()