chbrown / overdrive

Bash script to download mp3s from the OverDrive audiobook service
424 stars 64 forks source link

License acquisition error "Missing Query Parameter" silently ignored #3

Closed dennis-magnusson closed 5 years ago

dennis-magnusson commented 5 years ago

After running overdrive download myBook.odm The .license is created and I get this error: Using License=<LicenseError xmlns="http://license.overdrive.com/2008/03/LicenseError.xsd" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorCode>1001</ErrorCode><ErrorMessage>Missing Query Parameter</ErrorMessage><ErrorDetails i:nil="true"/></LicenseError> Any ideas what's going on and how can I fix it?

chbrown commented 5 years ago

Can't tell from such limited context, but you might delete the myBook.odm.license file and retry. (The script doesn't check the validity/success of the license, just whether the file exists or not)

If that still doesn't work, delete the license file again and re-run with the --verbose flag, and paste the entire output here or in a linked gist/pastebin/etc.

dennis-magnusson commented 5 years ago

Deleting the license didn't change anything, same error.

Here's the output when ran overdrive download myBook.odm --verbose

+ printf 'Entering debug (verbose) mode\n'
Entering debug (verbose) mode
+ shift
+ [[ 0 -gt 0 ]]
+ [[ 1 -eq 0 ]]
+ [[ 1 -eq 0 ]]
+ HEADER_PRINTED=
+ for ODM in '"${MEDIA[@]}"'
+ for COMMAND in '"${COMMANDS[@]}"'
+ case $COMMAND in
+ download myBook.odm
+ license_path=myBook.odm.license
+ acquire_license myBook.odm myBook.odm.license
+ [[ -e myBook.odm.license ]]
++ uuid
/usr/local/bin/overdrive: line 66: uuid: command not found
++ tr /a-z/ /A-Z/
+ ClientID=
+ printf 'Generating random ClientID=%s\n' ''
Generating random ClientID=
++ xmlstarlet sel -t -v /OverDriveMedia/License/AcquisitionUrl myBook.odm
+ AcquisitionUrl=https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/fc994945-5849-478a-99c3-a93b00e8c57b
+ printf 'Using AcquisitionUrl=%s\n' https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/fc994945-5849-478a-99c3-a93b00e8c57b
Using AcquisitionUrl=https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/fc994945-5849-478a-99c3-a93b00e8c57b
++ xmlstarlet sel -t -v /OverDriveMedia/@id myBook.odm
+ MediaID=631a852b-ef56-4cb7-b361-031990187ab5-425
+ printf 'Using MediaID=%s\n' 631a852b-ef56-4cb7-b361-031990187ab5-425
Using MediaID=631a852b-ef56-4cb7-b361-031990187ab5-425
+ RawHash='|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO'
+ printf 'Using RawHash=%s\n' '|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO'
Using RawHash=|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO
++ echo -n '|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO'
++ iconv -f ASCII -t UTF-16LE
++ openssl dgst -binary -sha1
++ base64
+ Hash=hq1tACqsLEikyeobpJZQp3m0FZ0=
+ printf 'Using Hash=%s\n' hq1tACqsLEikyeobpJZQp3m0FZ0=
Using Hash=hq1tACqsLEikyeobpJZQp3m0FZ0=
+ curl -A 'OverDrive Media Console' 'https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/fc994945-5849-478a-99c3-a93b00e8c57b?MediaID=631a852b-ef56-4cb7-b361-031990187ab5-425&ClientID=&OMC=1.2.0&OS=10.11.6&Hash=hq1tACqsLEikyeobpJZQp3m0FZ0='
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   250    0   250    0     0    250      0 --:--:-- --:--:-- --:--:--   354
++ cat myBook.odm.license
+ printf 'Using License=%s\n' '<LicenseError xmlns="http://license.overdrive.com/2008/03/LicenseError.xsd" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorCode>1001</ErrorCode><ErrorMessage>Missing Query Parameter</ErrorMessage><ErrorDetails i:nil="true"/></LicenseError>'
Using License=<LicenseError xmlns="http://license.overdrive.com/2008/03/LicenseError.xsd" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorCode>1001</ErrorCode><ErrorMessage>Missing Query Parameter</ErrorMessage><ErrorDetails i:nil="true"/></LicenseError>
++ xmlstarlet sel -N ol=http://license.overdrive.com/2008/03/License.xsd -t -v /ol:License/ol:SignedInfo/ol:ClientID myBook.odm.license
+ ClientID=

For what it's worth I'm running macOS 10.13.6 High Sierra on a Mid 2014 MacBook Pro 15in.

chbrown commented 5 years ago

Ah, you don't have uuid on your PATH. If you have Homebrew, you can brew install ossp-uuid.

Or open up the shell script and replace:

ClientID=$(uuid | tr /a-z/ /A-Z/)

with:

ClientID=2F6A8F70-9F37-11E8-BDE6-63352C801092

(which I just now copied from https://www.uuidgenerator.net/ — feel free to replace with any other valid UUID in the same format)

And of course delete the broken license file before you re-run. I should have it check in the script :)

dennis-magnusson commented 5 years ago

Thank you! brew install ossp-uuid fixed the problem.