Skip to content

Commit 0ae69bf

Browse files
authored
Fix: Correct support Komga OPDS server
1 parent a8dcfc7 commit 0ae69bf

5 files changed

Lines changed: 62 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1111
- Error opening files from the system file explorer [`cecc15d`](https://github.com/ollm/OpenComic/commit/cecc15d44c15545fddb932ee87d99213015f295e)
1212
- Invert tap zones in manga reading [`08a4d10`](https://github.com/ollm/OpenComic/commit/08a4d10115b4687631bd23695d2accff7933ba81)
1313
- Error opening an OPDS Catalog
14+
- Correct support Komga OPDS server
1415

1516
## [v1.5.0](https://github.com/ollm/OpenComic/releases/tag/v1.5.0) (19-06-2025)
1617

scripts/dom/file-info.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,11 @@ function _parseContributor(metadata, key)
501501
{
502502
for(let i = 0, len = metadata[key].length; i < len; i++)
503503
{
504-
metadata[key].role = key;
505-
metadata.contributor.push(metadata[key]);
504+
if(typeof metadata[key][i] === 'string')
505+
metadata[key][i] = {name: metadata[key][i]};
506+
507+
metadata[key][i].role = key;
508+
metadata.contributor.push(metadata[key][i]);
506509
}
507510
}
508511
}

scripts/opds.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ function getPosterPath(image)
263263
const basename = p.basename(image);
264264
const ext = app.extname(basename).replace(/\?.*/, '');
265265

266-
image = p.join(dirname, opds.btoa(basename)+'.'+ext);
266+
image = p.join(dirname, opds.btoa(basename)+(ext ? '.'+ext : ''));
267267

268-
return image;
268+
return serverClient.fixStart(image);
269269
}
270270

271271
async function getPublicationPosters(feed)
@@ -619,7 +619,7 @@ function getFileName(link)
619619
const fileName = link.publicationTitle || p.parse(basename).name;
620620
const ext = mime.getExtension(link.mime) || app.extname(basename);
621621

622-
return fileName.replace(/[\\\/:*?\"<>|]/g, '')+'.'+ext;
622+
return fileName.replace(/[\\\/:*?\"<>|]/g, '')+(ext ? '.'+ext : '');
623623
}
624624

625625
function addUrlFunctions(items, currentUrl, mainPath)

scripts/opds/opds.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,17 @@ function getSelfLink(links)
191191
return false;
192192
}
193193

194+
function getLinks(data)
195+
{
196+
if(data.links)
197+
return data.links;
198+
199+
if(data.href)
200+
return [data];
201+
202+
return [];
203+
}
204+
194205
function renameSummaryKeyInNavigation(feed)
195206
{
196207
if(feed.navigation)
@@ -236,7 +247,7 @@ function convertPublicationsToFile(feed, path, mainPath, currentUrl)
236247
for(let i = 0, len = feed.groups.length; i < len; i++)
237248
{
238249
const group = feed.groups[i];
239-
const self = getSelfLink(group.links ?? []);
250+
const self = getSelfLink(getLinks(group));
240251

241252
if(self)
242253
{
@@ -250,6 +261,9 @@ function convertPublicationsToFile(feed, path, mainPath, currentUrl)
250261

251262
if(group.publications)
252263
feed.groups[i] = convertPublicationsToFile(group, path, mainPath, currentUrl);
264+
265+
if(group.navigation)
266+
feed.groups[i] = parseUrls(group, path, mainPath, currentUrl);
253267
}
254268
}
255269

@@ -443,9 +457,11 @@ function parseUrls(feed, path, mainPath, currentUrl)
443457

444458
if(facet)
445459
{
446-
for(let j = 0, len2 = facet.links.length; j < len2; j++)
460+
const links = getLinks(facet);
461+
462+
for(let j = 0, len2 = links.length; j < len2; j++)
447463
{
448-
const link = facet.links[j];
464+
const link = links[j];
449465
const rel = getRel(link.rel);
450466
const _base64 = base64(resolveUrl(currentUrl, link.href));
451467

@@ -514,9 +530,11 @@ function base64ToUrl(path)
514530

515531
function getPath(item, currentUrl, mainPath)
516532
{
517-
for(let j = 0, len2 = item.links?.length; j < len2; j++)
533+
const links = getLinks(item);
534+
535+
for(let j = 0, len2 = links?.length; j < len2; j++)
518536
{
519-
const link = item.links[j];
537+
const link = links[j];
520538

521539
if(isOpdsCatalog(link.type))
522540
{

templates/opds.content.right.browse.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,36 @@ <h2 class="headline-small">{{metadata.title}}</h2>
4848
</div>
4949
</div>
5050
{{/if}}
51+
52+
53+
{{#if navigation}}
54+
<div class="opds-browse-groups">
55+
<span class="opds-browse-groups-title">
56+
<div>
57+
<h2 class="headline-small">{{metadata.title}}</h2>
58+
{{#if metadata.description}}<h3 class="body-medium">{{metadata.description}}</h3>{{/if}}
59+
</div>
60+
{{#if path}}
61+
<span>
62+
<div class="simple-button filled-tonal gamepad-item" onclick="dom.loadIndexPage(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', false, false, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}');">
63+
<div class="touch-effect">{{../language.global.viewAll}}{{#if metadata.numberOfItems}} ({{metadata.numberOfItems}}){{/if}}</div>
64+
</div>
65+
</span>
66+
{{/if}}
67+
</span>
68+
<div class="opds-browse-groups-items">
69+
<div class="opds-browse-navigation">
70+
{{#each navigation}}
71+
<div class="opds-browse-navigation-item gamepad-item{{#if @first}} gamepad-to-highlight{{/if}}" onclick="{{#if differentHost}}electron.shell.openExternal('{{chain 'escapeBackSlash' 'escapeQuotesSimples' differentHost}}');{{else}}dom.loadIndexPage(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', false, false, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}');{{/if}}">
72+
<span class="headline-small">{{title}}</span>
73+
{{#if summary}}<span class="body-medium">{{summary}}</span>{{/if}}
74+
</div>
75+
{{/each}}
76+
</div>
77+
</div>
78+
</div>
79+
{{/if}}
80+
5181
{{/each}}
5282
{{/if}}
5383

0 commit comments

Comments
 (0)