Use config from factory
MODIFY
plex_trakt_sync/commands/plex_login.py
plex_trakt_sync/commands/plex_login.py
from plexapi.myplex import MyPlexAccount, MyPlexResource, ResourceConnection
from plexapi.server import PlexServer
-from plex_trakt_sync.config import CONFIG
+from plex_trakt_sync.factory import factory
from plex_trakt_sync.style import prompt, error, success, title, comment, disabled, highlight
PROMPT_PLEX_PASSWORD = prompt("Please enter your Plex password")
PROMPT_PLEX_RELOGIN = prompt("You already have Plex Access Token, do you want to log in again?")
PROMPT_MANAGED_USER = prompt("Do you want to use managed user instead of main account?")
SUCCESS_MESSAGE = success("Plex Media Server Authentication Token and base URL have been added to .env file")
+CONFIG = factory.config()
def myplex_login(username, password):

MODIFY
plex_trakt_sync/commands/sync.py
plex_trakt_sync/commands/sync.py
from plex_trakt_sync.factory import factory
from plex_trakt_sync.media import Media
from plex_trakt_sync.plex_api import PlexApi
-from plex_trakt_sync.config import CONFIG
from plex_trakt_sync.decorators.measure_time import measure_time
from plex_trakt_sync.trakt_api import TraktApi
from plex_trakt_sync.trakt_list_util import TraktListUtil
from plex_trakt_sync.version import git_version_info
from plex_trakt_sync.walker import Walker
+CONFIG = factory.config()
+
def sync_collection(m: Media):
if not CONFIG['sync']['collection']:

MODIFY
plex_trakt_sync/commands/trakt_login.py
plex_trakt_sync/commands/trakt_login.py
import click
from trakt.errors import ForbiddenException
-from plex_trakt_sync.config import CONFIG
from plex_trakt_sync.factory import factory
from plex_trakt_sync.path import pytrakt_file
from plex_trakt_sync.style import title, success, error, prompt
@@ -39,6 +38,8 @@ def trakt_authenticate(api: TraktApi):
def has_trakt_token():
if not exists(pytrakt_file):
return False
+
+ CONFIG = factory.config()
return CONFIG["TRAKT_USERNAME"] is not None
@@ -52,6 +53,7 @@ def trakt_login():
trakt_authenticate(api)
user = api.me.username
+ CONFIG = factory.config()
CONFIG["TRAKT_USERNAME"] = user
CONFIG.save()

MODIFY
plex_trakt_sync/logging.py
plex_trakt_sync/logging.py
import logging
import sys
-from .config import CONFIG
+from .factory import factory
from .path import log_file
def initialize():
+ CONFIG = factory.config()
# global log level for all messages
log_level = logging.DEBUG if CONFIG['log_debug_messages'] else logging.INFO
log_format = '%(asctime)s %(levelname)s:%(message)s'

MODIFY
plex_trakt_sync/plex_api.py
plex_trakt_sync/plex_api.py
from plex_trakt_sync.decorators.deprecated import deprecated
from plex_trakt_sync.decorators.memoize import memoize
from plex_trakt_sync.decorators.nocache import nocache
-from plex_trakt_sync.config import CONFIG
from trakt.utils import timestamp
+from plex_trakt_sync.factory import factory
from plex_trakt_sync.logging import logger
@@ -37,6 +37,7 @@ def provider(self):
x = x.replace("themoviedb", "tmdb")
x = x.replace("thetvdb", "tvdb")
if x == "xbmcnfo":
+ CONFIG = factory.config()
x = CONFIG["xbmc-providers"][self.media_type]
return x
@@ -331,6 +332,7 @@ def updated_at(self):
@memoize
@nocache
def library_sections(self):
+ CONFIG = factory.config()
result = []
for section in self.plex.library.sections():
if section.title in CONFIG["excluded-libraries"]:

MODIFY
plex_trakt_sync/plex_server.py
plex_trakt_sync/plex_server.py
import plexapi.server
-from plex_trakt_sync.config import CONFIG, PLEX_PLATFORM
+from plex_trakt_sync.config import PLEX_PLATFORM
from plex_trakt_sync.decorators.nocache import nocache
+from plex_trakt_sync.factory import factory
from plex_trakt_sync.logging import logger
@@ -15,6 +16,7 @@ def get_plex_server():
def _get_plex_server():
+ CONFIG = factory.config()
plex_token = CONFIG["PLEX_TOKEN"]
plex_baseurl = CONFIG["PLEX_BASEURL"]
plex_fallbackurl = CONFIG["PLEX_FALLBACKURL"]

MODIFY
plex_trakt_sync/trakt_api.py
plex_trakt_sync/trakt_api.py
from plex_trakt_sync.decorators.nocache import nocache
from plex_trakt_sync.decorators.rate_limit import rate_limit
from plex_trakt_sync.decorators.time_limit import time_limit
-from plex_trakt_sync.config import CONFIG
from plex_trakt_sync import pytrakt_extensions
from plex_trakt_sync.path import pytrakt_file
from plex_trakt_sync.plex_api import PlexLibraryItem, PlexGuid
@@ -82,6 +81,7 @@ def me(self):
@nocache
@rate_limit()
def liked_lists(self):
+ CONFIG = factory.config()
if not CONFIG['sync']['liked_lists']:
return []
return pytrakt_extensions.get_liked_lists()
@@ -136,6 +136,7 @@ def watched_shows(self):
@nocache
@rate_limit()
def watchlist_movies(self):
+ CONFIG = factory.config()
if not CONFIG['sync']['watchlist']:
return []

Use config from factory