Abilty to specify output file name

This commit is contained in:
bipinkrish 2023-02-24 16:16:01 +05:30
parent a89c55ce39
commit 2ff32152dd
4 changed files with 59 additions and 43 deletions

View file

@ -67,6 +67,16 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ github.token }} 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 - name: upload linux artifact
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
env: env:
@ -86,13 +96,3 @@ jobs:
asset_path: ./macOS Build/DeGourou.bin asset_path: ./macOS Build/DeGourou.bin
asset_name: DeGourou-macOS.bin asset_name: DeGourou-macOS.bin
asset_content_type: application/gzip 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

View file

@ -7,12 +7,13 @@ from decrypt.decodeEPUB import decryptEPUB
import argparse import argparse
from os import mkdir, remove, rename from os import mkdir, remove, rename
from os.path import exists from os.path import exists
from sys import exit
from setup.params import FILE_DEVICEKEY, FILE_DEVICEXML, FILE_ACTIVATIONXML from setup.params import FILE_DEVICEKEY, FILE_DEVICEXML, FILE_ACTIVATIONXML
from decrypt.params import KEYPATH from decrypt.params import KEYPATH
from setup.data import createDefaultFiles from setup.data import createDefaultFiles
def main(acsmFile, login): def main(acsmFile, login, outputFilename):
# user login # user login
if login: if login:
@ -27,6 +28,8 @@ def main(acsmFile, login):
mkdir("account") mkdir("account")
createDefaultFiles() createDefaultFiles()
print()
# cheek for file existance # cheek for file existance
if not exists(acsmFile): if not exists(acsmFile):
print(f"{acsmFile} file does not exist") print(f"{acsmFile} file does not exist")
@ -49,18 +52,28 @@ def main(acsmFile, login):
exit(1) exit(1)
remove(encryptedFile) remove(encryptedFile)
rename(decryptedFile, encryptedFile) if outputFilename is None:
decryptedFile = encryptedFile tempName = encryptedFile
print(decryptedFile) else:
tempName = outputFilename
rename(decryptedFile, tempName)
print(tempName)
print() print()
if __name__ == "__main__": 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 = 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("-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() args = parser.parse_args()
if args.file == "URLLink.acsm" and not exists(args.file):
parser.print_help() # check for default value
else: if args.file == None:
main(args.file, args.login) if exists("URLLink.acsm"):
args.file = "URLLink.acsm"
else:
parser.print_help()
exit(0)
main(args.file, args.login, args.output)

View file

@ -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 ## 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 ### For Normal Users
1. Download binary file according to your operating system from [Releases Section](https://github.com/bipinkrish/DeGourou/releases) 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 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 B. Linux user's need to change the file permission and then can run
@ -29,7 +47,7 @@
./DeGourou-linux ./DeGourou-linux
``` ```
C. MacOS user's accordingly C. MacOS user's accordingly with name ```DeGourou.bin```
### For Developers ### 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 ## Credits
This project is highly inspired from these projects, thanks to them This project is highly inspired from these projects, thanks to them

View file

@ -58,6 +58,7 @@ def download(replyData):
dl_start_time = int(time.time() * 1000) dl_start_time = int(time.time() * 1000)
ret = sendHTTPRequest_DL2FILE(download_url, filename_tmp) ret = sendHTTPRequest_DL2FILE(download_url, filename_tmp)
dl_end_time = int(time.time() * 1000) dl_end_time = int(time.time() * 1000)
print()
print("Download took %d milliseconds" % (dl_end_time - dl_start_time)) print("Download took %d milliseconds" % (dl_end_time - dl_start_time))
if (ret != 200): if (ret != 200):
@ -84,7 +85,7 @@ def download(replyData):
zf = zipfile.ZipFile(filename, "a") zf = zipfile.ZipFile(filename, "a")
zf.writestr("META-INF/rights.xml", rights_xml_str) zf.writestr("META-INF/rights.xml", rights_xml_str)
zf.close() zf.close()
print()
print("File successfully fulfilled") print("File successfully fulfilled")
return filename return filename
@ -100,6 +101,7 @@ def download(replyData):
ret = patch_drm_into_pdf("tmp_" + filename, rights_xml_str, filename, resource) ret = patch_drm_into_pdf("tmp_" + filename, rights_xml_str, filename, resource)
os.remove("tmp_" + filename) os.remove("tmp_" + filename)
if (ret): if (ret):
print()
print("File successfully fulfilled") print("File successfully fulfilled")
return filename return filename
else: else:
@ -116,14 +118,14 @@ def downloadFile(file="URLLink.acsm"):
print("Fulfilling book '" + file + "' ...") print("Fulfilling book '" + file + "' ...")
success, replyData = fulfill(file) success, replyData = fulfill(file)
if (success is False): if (success is False):
print()
print("Hey, that didn't work!") print("Hey, that didn't work!")
print(replyData) print(replyData)
else: else:
print("Downloading book '" + file + "' ...") print()
print("Downloading book '" + file + "' with download link")
success = download(replyData) success = download(replyData)
if (success is False): if (success is False):
print("That didn't work!") print("That didn't work!")
else: else:
return success return success