parent
e4acaa355f
commit
4f2ce0091a
2 changed files with 68 additions and 6 deletions
|
@ -2,8 +2,8 @@ import axios from 'axios';
|
||||||
import { linkSync, mkdirSync, readFileSync, rmSync } from 'fs';
|
import { linkSync, mkdirSync, readFileSync, rmSync } from 'fs';
|
||||||
import { basename } from 'path';
|
import { basename } from 'path';
|
||||||
|
|
||||||
// eslint-disable-next-line
|
import { type Book } from './types';
|
||||||
type Book = any;
|
|
||||||
|
|
||||||
const API = JSON.parse(
|
const API = JSON.parse(
|
||||||
readFileSync(`${process.env.FLAKE}/apps/list2series/.env`, { encoding: 'utf-8' }),
|
readFileSync(`${process.env.FLAKE}/apps/list2series/.env`, { encoding: 'utf-8' }),
|
||||||
|
@ -48,13 +48,17 @@ const getSeriesBooks = async(listName: string, seriesPath: string): Promise<Book
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const seriesId = (series.data.content as Book[]).find((s) => s.url === seriesPath).id;
|
const thisSeries = (series.data.content as Book[]).find((s) => s.url === seriesPath);
|
||||||
|
|
||||||
|
if (!thisSeries) {
|
||||||
|
throw new Error('Series could not be found');
|
||||||
|
}
|
||||||
|
|
||||||
// Reset Series metadata
|
// Reset Series metadata
|
||||||
axios.request({
|
axios.request({
|
||||||
method: 'patch',
|
method: 'patch',
|
||||||
maxBodyLength: Infinity,
|
maxBodyLength: Infinity,
|
||||||
url: `https://komga.nelim.org/api/v1/series/${seriesId}/metadata`,
|
url: `https://komga.nelim.org/api/v1/series/${thisSeries.id}/metadata`,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-API-Key': API,
|
'X-API-Key': API,
|
||||||
|
@ -102,7 +106,7 @@ const getSeriesBooks = async(listName: string, seriesPath: string): Promise<Book
|
||||||
condition: {
|
condition: {
|
||||||
seriesId: {
|
seriesId: {
|
||||||
operator: 'is',
|
operator: 'is',
|
||||||
value: seriesId,
|
value: thisSeries.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
@ -137,7 +141,7 @@ const scanLibrary = async() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const setBookMetadata = async(i: number, source: Book, target: Book) => {
|
const setBookMetadata = async(i: number, source: Book, target: Book) => {
|
||||||
source.metadata.title = `${source.seriesTitle} Issue #${source.number}`;
|
source.metadata.title = `${source.seriesTitle} Issue #${source.metadata.number}`;
|
||||||
source.metadata.number = i.toString();
|
source.metadata.number = i.toString();
|
||||||
source.metadata.numberSort = i;
|
source.metadata.numberSort = i;
|
||||||
|
|
||||||
|
|
58
apps/list2series/src/types.ts
Normal file
58
apps/list2series/src/types.ts
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
export interface Media {
|
||||||
|
status: string
|
||||||
|
mediaType: string
|
||||||
|
pagesCount: number
|
||||||
|
comment: string
|
||||||
|
epubDivinaCompatible: boolean
|
||||||
|
epubIsKepub: boolean
|
||||||
|
mediaProfile: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Author {
|
||||||
|
name: string
|
||||||
|
role: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Metadata {
|
||||||
|
title: string
|
||||||
|
titleLock: boolean
|
||||||
|
summary: string
|
||||||
|
summaryLock: boolean
|
||||||
|
number: string
|
||||||
|
numberLock: boolean
|
||||||
|
numberSort: number
|
||||||
|
numberSortLock: boolean
|
||||||
|
releaseDate: string
|
||||||
|
releaseDateLock: boolean
|
||||||
|
authors: Author[]
|
||||||
|
authorsLock: boolean
|
||||||
|
tags: []
|
||||||
|
tagsLock: boolean
|
||||||
|
isbn: string
|
||||||
|
isbnLock: boolean
|
||||||
|
links: unknown[]
|
||||||
|
linksLock: boolean
|
||||||
|
created: string
|
||||||
|
lastModified: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Book {
|
||||||
|
id: string
|
||||||
|
seriesId: string
|
||||||
|
seriesTitle: string
|
||||||
|
libraryId: string
|
||||||
|
name: string
|
||||||
|
url: string
|
||||||
|
number: number
|
||||||
|
created: string
|
||||||
|
lastModified: string
|
||||||
|
fileLastModified: string
|
||||||
|
sizeBytes: number
|
||||||
|
size: string
|
||||||
|
media: Media
|
||||||
|
metadata: Metadata
|
||||||
|
readProgress: null | unknown
|
||||||
|
deleted: boolean
|
||||||
|
fileHash: string
|
||||||
|
oneshot: boolean
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue