Skip to content

Commit 3746332

Browse files
Added /config as the HOME env in the ENV variables passed to Calibre to enable plugin functionality
1 parent a10b9b5 commit 3746332

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

scripts/convert_library.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,13 @@ def __init__(self, args) -> None:
9797
self.to_convert = self.get_books_to_convert()
9898

9999
self.calibre_env = os.environ.copy()
100+
# Enables Calibre plugins to be used from /config/plugins
101+
self.calibre_env["HOME"] = "/config"
100102
# Gets split library info from app.db and sets library dir to the split dir if split library is enabled
101103
self.split_library = self.get_split_library()
102104
if self.split_library:
103105
self.library_dir = self.split_library["split_path"]
104-
my_env = os.environ.copy()
105-
my_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(self.split_library["db_path"], "metadata.db")
106-
self.calibre_env = my_env
107-
print(f"[Library Converter] - DEBUG - {my_env['CALIBRE_OVERRIDE_DATABASE_PATH']}")
106+
self.calibre_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(self.split_library["db_path"], "metadata.db")
108107

109108

110109
def get_split_library(self) -> dict[str, str] | None:

scripts/cover_enforcer.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ def __init__(self, book_dir: str, file_path: str):
5151
self.book_title, self.author_name, self.title_author = self.get_title_and_author()
5252

5353
self.calibre_env = os.environ.copy()
54+
# Enables Calibre plugins to be used from /config/plugins
55+
self.calibre_env["HOME"] = "/config"
5456
# Gets split library info from app.db and sets library dir to the split dir if split library is enabled
5557
self.split_library = self.get_split_library()
5658
if self.split_library:
5759
self.calibre_library = self.split_library["split_path"]
58-
my_env = os.environ.copy()
59-
my_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(self.split_library["db_path"], "metadata.db")
60-
self.calibre_env = my_env
61-
print(f"[Book] - DEBUG - {my_env['CALIBRE_OVERRIDE_DATABASE_PATH']}")
60+
self.calibre_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(self.split_library["db_path"], "metadata.db")
6261

6362
self.cover_path = book_dir + '/cover.jpg'
6463
self.old_metadata_path = book_dir + '/metadata.opf'
@@ -141,14 +140,13 @@ def __init__(self, args):
141140
self.illegal_characters = ["<", ">", ":", '"', "/", "\\", "|", "?", "*"]
142141

143142
self.calibre_env = os.environ.copy()
143+
# Enables Calibre plugins to be used from /config/plugins
144+
self.calibre_env["HOME"] = "/config"
144145
# Gets split library info from app.db and sets library dir to the split dir if split library is enabled
145146
self.split_library = self.get_split_library()
146147
if self.split_library:
147148
self.calibre_library = self.split_library["split_path"]
148-
my_env = os.environ.copy()
149-
my_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(self.split_library["db_path"], "metadata.db")
150-
self.calibre_env = my_env
151-
print(f"[enforcer] - DEBUG - {my_env['CALIBRE_OVERRIDE_DATABASE_PATH']}")
149+
self.calibre_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(self.split_library["db_path"], "metadata.db")
152150

153151

154152
def get_split_library(self) -> dict[str, str] | None:

scripts/ingest_processor.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,12 @@ def __init__(self, filepath: str):
7272

7373
# Gets split library info from app.db and sets library dir to the split dir if split library is enabled
7474
self.calibre_env = os.environ.copy()
75+
# Enables Calibre plugins to be used from /config/plugins
76+
self.calibre_env["HOME"] = "/config"
7577
self.split_library = self.get_split_library()
7678
if self.split_library:
7779
self.library_dir = self.split_library["split_path"]
78-
my_env = os.environ.copy()
79-
my_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(self.split_library["db_path"], "metadata.db")
80-
self.calibre_env = my_env
81-
print(f"[New Book Processor] - DEBUG - {my_env['CALIBRE_OVERRIDE_DATABASE_PATH']}")
80+
self.calibre_env['CALIBRE_OVERRIDE_DATABASE_PATH'] = os.path.join(self.split_library["db_path"], "metadata.db")
8281

8382

8483
def get_split_library(self) -> dict[str, str] | None:

0 commit comments

Comments
 (0)