|
4 | 4 | import re |
5 | 5 | import sys |
6 | 6 | import time |
| 7 | +import sqlite3 |
7 | 8 | from datetime import datetime |
8 | 9 | from pathlib import Path |
9 | 10 |
|
@@ -56,9 +57,18 @@ def __init__(self, book_dir: str, file_path: str): |
56 | 57 |
|
57 | 58 | def get_calibre_library(self) -> str: |
58 | 59 | """Gets Calibre-Library location from dirs_json path""" |
59 | | - with open(dirs_json, 'r') as f: |
60 | | - dirs = json.load(f) |
61 | | - return dirs['calibre_library_dir'] # Returns without / on the end |
| 60 | + con = sqlite3.connect("/config/app.db") |
| 61 | + cur = con.cursor() |
| 62 | + split_library = cur.execute('SELECT config_calibre_split FROM settings;').fetchone()[0] |
| 63 | + |
| 64 | + if split_library: |
| 65 | + split_path = cur.execute('SELECT config_calibre_split_dir FROM settings;').fetchone()[0] |
| 66 | + con.close() |
| 67 | + return split_path |
| 68 | + else: |
| 69 | + with open(dirs_json, 'r') as f: |
| 70 | + dirs = json.load(f) |
| 71 | + return dirs['calibre_library_dir'] # Returns without / on the end |
62 | 72 |
|
63 | 73 |
|
64 | 74 | def get_time(self) -> str: |
@@ -110,9 +120,18 @@ def __init__(self, args): |
110 | 120 |
|
111 | 121 | def get_calibre_library(self) -> str: |
112 | 122 | """Gets Calibre-Library location from dirs_json path""" |
113 | | - with open(dirs_json, 'r') as f: |
114 | | - dirs = json.load(f) |
115 | | - return dirs['calibre_library_dir'] # Returns without / on the end |
| 123 | + con = sqlite3.connect("/config/app.db") |
| 124 | + cur = con.cursor() |
| 125 | + split_library = cur.execute('SELECT config_calibre_split FROM settings;').fetchone()[0] |
| 126 | + |
| 127 | + if split_library: |
| 128 | + split_path = cur.execute('SELECT config_calibre_split_dir FROM settings;').fetchone()[0] |
| 129 | + con.close() |
| 130 | + return split_path |
| 131 | + else: |
| 132 | + with open(dirs_json, 'r') as f: |
| 133 | + dirs = json.load(f) |
| 134 | + return dirs['calibre_library_dir'] # Returns without / on the end |
116 | 135 |
|
117 | 136 | def read_log(self, auto=True, log_path: str = "None") -> dict: |
118 | 137 | """Reads pertinent information from the given log file, adds the book_id from the log name and returns the info as a dict""" |
|
0 commit comments