fixed dlsite-maniax non-image file download process

This commit is contained in:
Nebel 2024-10-26 00:44:29 +09:00
parent 0d280b26fd
commit 4710cbccbd
Signed by: nebel
GPG key ID: 79807D08C6EF6460
3 changed files with 9 additions and 11 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "@fogtype/gadl", "name": "@fogtype/gadl",
"version": "1.6.0", "version": "1.6.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@fogtype/gadl", "name": "@fogtype/gadl",
"version": "1.6.0", "version": "1.6.1",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"dependencies": { "dependencies": {
"fflate": "^0.8.1", "fflate": "^0.8.1",

View file

@ -1,6 +1,6 @@
{ {
"name": "@fogtype/gadl", "name": "@fogtype/gadl",
"version": "1.6.0", "version": "1.6.1",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"type": "module", "type": "module",
"bin": "bin/run.js", "bin": "bin/run.js",

View file

@ -23,16 +23,14 @@ function Reader(page: PageOrFrame, readerUrl: string) {
await page.goto(readerUrl); await page.goto(readerUrl);
}, },
async downloadUrl(): Promise<null | string> { async downloadUrl(): Promise<null | string> {
const isBook = workId.startsWith("B"); const url = `https://www.dlsite.com/home/download/=/product_id/${workId}.html`;
if (isBook) { if (!workId.startsWith("B")) return url;
// PDFファイルでないことを確認
const items = await page.waitForSelector(workTreeItemsSelector);
const text = await items.textContent();
if (!text?.match(/PDF/u)) return null;
}
return `https://www.dlsite.com/home/download/=/product_id/${workId}.html`; const items = await page.waitForSelector(workTreeItemsSelector);
const text = await items.textContent();
return text?.match(/画像/) ? null : url;
}, },
}; };
} }