Skip to content

Commit c02df51

Browse files
committed
Merge branch 'hardcover' of https://github.com/demitrix/Calibre-Web-Automated into hardcover
2 parents fac24c7 + 8f2f4aa commit c02df51

File tree

6 files changed

+29
-13
lines changed

6 files changed

+29
-13
lines changed

root/app/calibre-web/cps/admin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,6 +1870,10 @@ def _configuration_update_helper():
18701870
services.goodreads_support.connect(config.config_goodreads_api_key,
18711871
config.config_use_goodreads)
18721872

1873+
# Hardcover configuration
1874+
_config_checkbox(to_save, "config_use_hardcover")
1875+
_config_string(to_save, "config_hardcover_token")
1876+
18731877
_config_int(to_save, "config_updatechannel")
18741878

18751879
# Reverse proxy login configuration

root/app/calibre-web/cps/config_sql.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ class _Settings(_Base):
118118

119119
config_use_goodreads = Column(Boolean, default=False)
120120
config_goodreads_api_key = Column(String)
121+
config_hardcover_token = Column(String)
122+
121123
config_register_email = Column(Boolean, default=False)
122124
config_login_type = Column(Integer, default=0)
123125

root/app/calibre-web/cps/metadata_provider/hardcover.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from typing import Dict, List, Optional
2121

2222
import requests
23-
from cps import logger
23+
from cps import logger, config
2424
from cps.services.Metadata import MetaRecord, MetaSourceInfo, Metadata
2525
from cps.isoLanguages import get_language_name
2626
from ..cw_login import current_user
@@ -100,7 +100,7 @@ def search(
100100
val = list()
101101
if self.active:
102102
try:
103-
token = current_user.hardcover_token or getenv("HARDCOVER_TOKEN")
103+
token = current_user.hardcover_token or config.config_hardcover_token or getenv("HARDCOVER_TOKEN")
104104
if not token:
105105
self.set_status(False)
106106
raise Exception("Hardcover token not set for user, and no global token provided.")

root/app/calibre-web/cps/templates/book_edit.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ <h4 class="modal-title text-center" id="metaModalLabel">{{_('Fetch Metadata')}}<
271271
alt="Cover"
272272
>
273273
<div class="image-dimensions"></div>
274-
<input type="checkbox" data-meta-index="<%= index %>" data-meta-value="cover">
274+
<input type="checkbox" data-meta-index="<%= index %>" data-meta-value="cover" checked>
275275
</div>
276276
<button class="btn btn-default">Save</button>
277277
<div><a class="meta_source" href="<%= book.source.link %>" target="_blank" rel="noopener"><%= book.source.description %></a></div>
@@ -280,38 +280,38 @@ <h4 class="modal-title text-center" id="metaModalLabel">{{_('Fetch Metadata')}}<
280280
<% } %>
281281
</div>
282282
<dl class="media-body">
283-
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="title">Title:</dt>
283+
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="title" checked>Title:</dt>
284284
<dd><a class="meta_title" href="<%= book.url %>" target="_blank" rel="noopener"><%= book.title %></a></dd>
285-
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="authors">Author:</dt>
285+
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="authors" checked>Author:</dt>
286286
<dd class="meta_author"><%= book.authors.join(" & ") %></dd>
287287
<% if (book.publisher) { %>
288-
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="publisher">Publisher:</dt>
288+
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="publisher" checked>Publisher:</dt>
289289
<dd class="meta_publisher"><%= book.publisher %></dd>
290290
<% } %>
291291
<% if (book.publishedDate) { %>
292-
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="pubDate">Published Date:</dt>
292+
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="pubDate" checked>Published Date:</dt>
293293
<dd class="meta_publishedDate"><%= book.publishedDate %></dd>
294294
<% } %>
295295
<% if (book.series) { %>
296-
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="series">Series:</dt>
296+
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="series" checked>Series:</dt>
297297
<dd class="meta_publishedDate"><%= book.series %></dd>
298298
<% } %>
299299
<% if (book.series_index) { %>
300-
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="seriesIndex">Series Index:</dt>
300+
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="seriesIndex" checked>Series Index:</dt>
301301
<dd class="meta_publishedDate"><%= book.series_index %></dd>
302302
<% } %>
303303
<% if (book.description) { %>
304-
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="description">Description:</dt>
304+
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="description" checked>Description:</dt>
305305
<dd class="meta_description"><%= book.description %></dd>
306306
<% } %>
307307
<% if (book.tags.length !== 0) { %>
308-
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="tags">Tags:</dt>
308+
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="tags" checked>Tags:</dt>
309309
<dd class="meta_author"><%= book.tags.join(", ") %></dd>
310310
<% } %>
311311
<% if (Object.keys(book.identifiers).length !== 0 ) { %>
312312
<% for (const key in book.identifiers) { %>
313313
<% if (book.identifiers[key] !== "") { %>
314-
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="<%= key %>">Identifier</dt>
314+
<dt><input type="checkbox" data-meta-index="<%= index %>" data-meta-value="<%= key %>" checked>Identifier</dt>
315315
<dd class="meta_identifier"><%= key %>:<%= book.identifiers[key] %>
316316
<% if (key === "hardcover-id" && !document.getElementById("keyword").value.includes("hardcover-id")) { %>
317317
<a href="#" data-hardcover-id="<%= book.identifiers[key] %>" ><span class="glyphicon glyphicon-search" style="padding-left: 10px; padding-right: 6px;"></span>Editions</a>

root/app/calibre-web/cps/templates/config_edit.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ <h4 class="panel-title">
167167
</div>
168168
</div>
169169
{% endif %}
170+
<div class="form-group">
171+
<input type="checkbox" id="config_use_hardcover" name="config_use_hardcover" data-control="hardcover-settings" {% if config.config_use_hardcover %}checked{% endif %}>
172+
<label for="config_use_hardcover">{{_('Use Hardcover')}}</label>
173+
</div>
174+
<div data-related="hardcover-settings">
175+
<div class="form-group">
176+
<label for="config_hardcover_token">{{_('Hardcover API Key')}}</label>
177+
<input type="text" class="form-control" id="config_hardcover_token" name="config_hardcover_token" value="{% if config.config_hardcover_token != None %}{{ config.config_hardcover_token }}{% endif %}" autocomplete="off">
178+
</div>
179+
</div>
170180
<div class="form-group">
171181
<input type="checkbox" id="config_allow_reverse_proxy_header_login" name="config_allow_reverse_proxy_header_login" data-control="reverse-proxy-login-settings" {% if config.config_allow_reverse_proxy_header_login %}checked{% endif %}>
172182
<label for="config_allow_reverse_proxy_header_login">{{_('Allow Reverse Proxy Authentication')}}</label>

root/app/calibre-web/cps/web.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ def profile():
15711571
languages = calibre_db.speaking_language()
15721572
translations = get_available_locale()
15731573
kobo_support = feature_support['kobo'] and config.config_kobo_sync
1574-
hardcover_support = feature_support['hardcover'] and config.config_hardcover_sync
1574+
hardcover_support = feature_support['hardcover']
15751575
if feature_support['oauth'] and config.config_login_type == 2:
15761576
oauth_status = get_oauth_status()
15771577
local_oauth_check = oauth_check

0 commit comments

Comments
 (0)