Consolidate MangaCircus app, scraper, and Compose baseline

This commit is contained in:
Maashkinoozhe committed 2026-10-07 23:28:20 +02:00
1 parent cfb2d79103
commit eef4ffa07c
103 files changed
+9316 -172

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
'use strict';
// An unnumbered release is not chapter zero. Keep its upstream identity intact.
const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
const SPECIAL = new RegExp(`^special-mangadex-(${UUID})$`, 'i');
const SPECIAL_FOLDER = new RegExp(`^(special-mangadex-${UUID})(?: (.*))?$`, 'i');
const NUMBERED_FOLDER = /^([a-z]*) ?(\d+(?:\.\d+)?)(?=$|[\s_\-[(])[\s_-]*(.*)$/i;
const isSpecialKey = value => SPECIAL.test(String(value));
function specialKey(id) {
const key = `special-mangadex-${String(id).toLowerCase()}`;
if (!isSpecialKey(key)) throw new Error('Unnumbered MangaDex release needs a stable chapter UUID');
return key;
}
function parseSpecialFolder(name) {
const match = SPECIAL_FOLDER.exec(name);
if (!match) return null;
let title = (match[2] || '').trim(), src = '';
const source = /\s*\[([^\]]*)\]$/.exec(title);
if (source) { src = source[1].trim(); title = title.slice(0, source.index).trim(); }
return { key: match[1].toLowerCase(), special: true, x: false, num: null, title, src };
}
// Reader and scraper must assign the same identity to every numbered folder.
function parseKey(name) {
const match = NUMBERED_FOLDER.exec(name);
if (!match) return null;
const x = match[1].toLowerCase() === 'x', num = parseFloat(match[2]);
let title = match[3].trim(), src = '';
const source = /\s*\[([^\]]*)\]$/.exec(title);
if (source) { src = source[1].trim(); title = title.slice(0, source.index).trim(); }
return { key: (x ? 'x' : '') + num, x, num, title: title.replace(/^[-:.]\s*/, ''), src };
}
module.exports = { isSpecialKey, specialKey, parseSpecialFolder, parseKey };