Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working for MacOS Catalina Version 10.15.3 #40

Closed
DieSimpsonsDie opened this issue Nov 15, 2021 · 9 comments
Closed

Not working for MacOS Catalina Version 10.15.3 #40

DieSimpsonsDie opened this issue Nov 15, 2021 · 9 comments

Comments

@DieSimpsonsDie
Copy link

Hi @chbrown, first of all, thank you for doing this. I'm sure once I get it going correctly, this will be such an amazing tool to have.

I don't have any experience coding or using Terminal, so it's more than likely I'm not doing something right, but when I copy/paste the code listed on your GitHub, I get the following:

% mkdir -p ~/.local/bin
curl https://chbrown.github.io/overdrive/overdrive.sh -o ~/.local/bin/overdrive
chmod +x ~/.local/bin/overdrive
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8911  100  8911    0     0  27760      0 --:--:-- --:--:-- --:--:-- 27760

Then I move on to step 2 and type overdrive and get the following:

Usage: overdrive [-h|--help]
       overdrive --version
       overdrive command [command2 ...] book.odm [book2.odm ...] [-v|--verbose]

Commands:
  download   Download the mp3s for an OverDrive book loan.
  return     Process an early return for an OverDrive book loan.
  info       Print the author, title, and total duration (in seconds) for each OverDrive loan file.
  metadata   Print all metadata from each OverDrive loan file.

You must supply at least one command.
You must supply at least one media file (the .odm extension is required).

So all seems to be working well. But then I input the download code and get the following:

% cd ~/Downloads
overdrive download LilyandtheOctopus-9077.odm
License already acquired: LilyandtheOctopus-9077.odm.license
Using License=
LilyandtheOctopus-9077.odm.license:1: parser error : Document is empty

^

I have the .license file that goes along with the .odm file, but nothing happens at this point and I can't seem to figure out a way to fix anything.

Any help would be greatly appreciated!

@chbrown
Copy link
Owner

chbrown commented Nov 15, 2021

Your license file is probably broken, i.e., empty. Sorry, it's a known issue — #4, #30, #39 (tangentially). Doesn't come up that often and I haven't had a lot of time to work on substantial improvements lately :/

I'm guessing there's a previous invocation of the script not depicted here, which is where the output required to actually debug this would be, but it's probably just a one-off fluke.

Easiest surefire fix:

  1. Delete both *.odm and *.odm.license files.
  2. Re-download the .odm from your library
  3. Re-run the script: overdrive download *.odm

(If it fails again after that, please repeat steps 1 and 2 one more time, and then step 3, but add the verbose flag: overdrive download *.odm --verbose, and paste the output here.)

Fewer steps, but might not work:

  1. Delete just the *.odm.license file.
  2. Re-run the script: overdrive download *.odm

@DieSimpsonsDie
Copy link
Author

Thanks for the quick reply!

After deleting both the .odm and the .odm.license files, I redownloaded from my library and then ran the script again and got this:

% overdrive download /Users/myname/Downloads/LilyandtheOctopus-9077.odm
Generating random ClientID=EF7E14CA-7174-4028-8937-F15F6704C1B0
Using AcquisitionUrl=https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/99672640-59c9-4ad7-9bf4-ade100be5a90
Using MediaID=6a4953a5-24d9-4080-a5f2-255a21720ab6-425
Using RawHash=EF7E14CA-7174-4028-8937-F15F6704C1B0|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO
Using Hash=181DLz7xbw6uQSyTkCAm5fMapyc=

At that point, nothing happens and we're back to square one.

I deleted each file (.odm and .odm.license) and tried again and the same thing happened. Then I deleted each file and input the --verbose addition. Got the following from that:

Entering debug (verbose) mode
+ CURLOPTS=("${CURLOPTS[@]:1}")
+ shift
+ [[ 0 -gt 0 ]]
+ [[ 1 -eq 0 ]]
+ [[ 1 -eq 0 ]]
+ HEADER_PRINTED=
+ for ODM in '"${MEDIA[@]}"'
+ for COMMAND in '"${COMMANDS[@]}"'
+ case $COMMAND in
+ download LilyandtheOctopus-9077.odm
+ license_path=LilyandtheOctopus-9077.odm.license
+ acquire_license LilyandtheOctopus-9077.odm LilyandtheOctopus-9077.odm.license
+ [[ -e LilyandtheOctopus-9077.odm.license ]]
++ uuidgen
++ tr '[:lower:]' '[:upper:]'
+ ClientID=CFD9B257-9C73-4C8D-A926-6010A26721AE
+ printf 'Generating random ClientID=%s\n' CFD9B257-9C73-4C8D-A926-6010A26721AE
Generating random ClientID=CFD9B257-9C73-4C8D-A926-6010A26721AE
++ xmllint --xpath '/OverDriveMedia/License/AcquisitionUrl/text()' LilyandtheOctopus-9077.odm
warning: failed to load external entity "LilyandtheOctopus-9077.odm"
+ AcquisitionUrl=

