def init_plex(): # Ensure client identifier has been generated if not Dict['plex.client.identifier']: # Generate identifier Dict['plex.client.identifier'] = uuid.uuid4() # Retrieve current client identifier client_id = Dict['plex.client.identifier'] if isinstance(client_id, uuid.UUID): client_id = str(client_id) # plex.py Plex.configuration.defaults.authentication( os.environ.get('PLEXTOKEN') ) Plex.configuration.defaults.client( identifier=client_id, product='trakt (for Plex)', version=PLUGIN_VERSION ) # plex.activity.py path = os.path.join(LOG_HANDLER.baseFilename, '..', '..', 'Plex Media Server.log') path = os.path.abspath(path) Activity['logging'].add_hint(path) # plex.metadata.py Metadata.configure( client=Plex.client )
def init_plex(): # Ensure client identifier has been generated if not Dict['plex.client.identifier']: # Generate identifier Dict['plex.client.identifier'] = uuid.uuid4() # Retrieve current client identifier client_id = Dict['plex.client.identifier'] if isinstance(client_id, uuid.UUID): client_id = str(client_id) # plex.py Plex.configuration.defaults.authentication(os.environ.get('PLEXTOKEN')) Plex.configuration.defaults.client(identifier=client_id, product='trakt (for Plex)', version=PLUGIN_VERSION) # plex.activity.py path = os.path.join(LOG_HANDLER.baseFilename, '..', '..', 'Plex Media Server.log') path = os.path.abspath(path) Activity['logging'].add_hint(path) # plex.metadata.py Metadata.configure(client=Plex.client)
def init_plex(): # Ensure client identifier has been generated if not Dict['plex.client.identifier']: # Generate identifier Dict['plex.client.identifier'] = uuid.uuid4() # plex.py Plex.configuration.defaults.authentication( os.environ.get('PLEXTOKEN') ) Plex.configuration.defaults.client( identifier=Dict['plex.client.identifier'], product='trakt (for Plex)', version=PLUGIN_VERSION ) # plex.activity.py path = os.path.join(LOG_HANDLER.baseFilename, '..', '..', 'Plex Media Server.log') path = os.path.abspath(path) Activity['logging'].add_hint(path) # plex.metadata.py Metadata.configure( cache=CacheManager.get( 'plex.metadata', serializer='pickle:///?protocol=2' ), client=Plex.client )
def init_plex(): # plex.py Plex.configuration.defaults.authentication( os.environ.get('PLEXTOKEN') ) # plex.activity.py path = os.path.join(Core.log.handlers[1].baseFilename, '..', '..', 'Plex Media Server.log') path = os.path.abspath(path) Activity['logging'].add_hint(path) # plex.metadata.py Metadata.configure( cache=CacheManager.get('metadata'), client=Plex.client )
def test(func): t_elapsed = [] print 'test(%r)' % func # prime cache with Plex.configuration.cache(http=http_cache, matcher=matcher_cache): Metadata.configure(cache=metadata_cache) # Measure prime-cache task elapsed, items = measure(func) print '[P] %.02fs' % elapsed # Clear http cache http_cache.clear() time.sleep(1) for x in range(10): with Plex.configuration.cache(http=http_cache, matcher=matcher_cache): Metadata.configure(cache=metadata_cache) # Measure task elapsed, items = measure(func) print '[R] %.02fs' % elapsed t_elapsed.append(elapsed) # Clear http cache http_cache.clear() time.sleep(1) # Clear matcher/metadata caches matcher_cache.clear() metadata_cache.clear() # Calculate test statistics t_min = min(t_elapsed) t_max = max(t_elapsed) t_avg = sum(t_elapsed) / len(t_elapsed) print '] min: %.02f, max: %.02f, avg: %.02f' % (t_min, t_max, t_avg) print