usage
This commit is contained in:
parent
a53de8e5dd
commit
ce0fc9001e
5 changed files with 43 additions and 9 deletions
|
@ -3,7 +3,6 @@
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
$ npx playwright@1.40.1 install --with-deps chromium
|
|
||||||
$ npx https://git.fogtype.com/nebel/gadl/archive/main.tar.gz --help
|
$ npx https://git.fogtype.com/nebel/gadl/archive/main.tar.gz --help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
39
main.ts
39
main.ts
|
@ -2,24 +2,36 @@ import util from "node:util";
|
||||||
import { createBrowser } from "./browser";
|
import { createBrowser } from "./browser";
|
||||||
import { createDatabase } from "./database";
|
import { createDatabase } from "./database";
|
||||||
import { type Book, createLibrary } from "./library";
|
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";
|
import * as pkg from "./package.json";
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
db: {
|
db: {
|
||||||
type: "string",
|
type: "string",
|
||||||
default: "gadl.db",
|
default: "gadl.db",
|
||||||
|
toString() {
|
||||||
|
return `<database_file_path> (default: ${this.default})`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"out-dir": {
|
"out-dir": {
|
||||||
type: "string",
|
type: "string",
|
||||||
default: "dist",
|
default: "dist",
|
||||||
|
toString() {
|
||||||
|
return `<output_directory_path> (default: ${this.default})`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"out-authors-limit": {
|
"out-authors-limit": {
|
||||||
type: "string",
|
type: "string",
|
||||||
default: "3",
|
default: "3",
|
||||||
|
toString() {
|
||||||
|
return `<output_authors_limit> (default: ${this.default})`;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
login: {
|
login: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
toString() {
|
||||||
|
return [...Object.keys(platforms)].join("|");
|
||||||
|
},
|
||||||
async run() {
|
async run() {
|
||||||
const db = await createDatabase(args.values.db!);
|
const db = await createDatabase(args.values.db!);
|
||||||
const browser = await createBrowser({ db, headless: false });
|
const browser = await createBrowser({ db, headless: false });
|
||||||
|
@ -34,6 +46,9 @@ const options = {
|
||||||
},
|
},
|
||||||
logout: {
|
logout: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
toString() {
|
||||||
|
return [...Object.keys(platforms)].join("|");
|
||||||
|
},
|
||||||
async run() {
|
async run() {
|
||||||
const db = await createDatabase(args.values.db!);
|
const db = await createDatabase(args.values.db!);
|
||||||
const browser = await createBrowser({ db });
|
const browser = await createBrowser({ db });
|
||||||
|
@ -48,6 +63,9 @@ const options = {
|
||||||
},
|
},
|
||||||
add: {
|
add: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
toString() {
|
||||||
|
return `<reader_url_or_id>`;
|
||||||
|
},
|
||||||
async run() {
|
async run() {
|
||||||
const db = await createDatabase(args.values.db!);
|
const db = await createDatabase(args.values.db!);
|
||||||
const library = createLibrary(db);
|
const library = createLibrary(db);
|
||||||
|
@ -56,6 +74,9 @@ const options = {
|
||||||
},
|
},
|
||||||
delete: {
|
delete: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
toString() {
|
||||||
|
return `<id>`;
|
||||||
|
},
|
||||||
async run() {
|
async run() {
|
||||||
const db = await createDatabase(args.values.db!);
|
const db = await createDatabase(args.values.db!);
|
||||||
const library = createLibrary(db);
|
const library = createLibrary(db);
|
||||||
|
@ -79,6 +100,9 @@ const options = {
|
||||||
},
|
},
|
||||||
view: {
|
view: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
toString() {
|
||||||
|
return `<reader_url_or_id>`;
|
||||||
|
},
|
||||||
async run() {
|
async run() {
|
||||||
const db = await createDatabase(args.values.db!);
|
const db = await createDatabase(args.values.db!);
|
||||||
const library = createLibrary(db);
|
const library = createLibrary(db);
|
||||||
|
@ -97,6 +121,9 @@ const options = {
|
||||||
},
|
},
|
||||||
pull: {
|
pull: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
toString() {
|
||||||
|
return [...Object.keys(platforms)].join("|");
|
||||||
|
},
|
||||||
async run() {
|
async run() {
|
||||||
const db = await createDatabase(args.values.db!);
|
const db = await createDatabase(args.values.db!);
|
||||||
const library = createLibrary(db);
|
const library = createLibrary(db);
|
||||||
|
@ -116,6 +143,9 @@ const options = {
|
||||||
},
|
},
|
||||||
download: {
|
download: {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
toString() {
|
||||||
|
return `all|<reader_url_or_id>`;
|
||||||
|
},
|
||||||
async run() {
|
async run() {
|
||||||
const db = await createDatabase(args.values.db!);
|
const db = await createDatabase(args.values.db!);
|
||||||
const library = createLibrary(db);
|
const library = createLibrary(db);
|
||||||
|
@ -170,12 +200,17 @@ const options = {
|
||||||
run() {
|
run() {
|
||||||
console.log(
|
console.log(
|
||||||
[
|
[
|
||||||
|
"Usage: gadl [options...]",
|
||||||
|
` $ npx playwright@${pkg.dependencies.playwright} install --with-deps chromium`,
|
||||||
|
` $ gadl --login=<platform_type>`,
|
||||||
|
` $ gadl --download=<reader_url>`,
|
||||||
|
"",
|
||||||
"Available options:",
|
"Available options:",
|
||||||
...Object.entries(options).map((option) =>
|
...Object.entries(options).map((option) =>
|
||||||
[
|
[
|
||||||
` --${option[0]}`,
|
` --${option[0]}`,
|
||||||
"short" in option[1] && ` -${option[1].short}`,
|
"short" in option[1] && ` -${option[1].short}`,
|
||||||
option[1].type === "string" && "=<value>",
|
option[1].type === "string" && `=${option[1]}`,
|
||||||
]
|
]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join(""),
|
.join(""),
|
||||||
|
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -1,16 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "@fogtype/gadl",
|
"name": "@fogtype/gadl",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@fogtype/gadl",
|
"name": "@fogtype/gadl",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fflate": "^0.8.1",
|
"fflate": "^0.8.1",
|
||||||
"playwright": "^1.40.1",
|
"playwright": "1.40.1",
|
||||||
"sqlite": "^5.1.1",
|
"sqlite": "^5.1.1",
|
||||||
"sqlite3": "^5.1.6",
|
"sqlite3": "^5.1.6",
|
||||||
"tsx": "^4.6.1"
|
"tsx": "^4.6.1"
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@fogtype/gadl",
|
"name": "@fogtype/gadl",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": "bin/run.js",
|
"bin": "bin/run.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fflate": "^0.8.1",
|
"fflate": "^0.8.1",
|
||||||
"playwright": "^1.40.1",
|
"playwright": "1.40.1",
|
||||||
"sqlite": "^5.1.1",
|
"sqlite": "^5.1.1",
|
||||||
"sqlite3": "^5.1.6",
|
"sqlite3": "^5.1.6",
|
||||||
"tsx": "^4.6.1"
|
"tsx": "^4.6.1"
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { DmmBooks } from "./platforms/dmm-books";
|
||||||
import { FanzaDoujin } from "./platforms/fanza-doujin";
|
import { FanzaDoujin } from "./platforms/fanza-doujin";
|
||||||
import { GooglePlayBooks } from "./platforms/google-play-books";
|
import { GooglePlayBooks } from "./platforms/google-play-books";
|
||||||
|
|
||||||
const platforms = {
|
export const platforms = {
|
||||||
"dlsite-maniax": DlsiteManiax,
|
"dlsite-maniax": DlsiteManiax,
|
||||||
"dmm-books": DmmBooks,
|
"dmm-books": DmmBooks,
|
||||||
"fanza-doujin": FanzaDoujin,
|
"fanza-doujin": FanzaDoujin,
|
||||||
|
|
Loading…
Add table
Reference in a new issue