I don't know what any of that means, but hope it can help.

@chbrown
Copy link
Owner

chbrown commented Nov 15, 2021

By "nothing happens" I assume you mean it just exits and shows your terminal prompt again?

If so, I expect you're running into the curl security conflict described in #36. I described a workaround at #36 (comment); namely: open the overdrive.sh script (wherever you downloaded it) in a text editor, and replace the line:

CURLOPTS=(-s -L -A "$UserAgent" --compressed)

with this line:

CURLOPTS=(-s -L -A "$UserAgent" --compressed --insecure)

then delete the *.odm.license file and re-run the script.

If that is the problem, you won't need to delete and redownload the .odm file, because you never established a successful connection to the overdrive server in the first place, and so you never used up the license acquisition key in your current .odm file.


Btw, that command at the bottom of your previous comment was meant to be run after downloading a fresh .odm file, but the output it's showing indicates that even the LilyandtheOctopus-9077.odm file is totally missing. (Which ought to fail more descriptively 😬 — should add that to my to-do list.) I suspect the instructions above will solve your problem, but if not, please ensure that a fresh version of the .odm file exists in your Downloads folder, then reply with the output produced by calling cd ~/Downloads && overdrive download LilyandtheOctopus-9077.odm --verbose.

@DieSimpsonsDie
Copy link
Author

DieSimpsonsDie commented Nov 15, 2021

Sorry, "nothing happens" was unclear. I don't know this kind of stuff at all so I'm not sure what are the right words to use. I meant that I received the code that I had pasted and then I'm left with the ability to just type in a new line of code. I guess I was just trying to say that no new event seemed to have happened. The Terminal window doesn't close, but it does let me type in whatever my next line is going to be. (I hope that kind of clears that up).

I don't think I have an overdrive.sh script? The first thing I believe I did once I found my way to this github was to input:

mkdir -p ~/.local/bin
curl https://chbrown.github.io/overdrive/overdrive.sh -o ~/.local/bin/overdrive
chmod +x ~/.local/bin/overdrive

I see that I can click on the link overdrive.sh and it takes me to a new page with an "Executable File" with 291 lines and it's 8.7 KB. Based on your latest message, I edited that and replaced the old line with the new line you gave me and then copied that whole code and pasted it into Terminal. I got the following:

Last login: Mon Nov 15 12:58:12 on ttys000
myname@myname-MBP ~ % >....                                                 
for ODM in "${MEDIA[@]}"; do
[... elided by author]
zsh: event not found: /usr/bin/env
myname@myname-MBP ~ % 

Also, I believe I deleted the .odm file correctly this time but maybe I'm missing something. I'm sending it to trash and then emptying out the trash too.

@chbrown
Copy link
Owner

chbrown commented Nov 15, 2021

Oops no you can't just paste it into the terminal like that. Hopefully that didn't make too much of a mess ;)

Open it up in a text editor by calling this from terminal:

open -t "$(which overdrive)"

@DieSimpsonsDie
Copy link
Author

So I just opened the text editor using that line of code you gave me, made replacement of the one line with the other, deleted the .odm.license file, and then started from the beginning with:

mkdir -p ~/.local/bin
curl https://chbrown.github.io/overdrive/overdrive.sh -o ~/.local/bin/overdrive
chmod +x ~/.local/bin/overdrive

followed by:

cd ~/Downloads
overdrive download LilyandtheOctopus-9077.odm

Now a new .odm.license file has been created but nothing else has occured. This was the latest code in Terminal after doing the above:

myname@myname-MBP Downloads % overdrive download LilyandtheOctopus-9077.odm
Generating random ClientID=262A0E56-E014-4AE9-84FB-9D7F8AB2B69A
Using AcquisitionUrl=https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/e2110944-cb0e-48a2-9cc6-ade100dfb2db
Using MediaID=6a4953a5-24d9-4080-a5f2-255a21720ab6-425
Using RawHash=262A0E56-E014-4AE9-84FB-9D7F8AB2B69A|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO
Using Hash=gSYNhoRqegtXyzOcgGNRCWGO0GU=
myname@myname-MBP Downloads % 

So after that, I figured I'd delete the files again, re-download from my library, and then run the code with the --verbose add on. Here is that:

