chbrown / overdrive

Bash script to download mp3s from the OverDrive audiobook service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Verify license acquisition succeeded

chbrown opened this issue · comments

Either by checking the file contents or the result of the curl call in acquire_license.

(Debugging upstream errors requires a tedious extra step if the license fails; see #3)

See also #30 — still an issue.

Failure at this stage should display clear instructions on how to resolve the issue, which AFAICT simply consists of trashing the original ODM along with any derivative files generated so far, and retrying with a freshly downloaded ODM.

This is still an issue and I would agree that instructions on how to resolve this (delete / redownload) would be appreciated.

Btw. 25a3e94 is intended to address this.

...also ab1dfcc.

Ideally, curl would have some combination of flags like --fail --output success.txt --fail-output - that would switch output destination on HTTP error codes, so that the failure response could be written to stdout (or wherever). But AFAICT if I want to handle response data differently based on the HTTP status code, I would have to 1) write the output to a temporary file, 2) parse out the status code, 3) on failure, just cat the temp file and exit 1, 4) on success, parse out the response body (remove the status line and headers) and write it to the (ODM-adjacent) license file. Which seems like an awful lot of extra work/complexity for what should be a pretty rare failure 😬

Closing this since 25a3e94 and ab1dfcc should now make recovery easier, but if anyone stumbles on this in the future, feel free to open a new issue.