Skip to content

Commit

Permalink
Merge pull request #309 from glensc/config-init-oob
Browse files Browse the repository at this point in the history
Move .env init check out of config to sync command
  • Loading branch information
glensc authored Apr 29, 2021
2 parents 1a17862 + f932526 commit f1f8c9a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 7 additions & 0 deletions plex_trakt_sync/commands/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ def sync(sync_option: str, library: str, show: str, movie: str, batch_size: int)
git_version = git_version_info()
if git_version:
logger.info(f"PlexTraktSync [{git_version}]")

if not CONFIG["PLEX_TOKEN"] or not CONFIG["TRAKT_USERNAME"]:
click.echo("First run, please follow those configuration instructions.")
from get_env_data import get_env_data
get_env_data()
CONFIG.initialize()

logger.info(f"Syncing with Plex {CONFIG['PLEX_USERNAME']} and Trakt {CONFIG['TRAKT_USERNAME']}")

movies = sync_option in ["all", "movies"]
Expand Down
10 changes: 2 additions & 8 deletions plex_trakt_sync/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,12 @@ def initialize(self):
config = self.load_json(config_file)
self.update(config)

self.initialized = True

load_dotenv()
if not getenv("PLEX_TOKEN") or not getenv("TRAKT_USERNAME"):
print("First run, please follow those configuration instructions.")
from get_env_data import get_env_data
get_env_data()
load_dotenv()

for key in self.env_keys:
self[key] = getenv(key)

self.initialized = True

def save(self):
with open(env_file, "w") as txt:
txt.write("# This is .env file for PlexTraktSync\n")
Expand Down

0 comments on commit f1f8c9a

Please sign in to comment.