Abilty to specify output file name
This commit is contained in:
parent
a89c55ce39
commit
2ff32152dd
4 changed files with 59 additions and 43 deletions
20
.github/workflows/main.yml
vendored
20
.github/workflows/main.yml
vendored
|
@ -67,6 +67,16 @@ jobs:
|
|||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: upload windows artifact
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./Windows Build/DeGourou.exe
|
||||
asset_name: DeGourou-windows.exe
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: upload linux artifact
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
|
@ -86,13 +96,3 @@ jobs:
|
|||
asset_path: ./macOS Build/DeGourou.bin
|
||||
asset_name: DeGourou-macOS.bin
|
||||
asset_content_type: application/gzip
|
||||
|
||||
- name: upload windows artifact
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./Windows Build/DeGourou.exe
|
||||
asset_name: DeGourou-windows.exe
|
||||
asset_content_type: application/zip
|
||||
|
|
29
DeGourou.py
29
DeGourou.py
|
@ -7,12 +7,13 @@ from decrypt.decodeEPUB import decryptEPUB
|
|||
import argparse
|
||||
from os import mkdir, remove, rename
|
||||
from os.path import exists
|
||||
from sys import exit
|
||||
|
||||
from setup.params import FILE_DEVICEKEY, FILE_DEVICEXML, FILE_ACTIVATIONXML
|
||||
from decrypt.params import KEYPATH
|
||||
from setup.data import createDefaultFiles
|
||||
|
||||
def main(acsmFile, login):
|
||||
def main(acsmFile, login, outputFilename):
|
||||
|
||||
# user login
|
||||
if login:
|
||||
|
@ -27,6 +28,8 @@ def main(acsmFile, login):
|
|||
mkdir("account")
|
||||
createDefaultFiles()
|
||||
|
||||
print()
|
||||
|
||||
# cheek for file existance
|
||||
if not exists(acsmFile):
|
||||
print(f"{acsmFile} file does not exist")
|
||||
|
@ -49,18 +52,28 @@ def main(acsmFile, login):
|
|||
exit(1)
|
||||
|
||||
remove(encryptedFile)
|
||||
rename(decryptedFile, encryptedFile)
|
||||
decryptedFile = encryptedFile
|
||||
print(decryptedFile)
|
||||
if outputFilename is None:
|
||||
tempName = encryptedFile
|
||||
else:
|
||||
tempName = outputFilename
|
||||
rename(decryptedFile, tempName)
|
||||
print(tempName)
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Download and Decrypt an encrypted PDF or EPUB file. It uses Dummy account for ADE, you can overide using --login")
|
||||
parser.add_argument("file", type=str, nargs='?', default="URLLink.acsm", help="Path to the ACSM file")
|
||||
parser.add_argument("file", type=str, nargs='?', default=None, help="Path to the ACSM file")
|
||||
parser.add_argument("-l", "--login", action="store_true", help="Login to your ADE account. (optional)")
|
||||
parser.add_argument("-o", "--output", type=str, default=None, help="Output file name. (optional)")
|
||||
args = parser.parse_args()
|
||||
if args.file == "URLLink.acsm" and not exists(args.file):
|
||||
parser.print_help()
|
||||
|
||||
# check for default value
|
||||
if args.file == None:
|
||||
if exists("URLLink.acsm"):
|
||||
args.file = "URLLink.acsm"
|
||||
else:
|
||||
main(args.file, args.login)
|
||||
parser.print_help()
|
||||
exit(0)
|
||||
|
||||
main(args.file, args.login, args.output)
|
||||
|
|
41
README.md
41
README.md
|
@ -12,15 +12,33 @@
|
|||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
usage: DeGourou.xxx [-h] [-l] [-o OUTPUT] [file]
|
||||
|
||||
Download and Decrypt an encrypted PDF or EPUB file. It uses Dummy account for ADE, you can overide using --login
|
||||
|
||||
positional arguments:
|
||||
file Path to the ACSM file
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-l, --login Login to your ADE account. (optional)
|
||||
-o OUTPUT Output file name. (optional)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Guide
|
||||
|
||||
*It uses dummy account for ADE, you can also use your own account*
|
||||
*By default it uses dummy account for ADE, you can also use your own account*
|
||||
### For Normal Users
|
||||
|
||||
1. Download binary file according to your operating system from [Releases Section](https://github.com/bipinkrish/DeGourou/releases)
|
||||
2. Run the binary according to operating system
|
||||
|
||||
A. Windows user's can just simply run the DeGourou-windows.exe
|
||||
A. Windows user's can just open Command Prompt and use based on the [USAGE](https://github.com/bipinkrish/DeGourou#usage)
|
||||
|
||||
B. Linux user's need to change the file permission and then can run
|
||||
|
||||
|
@ -29,7 +47,7 @@
|
|||
./DeGourou-linux
|
||||
```
|
||||
|
||||
C. MacOS user's accordingly
|
||||
C. MacOS user's accordingly with name ```DeGourou.bin```
|
||||
|
||||
### For Developers
|
||||
|
||||
|
@ -47,23 +65,6 @@ python DeGourou.py
|
|||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
usage: DeGourou [-h] [-l] [file]
|
||||
|
||||
Download and Decrypt an encrypted PDF or EPUB file. It uses Dummy account for ADE, you can overide using --login
|
||||
|
||||
positional arguments:
|
||||
file Path to the ACSM file
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-l, --login Login to your ADE account. (optional)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Credits
|
||||
|
||||
This project is highly inspired from these projects, thanks to them
|
||||
|
|
|
@ -58,6 +58,7 @@ def download(replyData):
|
|||
dl_start_time = int(time.time() * 1000)
|
||||
ret = sendHTTPRequest_DL2FILE(download_url, filename_tmp)
|
||||
dl_end_time = int(time.time() * 1000)
|
||||
print()
|
||||
print("Download took %d milliseconds" % (dl_end_time - dl_start_time))
|
||||
|
||||
if (ret != 200):
|
||||
|
@ -84,7 +85,7 @@ def download(replyData):
|
|||
zf = zipfile.ZipFile(filename, "a")
|
||||
zf.writestr("META-INF/rights.xml", rights_xml_str)
|
||||
zf.close()
|
||||
|
||||
print()
|
||||
print("File successfully fulfilled")
|
||||
return filename
|
||||
|
||||
|
@ -100,6 +101,7 @@ def download(replyData):
|
|||
ret = patch_drm_into_pdf("tmp_" + filename, rights_xml_str, filename, resource)
|
||||
os.remove("tmp_" + filename)
|
||||
if (ret):
|
||||
print()
|
||||
print("File successfully fulfilled")
|
||||
return filename
|
||||
else:
|
||||
|
@ -116,14 +118,14 @@ def downloadFile(file="URLLink.acsm"):
|
|||
print("Fulfilling book '" + file + "' ...")
|
||||
success, replyData = fulfill(file)
|
||||
if (success is False):
|
||||
print()
|
||||
print("Hey, that didn't work!")
|
||||
print(replyData)
|
||||
else:
|
||||
print("Downloading book '" + file + "' ...")
|
||||
print()
|
||||
print("Downloading book '" + file + "' with download link")
|
||||
success = download(replyData)
|
||||
if (success is False):
|
||||
print("That didn't work!")
|
||||
else:
|
||||
return success
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue