This commit is contained in:
Nebel 2023-12-03 17:35:19 +09:00
parent a53de8e5dd
commit ce0fc9001e
Signed by: nebel
GPG key ID: 79807D08C6EF6460
5 changed files with 43 additions and 9 deletions

View file

@ -3,7 +3,6 @@
## Usage
```
$ npx playwright@1.40.1 install --with-deps chromium
$ npx https://git.fogtype.com/nebel/gadl/archive/main.tar.gz --help
```

39
main.ts
View file

@ -2,24 +2,36 @@ import util from "node:util";
import { createBrowser } from "./browser";
import { createDatabase } from "./database";
import { type Book, createLibrary } from "./library";
import { type TPlatform, createPlatform } from "./platform";
import { type TPlatform, createPlatform, platforms } from "./platform";
import * as pkg from "./package.json";
const options = {
db: {
type: "string",
default: "gadl.db",
toString() {
return `<database_file_path> (default: ${this.default})`;
},
},
"out-dir": {
type: "string",
default: "dist",
toString() {
return `<output_directory_path> (default: ${this.default})`;
},
},
"out-authors-limit": {
type: "string",
default: "3",
toString() {
return `<output_authors_limit> (default: ${this.default})`;
},
},
login: {
type: "string",
toString() {
return [...Object.keys(platforms)].join("|");
},
async run() {
const db = await createDatabase(args.values.db!);
const browser = await createBrowser({ db, headless: false });
@ -34,6 +46,9 @@ const options = {
},
logout: {
type: "string",
toString() {
return [...Object.keys(platforms)].join("|");
},
async run() {
const db = await createDatabase(args.values.db!);
const browser = await createBrowser({ db });
@ -48,6 +63,9 @@ const options = {
},
add: {
type: "string",
toString() {
return `<reader_url_or_id>`;
},
async run() {
const db = await createDatabase(args.values.db!);
const library = createLibrary(db);
@ -56,6 +74,9 @@ const options = {
},
delete: {
type: "string",
toString() {
return `<id>`;
},
async run() {
const db = await createDatabase(args.values.db!);
const library = createLibrary(db);
@ -79,6 +100,9 @@ const options = {
},
view: {
type: "string",
toString() {
return `<reader_url_or_id>`;
},
async run() {
const db = await createDatabase(args.values.db!);
const library = createLibrary(db);
@ -97,6 +121,9 @@ const options = {
},
pull: {
type: "string",
toString() {
return [...Object.keys(platforms)].join("|");
},
async run() {
const db = await createDatabase(args.values.db!);
const library = createLibrary(db);
@ -116,6 +143,9 @@ const options = {
},
download: {
type: "string",
toString() {
return `all|<reader_url_or_id>`;
},
async run() {
const db = await createDatabase(args.values.db!);
const library = createLibrary(db);
@ -170,12 +200,17 @@ const options = {
run() {
console.log(
[
"Usage: gadl [options...]",
` $ npx playwright@${pkg.dependencies.playwright} install --with-deps chromium`,
` $ gadl --login=<platform_type>`,
` $ gadl --download=<reader_url>`,
"",
"Available options:",
...Object.entries(options).map((option) =>
[
` --${option[0]}`,
"short" in option[1] && ` -${option[1].short}`,
option[1].type === "string" && "=<value>",
option[1].type === "string" && `=${option[1]}`,
]
.filter(Boolean)
.join(""),

6
package-lock.json generated
View file

@ -1,16 +1,16 @@
{
"name": "@fogtype/gadl",
"version": "1.3.0",
"version": "1.3.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@fogtype/gadl",
"version": "1.3.0",
"version": "1.3.1",
"license": "AGPL-3.0",
"dependencies": {
"fflate": "^0.8.1",
"playwright": "^1.40.1",
"playwright": "1.40.1",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.6",
"tsx": "^4.6.1"

View file

@ -1,12 +1,12 @@
{
"name": "@fogtype/gadl",
"version": "1.3.0",
"version": "1.3.1",
"license": "AGPL-3.0",
"type": "module",
"bin": "bin/run.js",
"dependencies": {
"fflate": "^0.8.1",
"playwright": "^1.40.1",
"playwright": "1.40.1",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.6",
"tsx": "^4.6.1"

View file

@ -8,7 +8,7 @@ import { DmmBooks } from "./platforms/dmm-books";
import { FanzaDoujin } from "./platforms/fanza-doujin";
import { GooglePlayBooks } from "./platforms/google-play-books";
const platforms = {
export const platforms = {
"dlsite-maniax": DlsiteManiax,
"dmm-books": DmmBooks,
"fanza-doujin": FanzaDoujin,