myname@myname-MBP Downloads % overdrive download LilyandtheOctopus-9077.odm --verbose
Entering debug (verbose) mode
+ CURLOPTS=("${CURLOPTS[@]:1}")
+ shift
+ [[ 0 -gt 0 ]]
+ [[ 1 -eq 0 ]]
+ [[ 1 -eq 0 ]]
+ HEADER_PRINTED=
+ for ODM in '"${MEDIA[@]}"'
+ for COMMAND in '"${COMMANDS[@]}"'
+ case $COMMAND in
+ download LilyandtheOctopus-9077.odm
+ license_path=LilyandtheOctopus-9077.odm.license
+ acquire_license LilyandtheOctopus-9077.odm LilyandtheOctopus-9077.odm.license
+ [[ -e LilyandtheOctopus-9077.odm.license ]]
++ uuidgen
++ tr '[:lower:]' '[:upper:]'
+ ClientID=FA6C3F18-9C66-4359-A3B1-E00A6C9DAA35
+ printf 'Generating random ClientID=%s\n' FA6C3F18-9C66-4359-A3B1-E00A6C9DAA35
Generating random ClientID=FA6C3F18-9C66-4359-A3B1-E00A6C9DAA35
++ xmllint --xpath '/OverDriveMedia/License/AcquisitionUrl/text()' LilyandtheOctopus-9077.odm
+ AcquisitionUrl=https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/e9b76dd3-fb39-43d9-9bc5-ade100e223a9
+ printf 'Using AcquisitionUrl=%s\n' https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/e9b76dd3-fb39-43d9-9bc5-ade100e223a9
Using AcquisitionUrl=https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/e9b76dd3-fb39-43d9-9bc5-ade100e223a9
++ xmllint --xpath 'string(/OverDriveMedia/@id)' LilyandtheOctopus-9077.odm
+ MediaID=6a4953a5-24d9-4080-a5f2-255a21720ab6-425
+ printf 'Using MediaID=%s\n' 6a4953a5-24d9-4080-a5f2-255a21720ab6-425
Using MediaID=6a4953a5-24d9-4080-a5f2-255a21720ab6-425
+ RawHash='FA6C3F18-9C66-4359-A3B1-E00A6C9DAA35|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO'
+ printf 'Using RawHash=%s\n' 'FA6C3F18-9C66-4359-A3B1-E00A6C9DAA35|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO'
Using RawHash=FA6C3F18-9C66-4359-A3B1-E00A6C9DAA35|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO
++ echo -n 'FA6C3F18-9C66-4359-A3B1-E00A6C9DAA35|1.2.0|10.11.6|ELOSNOC*AIDEM*EVIRDREVO'
++ iconv -f ASCII -t UTF-16LE
++ openssl dgst -binary -sha1
++ base64
+ Hash=lgXR069eYjw2u5yVPwypV/U1rmg=
+ printf 'Using Hash=%s\n' lgXR069eYjw2u5yVPwypV/U1rmg=
Using Hash=lgXR069eYjw2u5yVPwypV/U1rmg=
+ curl -L -A 'OverDrive Media Console' --compressed 'https://ofs.contentreserve.com/MP3LicenseAcquisitionService.svc/e9b76dd3-fb39-43d9-9bc5-ade100e223a9?MediaID=6a4953a5-24d9-4080-a5f2-255a21720ab6-425&ClientID=FA6C3F18-9C66-4359-A3B1-E00A6C9DAA35&OMC=1.2.0&OS=10.11.6&Hash=lgXR069eYjw2u5yVPwypV/U1rmg='
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem: certificate has expired
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
myname@myname-MBP Downloads % 


Note for this last --verbose included one, I just went straight to overdrive download LilyandtheOctopus-9077.odm --verbose I didn't start with:

mkdir -p ~/.local/bin
curl https://chbrown.github.io/overdrive/overdrive.sh -o ~/.local/bin/overdrive
chmod +x ~/.local/bin/overdrive

I hope we're getting closer to the fix! Thanks again.

@chbrown
Copy link
Owner

chbrown commented Nov 15, 2021

Okay, yep, definitely the problem from #36.

Unfortunately, the installation step:

mkdir -p ~/.local/bin
curl https://chbrown.github.io/overdrive/overdrive.sh -o ~/.local/bin/overdrive
chmod +x ~/.local/bin/overdrive

overwrites the "replacement of the one line with the other" step :(

You only need to run that 'installation step' one time, ever (well, per computer), which you've already done!

So now just:

  1. run the open ... command to edit the file
  2. replace that line with the other line as described above
  3. delete the .odm.license file
  4. re-run the overdrive download ... command

🤞

@DieSimpsonsDie
Copy link
Author

It worked! Wow, thank you so much. You're damn good.

Couple other questions for you.

  1. Do I need to replace that line in text edit using the open... command every time I want to convert a book to mp3?
  2. Do I need to manually use the return... command so the book goes back to the library? I've never used this or Overdrive before so I'm not sure.

Thanks again!

@chbrown
Copy link
Owner

chbrown commented Nov 15, 2021

Awesome, glad we were able to get it working 😄

Answers:

  1. No.
  2. No. It might come in handy if you reach your library's limit on concurrent loans, but otherwise your loan will expire naturally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants