Add server_config factory
Load config first to ensure migrate works and PLEX_SERVER is accurate
MODIFY
plextraktsync/factory.py
plextraktsync/factory.py
@@ -33,20 +33,24 @@ def media_factory(self):
@memoize
def plex_server(self):
- config = self.config()
-
- from plextraktsync.config.ServerConfig import ServerConfig
from plextraktsync.plex_server import PlexServerConnection
- server_name = config["PLEX_SERVER"]
- sc = ServerConfig()
- sn = sc.get_server(server_name)
+ server = self.server_config()
return PlexServerConnection(factory).connect(
- urls=sn.urls,
- token=sn.token,
+ urls=server.urls,
+ token=server.token,
)
+ @memoize
+ def server_config(self):
+ config = self.config()
+
+ from plextraktsync.config.ServerConfig import ServerConfig
+
+ # NOTE: the load() is needed because config["PLEX_SERVER"] may change during migrate() there.
+ return ServerConfig().load().get_server(config["PLEX_SERVER"])
+
@memoize
def session(self):
from requests_cache import CachedSession

Add server_config factory

Load config first to ensure migrate works and PLEX_SERVER is accurate