Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 43b2693

Browse files
committed
feat: update mangal to v4, allow updating existing manga metadata
1 parent 9abb2f8 commit 43b2693

File tree

7 files changed

+226
-111
lines changed

7 files changed

+226
-111
lines changed

docker/Dockerfile

+6-4
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ WORKDIR /tmp
5555

5656
RUN \
5757
if [ "$(uname -m)" = "x86_64" ] ; then \
58-
curl -L "https://github.com/metafates/mangal/releases/download/v3.14.2/mangal_3.14.2_Linux_x86_64.tar.gz" -o mangal.tar.gz ;\
58+
curl -L "https://github.com/metafates/mangal/releases/download/v4.0.0/mangal_4.0.0_Linux_x86_64.tar.gz" -o mangal.tar.gz ;\
5959
elif [ "$(uname -m)" = "armv6l" ] ; then \
60-
curl -L "https://github.com/metafates/mangal/releases/download/v3.14.2/mangal_3.14.2_Linux_armv6.tar.gz" -o mangal.tar.gz ;\
60+
curl -L "https://github.com/metafates/mangal/releases/download/v4.0.0/mangal_4.0.0_Linux_armv6.tar.gz" -o mangal.tar.gz ;\
6161
elif [ "$(uname -m)" = "i386" ] ; then \
62-
curl -L "https://github.com/metafates/mangal/releases/download/v3.14.2/mangal_3.14.2_Linux_i386.tar.gz" -o mangal.tar.gz ;\
62+
curl -L "https://github.com/metafates/mangal/releases/download/v4.0.0/mangal_4.0.0_Linux_i386.tar.gz" -o mangal.tar.gz ;\
6363
elif [ "$(uname -m)" = "aarch64" ] ; then \
64-
curl -L "https://github.com/metafates/mangal/releases/download/v3.14.2/mangal_3.14.2_Linux_arm64.tar.gz" -o mangal.tar.gz ;\
64+
curl -L "https://github.com/metafates/mangal/releases/download/v4.0.0/mangal_4.0.0_Linux_arm64.tar.gz" -o mangal.tar.gz ;\
6565
fi
6666
RUN tar xf mangal.tar.gz
6767
RUN mv mangal /usr/bin/mangal
@@ -74,6 +74,8 @@ ENV NEXT_TELEMETRY_DISABLED 1
7474
ENV HOME="/config"
7575
ENV KAIZOKU_LOG_PATH="/logs"
7676
ENV MANGAL_METADATA_COMIC_INFO_XML=true
77+
ENV MANGAL_METADATA_COMIC_INFO_XML_ADD_DATE=true
78+
ENV MANGAL_METADATA_COMIC_INFO_XML_ALTERNATIVE_DATE=true
7779
ENV MANGAL_METADATA_FETCH_ANILIST=true
7880
ENV MANGAL_METADATA_SERIES_JSON=true
7981
ENV MANGAL_FORMATS_USE=cbz

src/components/addLibrary.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function Form({ onClose }: { onClose: () => void }) {
6868
})}
6969
>
7070
<LoadingOverlay visible={visible} overlayBlur={2} />
71-
<TextInput data-autoFocus label="Library path" placeholder="/data" {...form.getInputProps('library.path')} />
71+
<TextInput data-autofocus label="Library path" placeholder="/data" {...form.getInputProps('library.path')} />
7272

