Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying kepubify arguments #3262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cps/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,7 @@ def _configuration_update_helper():
_config_string(to_save, "config_calibre")
_config_string(to_save, "config_binariesdir")
_config_string(to_save, "config_kepubifypath")
_config_string(to_save, "config_kepubifyopts")
if "config_binariesdir" in to_save:
calibre_status = helper.check_calibre(config.config_binariesdir)
if calibre_status:
Expand Down
1 change: 1 addition & 0 deletions cps/config_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class _Settings(_Base):
config_ldap_group_name = Column(String, default='calibreweb')

config_kepubifypath = Column(String, default=None)
config_kepubifyopts = Column(String)
config_converterpath = Column(String, default=None)
config_binariesdir = Column(String, default=None)
config_calibre = Column(String)
Expand Down
13 changes: 13 additions & 0 deletions cps/tasks/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,20 @@ def _convert_kepubify(self, file_path, format_old_ext, format_new_ext):
filename = file_path + format_old_ext
temp_file_path = os.path.dirname(file_path)
quotes = [1, 3]
quotes_index = 4
command = [config.config_kepubifypath, filename, '-o', temp_file_path, '-i']
if config.config_kepubifyopts:
parameters = re.findall(r"(--[\w-]+)(?:(\s(?:(\".+\")|(?:.+?)))(?:\s|$))?",
config.config_kepubifyopts, re.IGNORECASE | re.UNICODE)
if parameters:
for param in parameters:
command.append(strip_whitespaces(param[0]))
quotes_index += 1
if param[1] != "":
parsed = strip_whitespaces(param[1]).strip("\"")
command.append(parsed)
quotes.append(quotes_index)
quotes_index += 1
try:
p = process_open(command, quotes)
except OSError as e:
Expand Down
4 changes: 4 additions & 0 deletions cps/templates/config_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ <h4 class="panel-title">
<button type="button" id="kepubify_path" data-toggle="modal" data-link="config_kepubifypath" data-target="#fileModal" class="btn btn-default"><span class="glyphicon glyphicon-folder-open"></span></button>
</span>
</div>
<div class="form-group">
<label for="config_kepubifyopts">{{_('Kepubify Settings')}}</label>
<input type="text" class="form-control" id="config_kepubifyopts" name="config_kepubifyopts" value="{% if config.config_kepubifyopts != None %}{{ config.config_kepubifyopts }}{% endif %}" autocomplete="off">
</div>
{% if feature_support['rar'] %}
<label for="config_rarfile_location">{{_('Location of Unrar binary')}}</label>
<div class="form-group input-group">
Expand Down