Change factory.plex_api to property
MODIFY
plextraktsync/commands/info.py
plextraktsync/commands/info.py
@@ -32,7 +32,7 @@ def info(print=logger.info):
print(f"Plex Server Name: {factory.server_config().name}")
if has_plex_token():
- plex = factory.plex_api()
+ plex = factory.plex_api
print(f"Plex Server version: {plex.version}, updated at: {plex.updated_at}")
print(
f"Enabled {len(plex.library_sections)} libraries in Plex Server: {plex.library_section_names}"

MODIFY
plextraktsync/commands/inspect.py
plextraktsync/commands/inspect.py
def inspect_media(id):
- plex = factory.plex_api()
+ plex = factory.plex_api
mf = factory.media_factory()
print("")

MODIFY
plextraktsync/commands/subdl.py
plextraktsync/commands/subdl.py
@@ -21,7 +21,7 @@ def download(plex: PlexApi, pm: PlexLibraryItem):
def subdl(input):
- plex = factory.plex_api()
+ plex = factory.plex_api
for id in expand_id(input):
pm = plex.fetch_item(id)

MODIFY
plextraktsync/commands/unmatched.py
plextraktsync/commands/unmatched.py
def unmatched(no_progress_bar: bool, local: bool):
config = factory.run_config().update(progressbar=not no_progress_bar)
ensure_login()
- plex = factory.plex_api()
+ plex = factory.plex_api
trakt = factory.trakt_api
mf = factory.media_factory()
pb = factory.progressbar(config.progressbar)

MODIFY
plextraktsync/factory.py
plextraktsync/factory.py
@@ -12,7 +12,7 @@ def trakt_api(self):
return trakt
- @memoize
+ @cached_property
def plex_api(self):
from plextraktsync.plex_api import PlexApi
@@ -26,7 +26,7 @@ def media_factory(self):
from plextraktsync.media import MediaFactory
trakt = self.trakt_api
- plex = self.plex_api()
+ plex = self.plex_api
mf = MediaFactory(plex, trakt)
return mf
@@ -72,7 +72,7 @@ def sync(self):
from plextraktsync.sync import Sync
config = self.config()
- plex = self.plex_api()
+ plex = self.plex_api
trakt = self.trakt_api
return Sync(config, plex, trakt)
@@ -122,7 +122,7 @@ def walker(self):
config = self.run_config()
walk_config = self.walk_config()
- plex = self.plex_api()
+ plex = self.plex_api
trakt = self.trakt_api
mf = self.media_factory()
pb = self.progressbar(config.progressbar)
@@ -141,7 +141,7 @@ def watch_state_updater(self):
from plextraktsync.commands.watch import WatchStateUpdater
return WatchStateUpdater(
- plex=self.plex_api(),
+ plex=self.plex_api,
trakt=self.trakt_api,
mf=self.media_factory(),
config=self.config(),

MODIFY
tests/test_plex_search.py
tests/test_plex_search.py
#!/usr/bin/env python3 -m pytest
from tests.conftest import factory
-plex = factory.plex_api()
+plex = factory.plex_api
def test_plex_search():

Change factory.plex_api to property