1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #6060 from thornbill/cb7-support

Add support for cbt and cb7 books
This commit is contained in:
Bill Thornton 2024-09-11 13:51:05 -04:00 committed by GitHub
commit 335870aa26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,6 +9,11 @@ import { PluginType } from '../../types/plugin.ts';
import './style.scss'; 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 { export class ComicsPlayer {
constructor() { constructor() {
this.name = 'Comics Player'; this.name = 'Comics Player';
@ -358,13 +363,10 @@ export class ComicsPlayer {
} }
canPlayItem(item) { 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 { class ArchiveSource {
constructor(url) { constructor(url) {
this.url = url; this.url = url;
@ -389,7 +391,7 @@ class ArchiveSource {
files = files.filter((file) => { files = files.filter((file) => {
const name = file.file.name; const name = file.file.name;
const index = name.lastIndexOf('.'); 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) => { files.sort((a, b) => {
if (a.file.name < b.file.name) { if (a.file.name < b.file.name) {