|
4 | 4 | from datetime import date |
5 | 5 | from pydantic import Field |
6 | 6 | from pydantic_settings import BaseSettings |
7 | | -import os |
8 | 7 |
|
9 | 8 | class Settings(BaseSettings): |
10 | 9 | importEHdb_thumb: bool = True |
11 | 10 | importEHdb_matchtitle: Union[bool, str] = Field(default=True, union_mode='left_to_right') |
12 | 11 | importEHdb_matchtorrent: bool = True |
| 12 | + importEHdb_API_DUMP_PATH: str = "api_dump.sqlite" |
13 | 13 | settings = Settings() |
14 | 14 |
|
15 | 15 | import logging |
@@ -39,13 +39,10 @@ class Scanner: |
39 | 39 | Currently only support matching by the source URL (from previous scanners).''' |
40 | 40 |
|
41 | 41 | def __init__(self) -> None: |
42 | | - # Load database from $API_DUMP_PATH when the environment variable is set |
43 | | - # or fallback to api_dump.sqlite in the current directory |
44 | | - api_dump_path = os.getenv('API_DUMP_PATH', default="api_dump.sqlite") |
45 | | - if Path(api_dump_path).exists(): |
| 42 | + if Path(settings.importEHdb_API_DUMP_PATH).exists(): |
46 | 43 | logger.info('Loading ehentai metadata database, please wait...') |
47 | 44 | # do it in readonly mode, to maintain a readonly container image |
48 | | - self.con = sqlite3.connect("file:"+api_dump_path+"?mode=ro", uri=True, check_same_thread=False) |
| 45 | + self.con = sqlite3.connect("file:"+settings.importEHdb_API_DUMP_PATH+"?mode=ro", uri=True, check_same_thread=False) |
49 | 46 | if settings.importEHdb_matchtitle: |
50 | 47 | self.db_title = {blur_title(row[0]): row[1] for row in self.con.execute("SELECT title, gid FROM gallery") if not row[0] is None} |
51 | 48 | self.db_title_jpn = {blur_title(row[0]): row[1] for row in self.con.execute("SELECT title_jpn, gid FROM gallery") if not row[0] is None} |
|
0 commit comments