From cd42b95e495cfee9c744bbd647c4f18fc4793e89 Mon Sep 17 00:00:00 2001 From: ducklet Date: Thu, 8 Jul 2021 09:56:37 +0200 Subject: [PATCH] remove imdb users from config, load from db --- unwind/__main__.py | 9 +++++---- unwind/config.py | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/unwind/__main__.py b/unwind/__main__.py index bcc7dd5..24d530e 100644 --- a/unwind/__main__.py +++ b/unwind/__main__.py @@ -4,9 +4,10 @@ import logging from pathlib import Path from . import config -from .db import close_connection_pool, open_connection_pool +from .db import close_connection_pool, get_all, open_connection_pool from .imdb import load_imdb from .imdb_import import import_from_file +from .models import User from .request import session log = logging.getLogger(__name__) @@ -18,9 +19,9 @@ async def run_load_user_ratings_from_imdb(): with session() as s: s.headers["Accept-Language"] = "en-GB, en;q=0.5" - for name, imdb_id in config.imdb.items(): - log.info("Loading data for %s ... ⚡️", name) - await load_imdb(imdb_id) + for user in await get_all(User): + log.info("Loading data for %s ... ⚡️", user.name) + await load_imdb(user.imdb_id) await close_connection_pool() diff --git a/unwind/config.py b/unwind/config.py index b97ebcb..1805cd7 100644 --- a/unwind/config.py +++ b/unwind/config.py @@ -13,5 +13,4 @@ config_path = os.getenv("UNWIND_CONFIG", "./data/config.toml") _config = toml.load(config_path) -imdb = _config["imdb"] api_credentials = _config["api"]["credentials"]