novel extensions dont appear on manga entry and viceversa

This commit is contained in:
2026-01-01 19:47:28 +01:00
parent d09c769804
commit edb8a93395
10 changed files with 96 additions and 18 deletions

View File

@@ -1,8 +1,6 @@
import { FastifyReply, FastifyRequest } from 'fastify';
import { getExtension, getExtensionsList, getGalleryExtensionsMap, getBookExtensionsMap, getAnimeExtensionsMap, saveExtensionFile, deleteExtensionFile } from '../../shared/extensions';
import { getExtension, getExtensionsList, getGalleryExtensionsMap, getBookExtensionsMap, getMangaExtensionsMap, getNovelExtensionsMap, getAnimeExtensionsMap, saveExtensionFile, deleteExtensionFile } from '../../shared/extensions';
import { ExtensionNameRequest } from '../types';
import path from 'path';
import fs from 'fs/promises';
const TYPE_MAP: Record<string, string> = {
'anime-board': 'anime',
@@ -69,6 +67,16 @@ export async function getBookExtensions(req: FastifyRequest, reply: FastifyReply
return { extensions: Array.from(bookExtensions.keys()) };
}
export async function getMangaExtensions(req: FastifyRequest, reply: FastifyReply) {
const bookExtensions = getMangaExtensionsMap();
return { extensions: Array.from(bookExtensions.keys()) };
}
export async function getNovelExtensions(req: FastifyRequest, reply: FastifyReply) {
const bookExtensions = getNovelExtensionsMap();
return { extensions: Array.from(bookExtensions.keys()) };
}
export async function getGalleryExtensions(req: FastifyRequest, reply: FastifyReply) {
const galleryExtensions = getGalleryExtensionsMap();
return { extensions: Array.from(galleryExtensions.keys()) };

View File

@@ -6,6 +6,8 @@ async function extensionsRoutes(fastify: FastifyInstance) {
fastify.get('/extensions/anime', controller.getAnimeExtensions);
fastify.post('/extensions/update', controller.updateExtensions);
fastify.get('/extensions/book', controller.getBookExtensions);
fastify.get('/extensions/manga', controller.getMangaExtensions);
fastify.get('/extensions/novel', controller.getNovelExtensions);
fastify.get('/extensions/gallery', controller.getGalleryExtensions);
fastify.get('/extensions/:name/settings', controller.getExtensionSettings);
fastify.post('/extensions/install', controller.installExtension);

View File

@@ -499,11 +499,18 @@ async function checkLocalLibraryEntry() {
async function loadAvailableExtensions() {
try {
const res = await fetch('/api/extensions/book');
if (!bookData?.entry_type) return;
console.log(bookData.entry_type)
const type = bookData.entry_type === 'MANGA' ? 'manga' : 'novel';
const res = await fetch(`/api/extensions/${type}`);
const data = await res.json();
availableExtensions = data.extensions || [];
setupProviderFilter();
} catch (err) { console.error(err); }
} catch (err) {
console.error(err);
}
}
function setupProviderFilter() {

View File

@@ -1,4 +1,4 @@
const API_BASE = '/api/config';
const API_BASE2 = '/api/config';
let currentConfig = {};
let currentSchema = {};
let activeSection = '';
@@ -38,7 +38,7 @@ async function loadSettings() {
`;
try {
const res = await fetch(API_BASE);
const res = await fetch(API_BASE2);
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
const data = await res.json();
@@ -172,7 +172,7 @@ async function saveSettings() {
});
try {
const res = await fetch(`${API_BASE}/${activeSection}`, {
const res = await fetch(`${API_BASE2}/${activeSection}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(updatedData)

View File

@@ -194,6 +194,26 @@ function getBookExtensionsMap() {
return bookExts;
}
function getMangaExtensionsMap() {
const mangaExts = new Map();
for (const [name, ext] of extensions) {
if (ext.type === 'book-board' && ext.mediaType !== 'ln') {
mangaExts.set(name, ext);
}
}
return mangaExts;
}
function getNovelExtensionsMap() {
const novelExts = new Map();
for (const [name, ext] of extensions) {
if (ext.type === 'book-board' && ext.mediaType === 'ln') {
novelExts.set(name, ext);
}
}
return novelExts;
}
function getGalleryExtensionsMap() {
const galleryExts = new Map();
for (const [name, ext] of extensions) {
@@ -213,5 +233,7 @@ module.exports = {
getBookExtensionsMap,
getGalleryExtensionsMap,
saveExtensionFile,
deleteExtensionFile
deleteExtensionFile,
getMangaExtensionsMap,
getNovelExtensionsMap
};

View File

@@ -1,8 +1,6 @@
import { FastifyReply, FastifyRequest } from 'fastify';
import { getExtension, getExtensionsList, getGalleryExtensionsMap, getBookExtensionsMap, getAnimeExtensionsMap, saveExtensionFile, deleteExtensionFile } from '../../shared/extensions';
import { getExtension, getExtensionsList, getGalleryExtensionsMap, getBookExtensionsMap, getMangaExtensionsMap, getNovelExtensionsMap, getAnimeExtensionsMap, saveExtensionFile, deleteExtensionFile } from '../../shared/extensions';
import { ExtensionNameRequest } from '../types';
import path from 'path';
import fs from 'fs/promises';
const TYPE_MAP: Record<string, string> = {
'anime-board': 'anime',
@@ -69,6 +67,16 @@ export async function getBookExtensions(req: FastifyRequest, reply: FastifyReply
return { extensions: Array.from(bookExtensions.keys()) };
}
export async function getMangaExtensions(req: FastifyRequest, reply: FastifyReply) {
const bookExtensions = getMangaExtensionsMap();
return { extensions: Array.from(bookExtensions.keys()) };
}
export async function getNovelExtensions(req: FastifyRequest, reply: FastifyReply) {
const bookExtensions = getNovelExtensionsMap();
return { extensions: Array.from(bookExtensions.keys()) };
}
export async function getGalleryExtensions(req: FastifyRequest, reply: FastifyReply) {
const galleryExtensions = getGalleryExtensionsMap();
return { extensions: Array.from(galleryExtensions.keys()) };

View File

@@ -6,6 +6,8 @@ async function extensionsRoutes(fastify: FastifyInstance) {
fastify.get('/extensions/anime', controller.getAnimeExtensions);
fastify.post('/extensions/update', controller.updateExtensions);
fastify.get('/extensions/book', controller.getBookExtensions);
fastify.get('/extensions/manga', controller.getMangaExtensions);
fastify.get('/extensions/novel', controller.getNovelExtensions);
fastify.get('/extensions/gallery', controller.getGalleryExtensions);
fastify.get('/extensions/:name/settings', controller.getExtensionSettings);
fastify.post('/extensions/install', controller.installExtension);

View File

@@ -499,11 +499,18 @@ async function checkLocalLibraryEntry() {
async function loadAvailableExtensions() {
try {
const res = await fetch('/api/extensions/book');
if (!bookData?.entry_type) return;
console.log(bookData.entry_type)
const type = bookData.entry_type === 'MANGA' ? 'manga' : 'novel';
const res = await fetch(`/api/extensions/${type}`);
const data = await res.json();
availableExtensions = data.extensions || [];
setupProviderFilter();
} catch (err) { console.error(err); }
} catch (err) {
console.error(err);
}
}
function setupProviderFilter() {

View File

@@ -1,4 +1,4 @@
const API_BASE = '/api/config';
const API_BASE2 = '/api/config';
let currentConfig = {};
let currentSchema = {};
let activeSection = '';
@@ -38,7 +38,7 @@ async function loadSettings() {
`;
try {
const res = await fetch(API_BASE);
const res = await fetch(API_BASE2);
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
const data = await res.json();
@@ -172,7 +172,7 @@ async function saveSettings() {
});
try {
const res = await fetch(`${API_BASE}/${activeSection}`, {
const res = await fetch(`${API_BASE2}/${activeSection}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(updatedData)

View File

@@ -194,6 +194,26 @@ function getBookExtensionsMap() {
return bookExts;
}
function getMangaExtensionsMap() {
const mangaExts = new Map();
for (const [name, ext] of extensions) {
if (ext.type === 'book-board' && ext.mediaType !== 'ln') {
mangaExts.set(name, ext);
}
}
return mangaExts;
}
function getNovelExtensionsMap() {
const novelExts = new Map();
for (const [name, ext] of extensions) {
if (ext.type === 'book-board' && ext.mediaType === 'ln') {
novelExts.set(name, ext);
}
}
return novelExts;
}
function getGalleryExtensionsMap() {
const galleryExts = new Map();
for (const [name, ext] of extensions) {
@@ -213,5 +233,7 @@ module.exports = {
getBookExtensionsMap,
getGalleryExtensionsMap,
saveExtensionFile,
deleteExtensionFile
deleteExtensionFile,
getMangaExtensionsMap,
getNovelExtensionsMap
};