def create_session(self, info):
        if not info.get('ratingKey'):
            log.warn('Invalid ratingKey provided from activity info')
            return None

        # Metadata
        metadata = Metadata.get(info['ratingKey'])

        # Guid
        guid = Guid.parse(metadata.guid) if metadata else None

        ws = WatchSession.from_info(info, metadata, guid, info['ratingKey'])
        ws.skip = not metadata

        # Fetch client by `machineIdentifier`
        ws.client = Plex.clients().get(info['machineIdentifier'])

        if not ws.client:
            # Create dummy client from `info`
            ws.client = Client(Plex.client, 'clients')
            ws.client.name = info.get('client', None)
            ws.client.machine_identifier = info.get('machineIdentifier', None)

            ws.client.address = info.get('address', None)
            ws.client.port = info.get('port', None)

        # Create dummy user from `info`
        ws.user = User(Plex.client, 'accounts')
        ws.user.id = info['user_id']
        ws.user.title = info['user_name']

        ws.save()

        log.debug('created session: %s', ws)
        return ws
class LoggingScrobbler(ScrobblerMethod):
    name = 'LoggingScrobbler'

    def __init__(self):
        super(LoggingScrobbler, self).__init__()

        EventManager.subscribe('scrobbler.logging.update', self.update)

    @classmethod
    def test(cls):
        # Try enable logging
        if not PlexPreferences.log_debug(True):
            log.warn('Unable to enable logging')

        # Test if logging is enabled
        if not PlexPreferences.log_debug():
            log.warn(
                'Debug logging not enabled, unable to use logging activity method.'
            )
            return False

        return True

    def create_session(self, info):
        if not info.get('ratingKey'):
            log.warn('Invalid ratingKey provided from activity info')
            return None

        skip = False

        # Client
        client = None
        if info.get('machineIdentifier'):
            client = PlexMediaServer.get_client(info['machineIdentifier'])
        else:
            log.info(
                'No machineIdentifier available, client filtering not available'
            )

        # Metadata
        metadata = None

        try:
            metadata = PlexMetadata.get(info['ratingKey'])

            if metadata:
                metadata = metadata.to_dict()
        except NotImplementedError, e:
            # metadata not supported (music, etc..)
            log.debug('%s, ignoring session' % e.message)
            skip = True

        session = WatchSession.from_info(info, metadata, client)
        session.skip = skip
        session.save()

        return session
    def create_session(self, info):
        client = None
        if info.get('machineIdentifier'):
            client = PMS.client(info['machineIdentifier'])
        else:
            Log.Info('No machineIdentifier available, client filtering not available')

        return WatchSession.from_info(
            info,
            PMS.metadata(info['ratingKey']),
            client
        )
 def create_session(self, info):
     return WatchSession.from_info(
         info,
         PlexMediaServer.metadata(info['ratingKey']),
         PlexMediaServer.client(info.get('client_id'))
     )
示例#5
0
 def create_session(self, info):
     return WatchSession.from_info(
         info, PlexMediaServer.metadata(info['ratingKey']),
         PlexMediaServer.client(info.get('client_id')))