novel extensions dont appear on manga entry and viceversa
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
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 { ExtensionNameRequest } from '../types';
|
||||||
import path from 'path';
|
|
||||||
import fs from 'fs/promises';
|
|
||||||
|
|
||||||
const TYPE_MAP: Record<string, string> = {
|
const TYPE_MAP: Record<string, string> = {
|
||||||
'anime-board': 'anime',
|
'anime-board': 'anime',
|
||||||
@@ -69,6 +67,16 @@ export async function getBookExtensions(req: FastifyRequest, reply: FastifyReply
|
|||||||
return { extensions: Array.from(bookExtensions.keys()) };
|
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) {
|
export async function getGalleryExtensions(req: FastifyRequest, reply: FastifyReply) {
|
||||||
const galleryExtensions = getGalleryExtensionsMap();
|
const galleryExtensions = getGalleryExtensionsMap();
|
||||||
return { extensions: Array.from(galleryExtensions.keys()) };
|
return { extensions: Array.from(galleryExtensions.keys()) };
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ async function extensionsRoutes(fastify: FastifyInstance) {
|
|||||||
fastify.get('/extensions/anime', controller.getAnimeExtensions);
|
fastify.get('/extensions/anime', controller.getAnimeExtensions);
|
||||||
fastify.post('/extensions/update', controller.updateExtensions);
|
fastify.post('/extensions/update', controller.updateExtensions);
|
||||||
fastify.get('/extensions/book', controller.getBookExtensions);
|
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/gallery', controller.getGalleryExtensions);
|
||||||
fastify.get('/extensions/:name/settings', controller.getExtensionSettings);
|
fastify.get('/extensions/:name/settings', controller.getExtensionSettings);
|
||||||
fastify.post('/extensions/install', controller.installExtension);
|
fastify.post('/extensions/install', controller.installExtension);
|
||||||
|
|||||||
@@ -499,11 +499,18 @@ async function checkLocalLibraryEntry() {
|
|||||||
|
|
||||||
async function loadAvailableExtensions() {
|
async function loadAvailableExtensions() {
|
||||||
try {
|
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();
|
const data = await res.json();
|
||||||
|
|
||||||
availableExtensions = data.extensions || [];
|
availableExtensions = data.extensions || [];
|
||||||
setupProviderFilter();
|
setupProviderFilter();
|
||||||
} catch (err) { console.error(err); }
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupProviderFilter() {
|
function setupProviderFilter() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const API_BASE = '/api/config';
|
const API_BASE2 = '/api/config';
|
||||||
let currentConfig = {};
|
let currentConfig = {};
|
||||||
let currentSchema = {};
|
let currentSchema = {};
|
||||||
let activeSection = '';
|
let activeSection = '';
|
||||||
@@ -38,7 +38,7 @@ async function loadSettings() {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(API_BASE);
|
const res = await fetch(API_BASE2);
|
||||||
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
|
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
@@ -172,7 +172,7 @@ async function saveSettings() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_BASE}/${activeSection}`, {
|
const res = await fetch(`${API_BASE2}/${activeSection}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(updatedData)
|
body: JSON.stringify(updatedData)
|
||||||
|
|||||||
@@ -194,6 +194,26 @@ function getBookExtensionsMap() {
|
|||||||
return bookExts;
|
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() {
|
function getGalleryExtensionsMap() {
|
||||||
const galleryExts = new Map();
|
const galleryExts = new Map();
|
||||||
for (const [name, ext] of extensions) {
|
for (const [name, ext] of extensions) {
|
||||||
@@ -213,5 +233,7 @@ module.exports = {
|
|||||||
getBookExtensionsMap,
|
getBookExtensionsMap,
|
||||||
getGalleryExtensionsMap,
|
getGalleryExtensionsMap,
|
||||||
saveExtensionFile,
|
saveExtensionFile,
|
||||||
deleteExtensionFile
|
deleteExtensionFile,
|
||||||
|
getMangaExtensionsMap,
|
||||||
|
getNovelExtensionsMap
|
||||||
};
|
};
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
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 { ExtensionNameRequest } from '../types';
|
||||||
import path from 'path';
|
|
||||||
import fs from 'fs/promises';
|
|
||||||
|
|
||||||
const TYPE_MAP: Record<string, string> = {
|
const TYPE_MAP: Record<string, string> = {
|
||||||
'anime-board': 'anime',
|
'anime-board': 'anime',
|
||||||
@@ -69,6 +67,16 @@ export async function getBookExtensions(req: FastifyRequest, reply: FastifyReply
|
|||||||
return { extensions: Array.from(bookExtensions.keys()) };
|
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) {
|
export async function getGalleryExtensions(req: FastifyRequest, reply: FastifyReply) {
|
||||||
const galleryExtensions = getGalleryExtensionsMap();
|
const galleryExtensions = getGalleryExtensionsMap();
|
||||||
return { extensions: Array.from(galleryExtensions.keys()) };
|
return { extensions: Array.from(galleryExtensions.keys()) };
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ async function extensionsRoutes(fastify: FastifyInstance) {
|
|||||||
fastify.get('/extensions/anime', controller.getAnimeExtensions);
|
fastify.get('/extensions/anime', controller.getAnimeExtensions);
|
||||||
fastify.post('/extensions/update', controller.updateExtensions);
|
fastify.post('/extensions/update', controller.updateExtensions);
|
||||||
fastify.get('/extensions/book', controller.getBookExtensions);
|
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/gallery', controller.getGalleryExtensions);
|
||||||
fastify.get('/extensions/:name/settings', controller.getExtensionSettings);
|
fastify.get('/extensions/:name/settings', controller.getExtensionSettings);
|
||||||
fastify.post('/extensions/install', controller.installExtension);
|
fastify.post('/extensions/install', controller.installExtension);
|
||||||
|
|||||||
@@ -499,11 +499,18 @@ async function checkLocalLibraryEntry() {
|
|||||||
|
|
||||||
async function loadAvailableExtensions() {
|
async function loadAvailableExtensions() {
|
||||||
try {
|
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();
|
const data = await res.json();
|
||||||
|
|
||||||
availableExtensions = data.extensions || [];
|
availableExtensions = data.extensions || [];
|
||||||
setupProviderFilter();
|
setupProviderFilter();
|
||||||
} catch (err) { console.error(err); }
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupProviderFilter() {
|
function setupProviderFilter() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const API_BASE = '/api/config';
|
const API_BASE2 = '/api/config';
|
||||||
let currentConfig = {};
|
let currentConfig = {};
|
||||||
let currentSchema = {};
|
let currentSchema = {};
|
||||||
let activeSection = '';
|
let activeSection = '';
|
||||||
@@ -38,7 +38,7 @@ async function loadSettings() {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(API_BASE);
|
const res = await fetch(API_BASE2);
|
||||||
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
|
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
@@ -172,7 +172,7 @@ async function saveSettings() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_BASE}/${activeSection}`, {
|
const res = await fetch(`${API_BASE2}/${activeSection}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(updatedData)
|
body: JSON.stringify(updatedData)
|
||||||
|
|||||||
@@ -194,6 +194,26 @@ function getBookExtensionsMap() {
|
|||||||
return bookExts;
|
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() {
|
function getGalleryExtensionsMap() {
|
||||||
const galleryExts = new Map();
|
const galleryExts = new Map();
|
||||||
for (const [name, ext] of extensions) {
|
for (const [name, ext] of extensions) {
|
||||||
@@ -213,5 +233,7 @@ module.exports = {
|
|||||||
getBookExtensionsMap,
|
getBookExtensionsMap,
|
||||||
getGalleryExtensionsMap,
|
getGalleryExtensionsMap,
|
||||||
saveExtensionFile,
|
saveExtensionFile,
|
||||||
deleteExtensionFile
|
deleteExtensionFile,
|
||||||
|
getMangaExtensionsMap,
|
||||||
|
getNovelExtensionsMap
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user