7373
<Box
7474
sx={(theme) => ({

src/components/addManga/steps/reviewStep.tsx

+16-16
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ export function ReviewStep({ form }: { form: UseFormReturnType<FormType> }) {
4848

4949
const handleBind = async () => {
5050
setOpened(false);
51-
if (!anilistId || !manga?.Name) {
51+
if (!anilistId || !manga?.name) {
5252
return;
5353
}
5454
await bindMutation.mutateAsync({
5555
anilistId,
56-
title: manga.Name,
56+
title: manga.name,
5757
});
5858

5959
query.refetch();
@@ -82,10 +82,10 @@ export function ReviewStep({ form }: { form: UseFormReturnType<FormType> }) {
8282
boxShadow: theme.shadows.xl,
8383
})}
8484
src="/cover-not-found.jpg"
85-
alt={manga.Name}
85+
alt={manga.name}
8686
/>
8787
}
88-
src={manga.Metadata.Cover}
88+
src={manga.metadata.cover.extraLarge || manga.metadata.cover.large || manga.metadata.cover.medium}
8989
/>
9090
</Grid.Col>
9191
<Grid.Col span={8}>
@@ -94,7 +94,7 @@ export function ReviewStep({ form }: { form: UseFormReturnType<FormType> }) {
9494
labelPosition="center"
9595
label={
9696
<>
97-
<Title order={3}>{manga.Name}</Title>
97+
<Title order={3}>{manga.name}</Title>
9898
<Popover
9999
width={300}
100100
trapFocus
@@ -140,7 +140,7 @@ export function ReviewStep({ form }: { form: UseFormReturnType<FormType> }) {
140140
rightSectionWidth={42}
141141
label={
142142
<Text size="sm" mb="xs">
143-
Please enter a new AniList id for {manga.Name}
143+
Please enter a new AniList id for {manga.name}
144144
</Text>
145145
}
146146
placeholder="AniList Id"
@@ -150,9 +150,9 @@ export function ReviewStep({ form }: { form: UseFormReturnType<FormType> }) {
150150
</>
151151
}
152152
/>
153-
{manga.Metadata.Synonyms && (
153+
{manga.metadata.synonyms && (
154154
<Group spacing="xs">
155-
{manga.Metadata.Synonyms.map((synonym) => (
155+
{manga.metadata.synonyms.map((synonym) => (
156156
<Tooltip label={synonym} key={synonym}>
157157
<div style={{ maxWidth: 100 }}>
158158
<Badge color="blue" variant="filled" size="sm" fullWidth>
@@ -164,9 +164,9 @@ export function ReviewStep({ form }: { form: UseFormReturnType<FormType> }) {
164164
</Group>
165165
)}
166166
<Divider variant="dashed" my="xs" label="Status" />
167-
{manga.Metadata.Status ? (
167+
{manga.metadata.status ? (
168168
<Badge color="cyan" variant="filled" size="sm">
169-
{manga.Metadata.Status}
169+
{manga.metadata.status}
170170
</Badge>
171171
) : (
172172
<Text size="sm">No status...</Text>
@@ -175,16 +175,16 @@ export function ReviewStep({ form }: { form: UseFormReturnType<FormType> }) {
175175
<Text>
176176
There are &nbsp;
177177
<Badge color="teal" variant="outline" size="lg">
178-
{manga.Chapters?.length || 0}
178+
{manga.chapters?.length || 0}
179179
</Badge>
180180
&nbsp; chapters
181181
</Text>
182182
<Divider variant="dashed" my="xs" label="Summary" />
183-
<Text size="sm">{manga.Metadata.Summary || 'No summary...'}</Text>
183+
<Text size="sm">{manga.metadata.summary || 'No summary...'}</Text>
184184
<Divider variant="dashed" my="xs" label="Genres" />
185-
{manga.Metadata.Genres ? (
185+
{manga.metadata.genres ? (
186186
<Group spacing="xs">
187-
{manga.Metadata.Genres.map((genre) => (
187+
{manga.metadata.genres.map((genre) => (
188188
<Tooltip label={genre} key={genre}>
189189
<div style={{ maxWidth: 100 }}>
190190
<Badge color="indigo" variant="light" size="xs" fullWidth>
@@ -198,9 +198,9 @@ export function ReviewStep({ form }: { form: UseFormReturnType<FormType> }) {
198198
<Text size="sm">No genres...</Text>
199199
)}
200200
<Divider variant="dashed" my="xs" label="Tags" />
201-
{manga.Metadata.Tags ? (
201+
{manga.metadata.tags ? (
202202
<Group spacing="xs">
203-
{manga.Metadata.Tags.map((tag) => (
203+
{manga.metadata.tags.map((tag) => (
204204
<Tooltip label={tag} key={tag}>
205205
<div style={{ maxWidth: 100 }}>
206206
<Badge color="violet" variant="light" size="xs" fullWidth>

src/server/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { logger } from '../utils/logging';
77
import { checkChaptersQueue, scheduleAll } from './queue/checkChapters';
88
import { downloadQueue } from './queue/download';
99
import { notificationQueue } from './queue/notify';
10+
import { updateMetadataQueue } from './queue/updateMetadata';
1011

1112
const dev = process.env.NODE_ENV !== 'production';
1213
const app = next({ dev });
@@ -17,7 +18,12 @@ const serverAdapter = new ExpressAdapter();
1718
serverAdapter.setBasePath('/bull/queues');
1819

1920
createBullBoard({
20-
queues: [new BullAdapter(downloadQueue), new BullAdapter(checkChaptersQueue), new BullAdapter(notificationQueue)],
21+
queues: [
22+
new BullAdapter(downloadQueue),
23+
new BullAdapter(checkChaptersQueue),
24+
new BullAdapter(notificationQueue),
25+
new BullAdapter(updateMetadataQueue),
26+
],
2127
serverAdapter,
2228
});
2329

src/server/queue/updateMetadata.ts

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { Job, Queue, Worker } from 'bullmq';
2+
3+
import { getMangaPath, updateExistingMangaMetadata } from '../utils/mangal';
4+
5+
export interface IUpdateMetadataWorkerData {
6+
libraryPath: string;
7+
mangaTitle: string;
8+
}
9+
10+
export const updateMetadataWorker = new Worker(
11+
'updateMetadataQueue',
12+
async (job: Job) => {
13+
const { libraryPath, mangaTitle }: IUpdateMetadataWorkerData = job.data;
14+
try {
15+
await updateExistingMangaMetadata(libraryPath, mangaTitle);
16+
await job.updateProgress(100);
17+
} catch (err) {
18+
await job.log(`${err}`);
19+
throw err;
20+
}
21+
},
22+
{
23+
connection: {
24+
host: process.env.REDIS_HOST,
25+
port: parseInt(process.env.REDIS_PORT || '6379', 10),
26+
},
27+
concurrency: 5,
28+
},
29+
);
30+
31+
export const updateMetadataQueue = new Queue('updateMetadataQueue', {
32+
connection: {
33+
host: process.env.REDIS_HOST,
34+
port: parseInt(process.env.REDIS_PORT || '6379', 10),
35+
},
36+
defaultJobOptions: {
37+
removeOnComplete: true,
38+
attempts: 10,
39+
backoff: {
40+
type: 'fixed',
41+
delay: 1000 * 60 * 2,
42+
},
43+
},
44+
});
45+
46+
export const scheduleUpdateMetadata = async (libraryPath: string, mangaTitle: string) => {
47+
await updateMetadataQueue.add(
48+
getMangaPath(libraryPath, mangaTitle),
49+
{
50+
libraryPath,
51+
mangaTitle,
52+
},
53+
{
54+
jobId: getMangaPath(libraryPath, mangaTitle),
55+
},
56+
);
57+
};

0 commit comments

Comments
 (0)