-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #191
- Loading branch information
Showing
6 changed files
with
123 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
services: | ||
convertx: | ||
build: | ||
context: . | ||
# dockerfile: Debian.Dockerfile | ||
volumes: | ||
- ./data:/app/data | ||
environment: # Defaults are listed below. All are optional. | ||
- ACCOUNT_REGISTRATION=true # true or false, doesn't matter for the first account (e.g. keep this to false if you only want one account) | ||
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default | ||
- HTTP_ALLOWED=true # setting this to true is unsafe, only set this to true locally | ||
- ALLOW_UNAUTHENTICATED=true # allows anyone to use the service without logging in, only set this to true locally | ||
- AUTO_DELETE_EVERY_N_HOURS=1 # checks every n hours for files older then n hours and deletes them, set to 0 to disable | ||
- WEBROOT=/convertx # the root path of the web interface, leave empty to disable | ||
ports: | ||
- 3000:3000 | ||
services: | ||
convertx: | ||
build: | ||
context: . | ||
# dockerfile: Debian.Dockerfile | ||
volumes: | ||
- ./data:/app/data | ||
environment: # Defaults are listed below. All are optional. | ||
- ACCOUNT_REGISTRATION=true # true or false, doesn't matter for the first account (e.g. keep this to false if you only want one account) | ||
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default | ||
- HTTP_ALLOWED=true # setting this to true is unsafe, only set this to true locally | ||
- ALLOW_UNAUTHENTICATED=true # allows anyone to use the service without logging in, only set this to true locally | ||
- AUTO_DELETE_EVERY_N_HOURS=1 # checks every n hours for files older then n hours and deletes them, set to 0 to disable | ||
# - WEBROOT=/convertx # the root path of the web interface, leave empty to disable | ||
ports: | ||
- 3000:3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { exec } from "node:child_process"; | ||
|
||
export const properties = { | ||
from: { | ||
document: [ | ||
"azw4", | ||
"chm", | ||
"cbr", | ||
"cbz", | ||
"cbt", | ||
"cba", | ||
"cb7", | ||
"djvu", | ||
"docx", | ||
"epub", | ||
"fb2", | ||
"htlz", | ||
"html", | ||
"lit", | ||
"lrf", | ||
"mobi", | ||
"odt", | ||
"pdb", | ||
"pdf", | ||
"pml", | ||
"rb", | ||
"rtf", | ||
"recipe", | ||
"snb", | ||
"tcr", | ||
"txt", | ||
], | ||
}, | ||
to: { | ||
document: [ | ||
"azw3", | ||
"docx", | ||
"epub", | ||
"fb2", | ||
"html", | ||
"htmlz", | ||
"lit", | ||
"lrf", | ||
"mobi", | ||
"oeb", | ||
"pdb", | ||
"pdf", | ||
"pml", | ||
"rb", | ||
"rtf", | ||
"snb", | ||
"tcr", | ||
"txt", | ||
"txtz", | ||
], | ||
}, | ||
}; | ||
|
||
export async function convert( | ||
filePath: string, | ||
fileType: string, | ||
convertTo: string, | ||
targetPath: string, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
options?: unknown, | ||
): Promise<string> { | ||
const command = `ebook-convert "${filePath}" "${targetPath}"`; | ||
|
||
return new Promise((resolve, reject) => { | ||
exec(command, (error, stdout, stderr) => { | ||
if (error) { | ||
reject(`error: ${error}`); | ||
} | ||
|
||
if (stdout) { | ||
console.log(`stdout: ${stdout}`); | ||
} | ||
|
||
if (stderr) { | ||
console.error(`stderr: ${stderr}`); | ||
} | ||
|
||
resolve("Done"); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters