Change factory.trakt_api to property
MODIFY
plextraktsync/commands/clear_collections.py
plextraktsync/commands/clear_collections.py
@@ -8,7 +8,7 @@ def clear_collections(confirm, dry_run):
click.echo("You need to pass --confirm or --dry-run option to proceed")
return
- trakt = factory.trakt_api()
+ trakt = factory.trakt_api
for movie in trakt.movie_collection:
logger.info(f"Deleting: {movie}")

MODIFY
plextraktsync/commands/imdb_import.py
plextraktsync/commands/imdb_import.py
@@ -59,7 +59,7 @@ def from_csv(row):
def imdb_import(input: PathLike, dry_run: bool):
- trakt = factory.trakt_api()
+ trakt = factory.trakt_api
for r in read_csv(input):
print(f"Importing [blue]{r.media_type} {r.imdb}[/]: {r.title} ({r.year}), rated at {r.rate_date}")

MODIFY
plextraktsync/commands/trakt_login.py
plextraktsync/commands/trakt_login.py
@@ -60,7 +60,7 @@ def trakt_login():
def login():
- api = factory.trakt_api()
+ api = factory.trakt_api
trakt_authenticate(api)
user = api.me.username

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

MODIFY
plextraktsync/commands/watched_shows.py
plextraktsync/commands/watched_shows.py
def watched_shows():
- trakt = factory.trakt_api()
+ trakt = factory.trakt_api
table = Table(
show_header=True, header_style="bold magenta", title="Watched shows on Trakt"

MODIFY
plextraktsync/factory.py
plextraktsync/factory.py
class Factory:
- @memoize
+ @cached_property
def trakt_api(self):
from plextraktsync.trakt_api import TraktApi
@@ -25,7 +25,7 @@ def plex_api(self):
def media_factory(self):
from plextraktsync.media import MediaFactory
- trakt = self.trakt_api()
+ trakt = self.trakt_api
plex = self.plex_api()
mf = MediaFactory(plex, trakt)
@@ -73,7 +73,7 @@ def sync(self):
config = self.config()
plex = self.plex_api()
- trakt = self.trakt_api()
+ trakt = self.trakt_api
return Sync(config, plex, trakt)
@@ -123,7 +123,7 @@ def walker(self):
config = self.run_config()
walk_config = self.walk_config()
plex = self.plex_api()
- trakt = self.trakt_api()
+ trakt = self.trakt_api
mf = self.media_factory()
pb = self.progressbar(config.progressbar)
w = Walker(plex=plex, trakt=trakt, mf=mf, config=walk_config, progressbar=pb)
@@ -142,7 +142,7 @@ def watch_state_updater(self):
return WatchStateUpdater(
plex=self.plex_api(),
- trakt=self.trakt_api(),
+ trakt=self.trakt_api,
mf=self.media_factory(),
config=self.config(),
)

MODIFY
tests/test_batch.py
tests/test_batch.py
from plextraktsync.trakt_api import TraktBatch
from tests.conftest import factory, load_mock
-trakt = factory.trakt_api()
+trakt = factory.trakt_api
def test_batch_size_none():

MODIFY
tests/test_new_agent.py
tests/test_new_agent.py
from plextraktsync.plex_api import PlexLibraryItem
from tests.conftest import factory, make
-trakt = factory.trakt_api()
+trakt = factory.trakt_api
def test_tv_lookup():

MODIFY
tests/test_trakt_progress.py
tests/test_trakt_progress.py
from plextraktsync.trakt_api import TraktApi
from tests.conftest import factory
-trakt: TraktApi = factory.trakt_api()
+trakt: TraktApi = factory.trakt_api
def test_trakt_watched_progress():

MODIFY
tests/test_tv_lookup.py
tests/test_tv_lookup.py
from plextraktsync.trakt_api import TraktLookup
from tests.conftest import factory, make
-trakt = factory.trakt_api()
+trakt = factory.trakt_api
def test_tv_lookup():

Change factory.trakt_api to property