Add save() method to Config class
MODIFY
plex_trakt_sync/config.py
plex_trakt_sync/config.py
import json
from dotenv import load_dotenv
from os import getenv
-from plex_trakt_sync.path import config_file
+from plex_trakt_sync.path import config_file, env_file
class Config(dict):
+ env_keys = [
+ "PLEX_BASEURL",
+ "PLEX_FALLBACKURL",
+ "PLEX_TOKEN",
+ "PLEX_USERNAME",
+ "TRAKT_USERNAME",
+ ]
+
initialized = False
def __getitem__(self, item):
@@ -32,5 +40,11 @@ def initialize(self):
self.initialized = True
+ def save(self):
+ with open(env_file, "w") as txt:
+ txt.write("# This is .env file for PlexTraktSync\n")
+ for key in self.env_keys:
+ txt.write("{}={}\n".format(key, self[key]))
+
CONFIG = Config()

Add save() method to Config class