Skip to content

Commit

Permalink
Merge pull request #10 from bcliang/release-v0.8.1
Browse files Browse the repository at this point in the history
Release v0.8.1
  • Loading branch information
bcliang committed Jan 19, 2023
2 parents bd4fa36 + f4fc601 commit 250ffe1
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
bin/
adobe/
Adobe-Digital-Editions/
.adobe-digital-editions/
.adept/

# ignore data files
*.acsm
*.pdf
*.epub
*.drm
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN apt-get update && \
libzip-dev \
libssl-dev \
libcurl4-gnutls-dev \
libpugixml-dev \
&& apt-get autoclean \
&& rm -rf /var/lib/apt/lists/*

Expand Down
51 changes: 29 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ By default, the container will process an inputted *.acsm file ($1) through both
```

Notes:
1. The shell script assumes that activated device configuration files (via Adobe ID credentials) have been mounted in the home directory (e.g. in `/home/libgourou`, `/home/libgourou/.adept/`, or `/home/libgourou/adobe-digital-editions/`).
2. To generate ADEPT configuration files (`activation.xml`, `devicesalt`, `device.xml`), use the interactive terminal and run the `adept_activate` utility
1. The shell script assumes that activated device configuration files (via Adobe ID credentials) have been mounted into `/home/libgourou` (alternates: `/home/libgourou/.adept/`, `/home/libgourou/adobe-digital-editions/`, etc.).
2. To generate ADEPT configuration files (`activation.xml`, `devicesalt`, `device.xml`), use the interactive terminal and run the `adept_activate` utility.

### Interactive Terminal

To manually run libgourou utils, run the container interactively and overide the docker entrypoint :
To manually run libgourou utils, run the container interactively and overide the docker entrypoint:
```bash
> docker run \
-v {$PATH_TO_ADOBE_CREDS}:/home/libgourou/.adept \
Expand All @@ -62,25 +62,25 @@ To manually run libgourou utils, run the container interactively and overide the

#### Commands

Use the bash shell to run the libgourou utility scripts. See the `libgourou` [README](https://indefero.soutade.fr/p/libgourou/source/tree/master/README.md) for additional notes.
Use the bash shell to run the libgourou utility scripts. See the `libgourou` [README](https://indefero.soutade.fr/p/libgourou/source/tree/master/README.md) and/or the included manpages for additional usage.

To activate a new device with a AdobeID :
```
adept_activate -u <AdobeID USERNAME> [--output-dir output_directory]
```
By default, configuration files will be saved in `/home/libgourou/.adept`. Save contents to a mounted volume for reuse at a later date.
By default, configuration files will be saved in `/home/libgourou/.adept`. Users should save contents to a mounted volume for reuse at a later date.

To download an ePub/PDF :
```
acsmdownloader -f <ACSM_FILE>
acsmdownloader <ACSM_FILE>
```
To export your private key (for use with Calibre, for example) :
```
acsmdownloader --export-private-key [-o adobekey_1.der]
```
To remove ADEPT DRM :
```
adept_remove -f <encryptedFile>
adept_remove <encrypted_file>
```
To list loaned books :
```
Expand All @@ -103,35 +103,42 @@ A "de-DRM" bash script is provided (`./scripts/dedrm.sh`) to simplify running an
To launch an interactive terminal with access to the libgourou utils:
```bash
> dedrm
!!!
!!! WARNING: no ADEPT keys detected (argument $2, or "$(pwd)/.adept").
!!! WARNING: no ADEPT keys detected (argument $2, or "/home/brad/.config/adept").
!!! Launching interactive terminal for credentials creation (device activation). Run this:
!!!
!!! adept_activate -r --username {USERNAME} --password {PASSWORD} --output-dir files/.adept
!!!

> adept_activate --random-serial \
--username {USERNAME} \
--password {PASSWORD} \
--output-dir files/adept

!!! (*) use --anonymous in place of --username, --password if you do not have an ADE account.
!!! (*) credentials will be saved in your current path in the folder "$(pwd)/.adept"
!!!
!!!
!!! (*) credentials will be saved in the following path: "/home/brad/repos/docker-libgourou/adept"

!!! WARNING: no ACSM file detected (argument $1).
!!! Launching interactive terminal for manual loan management. Example commands below:
!!!
!!! acsmdownloader -f "./files/{ACSM_FILE}" -o output.drm
!!! adept_remove -v -f output.drm -o "/home/libgourou/files/{OUTPUT_FILE}"
!!!

> acsmdownloader \
--adept-directory .adept \
--output-file encrypted_file.drm \
"files/{ACSM_FILE}"
> adept_remove \
--adept-directory .adept \
--output-dir files \
--output-file "{OUTPUT_FILE}" \
encrypted_file.drm

Mounted Volumes
(current path e.g. $pwd) --> /home/libgourou/files/

username@..:/home/libgourou#
root@..:/home/libgourou#
```
To generate a DRM-removed PDF/ePub file (this simply replicates the command at the top of this section):
If you already have ADEPT keys saved (i.e. in `.adept` or `~/.config/adept`), append the encrypted ACSM file path in order to automatically generate a DRM-removed PDF/ePub file (this simply replicates the command at the top of this section):
```bash
> dedrm {ACSM_FILE}
```
To generate a DRM-free PDF/ePub file using credentials in a specific directory:
To generate a DRM-free PDF/ePub file using credentials in a specific path:
```bash
> dedrm {ACSM_FILE} {CREDENTIALS_PATH}
```
41 changes: 24 additions & 17 deletions scripts/dedrm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

ACSM_FILE=$1
KEY_PATH=$2
HOME_DIR="$(getent passwd $USER | awk -F ':' '{print $6}')"

# Docker container needs a well-defined path for mounting volumes (paths should start with /* or ./*).
# Check $KEY_PATH and attempt to convert relative paths when necessary
Expand All @@ -14,7 +15,6 @@ then
;;
~*)
# home directory, convert to absolute path
HOME_DIR="$(getent passwd $USER | awk -F ':' '{print $6}')"
KEY_PATH="$HOME_DIR/${KEY_PATH:1}"
;;
*)
Expand All @@ -26,34 +26,41 @@ else
# user didn't specify a path
if [[ -z "$KEY_PATH" ]]
then
if [[ -d "$(pwd)/.adept" ]]
if [[ -d "$HOME_DIR/.config/adept" ]]
then
# check the script's "default" path
KEY_PATH="$(pwd)/.adept"
KEY_PATH="$HOME_DIR/.config/adept"
else
echo "!!!"
echo "!!! WARNING: no ADEPT keys detected (argument \$2, or \"$(pwd)/.adept\")."
echo "!!! WARNING: no ADEPT keys detected (argument \$2, or \"$HOME_DIR/.config/adept\")."
echo "!!! Launching interactive terminal for credentials creation (device activation). Run this:"
echo "!!!"
echo "!!! adept_activate -r --username {USERNAME} --password {PASSWORD} --output-dir files/.adept"
echo "!!!"
echo ""
echo " > adept_activate --random-serial \\"
echo " --username {USERNAME} \\"
echo " --password {PASSWORD} \\"
echo " --output-dir files/adept"
echo ""
echo "!!! (*) use --anonymous in place of --username, --password if you do not have an ADE account."
echo "!!! (*) credentials will be saved in your current path in the folder \"$(pwd)/.adept\""
echo "!!!"
echo "!!! (*) credentials will be saved in the following path: \"$(pwd)/adept\""
fi
fi
fi

# *.acsm file not specified, or specified file doesn't exist
if [[ -z "$ACSM_FILE" ]] || [[ ! -f "$ACSM_FILE" ]]
then
echo "!!!"
echo ""
echo "!!! WARNING: no ACSM file detected (argument \$1)."
echo "!!! Launching interactive terminal for manual loan management. Example commands below:"
echo "!!!"
echo "!!! acsmdownloader -f \"./files/{ACSM_FILE}\" -o output.drm"
echo "!!! adept_remove -v -f output.drm -o \"/home/libgourou/files/{OUTPUT_FILE}\""
echo "!!!"
echo ""
echo " > acsmdownloader \\"
echo " --adept-directory .adept \\"
echo " --output-file encrypted_file.drm \\"
echo " \"files/{ACSM_FILE}\""
echo " > adept_remove \\"
echo " --adept-directory .adept \\"
echo " --output-dir files \\"
echo " --output-file \"{OUTPUT_FILE}\" \\"
echo " encrypted_file.drm"
fi

if [[ -z "$KEY_PATH" ]]
Expand All @@ -79,8 +86,8 @@ else
--rm bcliang/docker-libgourou
else
# both ADEPT keys and *.acsm file were found
echo "> acsmdownloader -f \"/home/libgourou/files/$ACSM_FILE\" -o \"output.drm\""
echo "> adept_remove -v -f \"output.drm\" -o \"/home/libgourou/files/{OUTPUT_FILE}\""
echo "> acsmdownloader --adept-directory .adept --output-file encrypted_file.drm \"files/$ACSM_FILE\""
echo "> adept_remove --adept-directory .adept --output-dir files --output-file \"{OUTPUT_FILE}\" encrypted_file.drm"
docker run \
-v "$(pwd)":/home/libgourou/files \
-v "$KEY_PATH":/home/libgourou/.adept \
Expand Down
16 changes: 11 additions & 5 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ ACSM_FILE=$1
ACSM_PATH=/home/libgourou/files/$ACSM_FILE

acsmdownloader --version
echo ""[util] acsmdownloader -f "$ACSM_PATH"""
OUTPUT_FILE=$(acsmdownloader -f "$ACSM_PATH" | egrep "epub|pdf" | cut -d " " -f 2-)
echo ""[util] acsmdownloader "$ACSM_PATH"""

OUTPUT_FILE=$(acsmdownloader --adept-directory .adept "$ACSM_PATH" | egrep "epub|pdf" | cut -d " " -f 2-)
echo " > $OUTPUT_FILE"
mv "$OUTPUT_FILE" "output.drm"
# adept_remove -f "output.drm" -o "${ACSM_PATH%.*}.${OUTPUT_FILE##*.}"
adept_remove -v -f "output.drm" -o "/home/libgourou/files/$OUTPUT_FILE"

mv "$OUTPUT_FILE" "encrypted_file.drm"

adept_remove \
--adept-directory .adept \
--output-dir files \
--output-file "$OUTPUT_FILE" \
"encrypted_file.drm"

0 comments on commit 250ffe1

Please sign in to comment.