Skip to content

Commit

Permalink
Fix Calibre on macOS
Browse files Browse the repository at this point in the history
Fix #2192
Changed path to calibre executable file on macOS
  • Loading branch information
CryZFix committed Nov 24, 2023
1 parent 9041a7d commit 9be218a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lncrawl/binders/calibre.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
import os
import platform
import subprocess
from typing import Union, List
logger = logging.getLogger(__name__)
EBOOK_CONVERT = "ebook-convert"
CALIBRE_LINK = "https://calibre-ebook.com/download"


Expand All @@ -12,11 +12,17 @@ def run_ebook_convert(*args) -> bool:
Calls `ebook-convert` with given args
Visit https://manual.calibre-ebook.com/generated/en/ebook-convert.html for argument list.
"""
os_name = platform.platform()
if "macOS" in os_name:
ebook_convert = "/Applications/calibre.app/Contents/MacOS/ebook-convert"
else:
ebook_convert = "ebook-convert"

try:
isdebug = os.getenv("debug_mode")
with open(os.devnull, "w", encoding="utf8") as dumper:
subprocess.run(
args=[EBOOK_CONVERT] + list(args),
args=[ebook_convert] + list(args),
stdout=None if isdebug else dumper,
stderr=None if isdebug else dumper,
check=True
Expand Down

0 comments on commit 9be218a

Please sign in to comment.