Skip to content

Commit

Permalink
Merge pull request #6060 from thornbill/cb7-support
Browse files Browse the repository at this point in the history
Add support for cbt and cb7 books
  • Loading branch information
thornbill authored Sep 11, 2024
2 parents 462d5ac + da6e3d1 commit 335870a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/plugins/comicsPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import { PluginType } from '../../types/plugin.ts';

import './style.scss';

// supported book file extensions
const FILE_EXTENSIONS = ['.cbr', '.cbt', '.cbz', '.cb7'];
// the comic book archive supports any kind of image format as it's just a zip archive
const IMAGE_FORMATS = ['jpg', 'jpeg', 'jpe', 'jif', 'jfif', 'jfi', 'png', 'avif', 'gif', 'bmp', 'dib', 'tiff', 'tif', 'webp'];

export class ComicsPlayer {
constructor() {
this.name = 'Comics Player';
Expand Down Expand Up @@ -358,13 +363,10 @@ export class ComicsPlayer {
}

canPlayItem(item) {
return item.Path && (item.Path.endsWith('cbz') || item.Path.endsWith('cbr'));
return item.Path && FILE_EXTENSIONS.some(ext => item.Path.endsWith(ext));
}
}

// the comic book archive supports any kind of image format as it's just a zip archive
const supportedFormats = ['jpg', 'jpeg', 'jpe', 'jif', 'jfif', 'jfi', 'png', 'avif', 'gif', 'bmp', 'dib', 'tiff', 'tif', 'webp'];

class ArchiveSource {
constructor(url) {
this.url = url;
Expand All @@ -389,7 +391,7 @@ class ArchiveSource {
files = files.filter((file) => {
const name = file.file.name;
const index = name.lastIndexOf('.');
return index !== -1 && supportedFormats.includes(name.slice(index + 1));
return index !== -1 && IMAGE_FORMATS.includes(name.slice(index + 1));
});
files.sort((a, b) => {
if (a.file.name < b.file.name) {
Expand Down

0 comments on commit 335870a

Please sign in to comment.