• Stars
    star
    427
  • Rank 101,067 (Top 3 %)
  • Language
    Shell
  • Created about 7 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bash script to download mp3s from the OverDrive audiobook service

OverDrive

OverDrive is great and distributes DRM-free MP3s instead of some fragile DRM-ridden format, which is awesome. Way to go, Rakuten / OverDrive, fight the man!

Their "OverDrive Media Console" application for macOS is pretty simple, but I like to automate things, so I wrote a bash script, overdrive.sh, which takes one or more .odm files, and downloads the audio content files locally, just like the app.

Then they stopped supporting macOS altogether after Mojave (10.14), leaving Catalina (10.15), Big Sur (11), and Monterey (12) users with no choice but to find a third-party option, such as this script ๐Ÿ˜‰

Btw, it works on Linux too!

Libby

This script will stop working when OverDrive finally decides to stop supporting the "classic" OverDrive app.

You don't have to worry about this as long as you can download .odm files from your library!

But if you do want to worry about it sooner rather than later, you can expand this...

On Libby and the impending demise of OverDrive ๐Ÿคช

OverDrive has been making it harder to use the .odm flow for a while now, first removing their OverDrive app from all app stores, then adding various hurdles around accessing the .odm file for a loan from your library's website.

They've been threatening to shut it down for what seems like years, so ๐Ÿคž they keep that up for years to come. But lately it does sound like they're getting more serious; their Libby propaganda page reads:

To help your library welcome more users to Libby, the legacy OverDrive app is being discontinued in early 2023.

That and I've been getting more issues/notes about it, so here's my position:

  • This repo is not called libby and will not be retrofitted to accommodate Libby (if that's even possible).
  • This project has no interest in circumventing DRM or aiding others to circumvent DRM. Never has, never will.
  • I too am a user of this script, and I too regret the forced migration to Libby.
  • If/when OverDrive fully shuts down, I'll be on the hunt for another way to consume audiobooks from my local public library (โค๏ธ) in a format that fits my lifestyle.
  • If I find a good solution, I'll link to it from this README.

I'm going to enjoy OverDrive while it lasts, and move on when it doesn't.

r/audiobooks seems like a nice community. Let's hang out there?

Instructions

First, install the script and make it executable:

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

(You only need to do that โ˜๏ธ step once! It is also idempotent โ€” you can run it multiple times no problem.)

Now download an OverDrive loan file from your library or wherever. I'll assume that yours is called Novel.odm. Assuming you've downloaded it to your ~/Downloads folder, simply run the following command:

cd ~/Downloads
~/.local/bin/overdrive download Novel.odm

This will display a couple dozen lines as it downloads the book, most of which are only relevant/useful if something goes wrong.

Assuming that you decided to listen to Blake Crouch's Recursion, once the script finishes you will have a new folder called Blake Crouch - Recursion (inside your "Downloads" folder), inside which will be several MP3s: Part01.mp3, Part02.mp3, etc. (these "parts" don't necessarily correspond to actual chapters in the book; there may be multiple chapters in a single part, or a single chapter spread out over multiple parts), and the cover art: folder.jpg.

And that's it, you're done! ๐ŸŽ‰

The rest of this README describes how to debug various issues people run into and some automation tips; if your book downloaded just fine, you don't need to worry about any of that ๐Ÿ˜

Debugging

If you have trouble getting the script to run successfully, add the --verbose flag and retry, e.g.:

~/.local/bin/overdrive download Novel.odm --verbose

This will call set -x to turn bash's xtrace option on, which causes a trace of all commands to be printed to standard error, prefixed with one or more + signs. It will also set all curl calls to not be silent.

Common errors

Permission denied (executable flag)

If you get an error message like -bash: ~/.local/bin/overdrive: Permission denied or zsh: permission denied: overdrive, you installed overdrive to the right place ๐Ÿ‘, but didn't set the executable flag ๐Ÿ˜Ÿ. Try running the chmod +x command from the Instructions.

Folder access

If you see a line that reads I/O error : Operation not permitted, you probably didn't allow Terminal / iTerm2 to access your Downloads folder.

Syntax error (HTML vs. source)

If calling the script with any combination of options produces an error message like

.local/bin/overdrive: line 1: syntax error near unexpected token `newline'
.local/bin/overdrive: line 1: `<!DOCTYPE html>'

this indicates you installed the script incorrectly. You most likely saved the GitHub webpage that displays the source code, instead of just the source code. To fix, follow the Instructions exactly as shown.

If you are security conscious ๐Ÿง (good for you!), feel free to cat -n ~/.local/bin/overdrive after installing, but before executing the script for the first time.

SSL certificate

If the script fails right after a curl call, and then you rerun it with --verbose and get an error message like curl: (60) SSL certificate problem: certificate has expired, that indicates the OverDrive server cannot be verified from your system's certificate authority. You can bypass the security check by adding --insecure when calling the overdrive script.

Expired / used license

If you see a message like The requested license is either invalid or already acquired, you'll need to go back to your library and download a fresh ODM file.

Hidden download link

If your library doesn't show you the link to "Download MP3 audiobook" (i.e., the .odm file), the easiest way to get it to (re)appear is to pretend to use an OS that they do support โ€” by editing the "User Agent" that your browser presents itself as:

  1. Install a Chrome or Firefox extension to customize your user agent.
  2. Pick some mainstream value for Windows or pre-Catalina.
  3. Configure your extension to use that value.
  4. Refresh your "Loans" page.

New (as of 2022-02): you must now also click the "Do you have the OverDrive app? >" disclosure/dropdown to get the "Download MP3 audiobook" link to show up.

Dependencies

I call this a "standalone" script, but it actually depends on several executables being available on your PATH:

  • curl
  • uuidgen
  • xmllint
  • iconv
  • openssl
  • base64

If you get an error like -bash: xmllint: command not found, you're evidently missing one of those; the following package manager one-liners should help:

Command OS
N/Aโ€  # macOS
apt-get install curl uuid-runtime libxml2-utils libc-bin openssl coreutils # Debian / Ubuntu
apk add bash curl util-linux libxml2-utils openssl # Alpine
pacman -S curl util-linux libxml2 openssl coreutils # Arch
dnf install curl glibc-common util-linux libxml2 openssl coreutils # Fedora
(please create a PR to contribute a new OS!)

โ€ All required commands are installed by default on macOS 10.14 (Mojave), 10.15 (Catalina), 12.6 (Monterey), and probably everywhere in between โ€” those are just the versions I've personally tested. It also works with the latest version of OpenSSL, so if you want, brew install openssl.

Issues not emails

If none of that solves your problem, you can open an issue, including the full debug output (optimally as a gist), and I'll try to help you out.

  • If you email me asking for technical help with this script (or any of my GitHub projects), I will redirect you to create a GitHub issue. Don't have an account? Create one, they're free.
    Sure I could help you over email, but then the solution would be siloed away in our inboxes; by corresponding in an issue, other users will be able to find it.
  • You can email me cute little thank you notes; those are always fun to read ๐Ÿ˜€

Advanced

PATH

All the basic examples above invoke the script using its full path, (hopefully) to avoid PATH-related headaches for new users.

But if installed as instructed, you should be able to call just overdrive [...] instead of ~/.local/bin/overdrive [...], since ~/.local/bin is commonly used for tools like this, and many default init scripts automatically add it to your PATH if it exists.

However, if calling overdrive produces the error message -bash: overdrive: command not found, you'll can easily add ~/.local/bin to your PATH. One way to do this:

printf 'export PATH=$HOME/.local/bin:$PATH\n' >> ~/.bashrc
source ~/.bashrc

Or if you're using zsh instead of bash, run this instead:

printf 'export PATH=$HOME/.local/bin:$PATH\n' >> ~/.zshrc
source ~/.zshrc

Early Return

Early return is entirely optional, and AFAICT, equivalent to clicking "Return" on the library's OverDrive website, but if you want, you can "return" a loan using this script, e.g.:

overdrive return Novel.odm

License

Copyright ยฉ 2017โ€“2021 Christopher Brown. MIT Licensed.

More Repositories

1

rfc6902

Complete implementation of RFC6902 in TypeScript
TypeScript
283
star
2

liwc-python

Linguistic Inquiry and Word Count (LIWC) analyzer
Python
190
star
3

unmap

Unpack a JavaScript Source Map back into filesystem structure
JavaScript
173
star
4

macos-pasteboard

Like OS X's built-in pbpaste but more flexible and raw
Swift
89
star
5

slda

Supervised Latent Dirichlet Allocation for Classification
C++
84
star
6

flickr-with-uploads

Flickr API for Node.js using OAuth 1.0a, including upload support and featuring a CLI
JavaScript
47
star
7

osx-notifier

Send notifications to the OS X Notification Center using terminal-notifier.app
JavaScript
41
star
8

twttr

Twitter API client for Clojure supporting REST and Streaming endpoints
Clojure
35
star
9

macos-wifi

MacOS Wi-Fi (CoreWLAN) utility
Swift
34
star
10

lexicons

Lexicons for n-gram sentiment analysis
Python
20
star
11

flickr-sync

Deprecated! Use flickr-with-uploads instead
JavaScript
17
star
12

amulet

As-soon-as-possible streaming asynchronous Mustache template engine for Node.js
JavaScript
16
star
13

aclweb-data

Data from https://aclweb.org/anthology/
HTML
16
star
14

candc

C&C (Clark & Curran) Parser downloads
Python
14
star
15

nlp

NLP Homework (Spring 2013)
Java
13
star
16

twilight

Twitter Streaming API tools and data transformations for Node.js
JavaScript
13
star
17

afm

Collection of AFM (Adobe Font Metrics) specifications
TypeScript
12
star
18

BluetoothLE-HeartRate

Node.js Bluetooth Low Energy (BLE) heart rate (HR) sensor data collector
JavaScript
10
star
19

pdfi

PDF parsing, drawing, and text extraction
TypeScript
9
star
20

acl-anthology-network

Post-processing for "ACL Anthology Network" corpus (aanrelease2013)
Python
9
star
21

dropyll

Use Dropbox to edit your Jekyll website (with staging area)
JavaScript
9
star
22

macos-tags

Command line tool for manipulating OS X filesystem tags
Swift
8
star
23

autoauth

Automatic OAuth token generation from basic user account credentials
JavaScript
8
star
24

iOSpy

iOS MobileSync backup data extraction
Python
8
star
25

unidata

Javascript interface to the Unicode Character Database
JavaScript
8
star
26

chrome-unxss

Chrome extension to modify website headers on the fly
JavaScript
8
star
27

audible

Audio extraction and chapter splitting from Audible audiobooks
Shell
7
star
28

scripts

Multi-use scripts for my PATH
Python
7
star
29

fs-change

Monitor changes to specified files or directories, run arbitrary scripts in response
JavaScript
7
star
30

turk

Amazon Mechanical Turk API
TypeScript
7
star
31

config

My preferred system preferences
Shell
7
star
32

socks-server

SOCKS4/SOCKS5 proxy server
JavaScript
6
star
33

refseer

RefSeer dataset downloader
Makefile
6
star
34

openxml

openxml is a Python library to create and manipulate .docx and .pptx files
Python
6
star
35

fancy-clojure

Fancy printing โ€” prettier than pretty
Clojure
6
star
36

pybtex

Fork of http://pybtex.sourceforge.net/
Python
6
star
37

presidents

Textual data (and scrapers) produced by the United States presidency
Jupyter Notebook
5
star
38

brew-tour

Web UI and summarizer to facilitate pruning Homebrew-installed packages
JavaScript
5
star
39

argv

Simpler command line argument parsing in Python
Python
5
star
40

tex

TeX (and BibTeX) for JavaScript!
TypeScript
5
star
41

stanford-parser

Stanford parser with sane logging
Java
5
star
42

viz

Python-powered terminal visualizations
Python
4
star
43

synology

Synology configuration notes
Shell
4
star
44

jsed

JavaScript stream editor: transform JSON via the command line
JavaScript
4
star
45

formious

Online experimentation framework (Mechanical Turk oriented)
JavaScript
4
star
46

pi

Simpler python package installation
Python
4
star
47

justext

UNMAINTAINED; use https://github.com/miso-belica/jusText instead
Python
4
star
48

bartleby

BibTeX (and TeX) parsing with Clojure
Clojure
4
star
49

sqlcmd

Incremental and immutable SQL command builder
TypeScript
4
star
50

osx-tap

Mac OS X key logger
Objective-C
3
star
51

booktool

eBook (EPUB and Audiobook) management tool
Python
3
star
52

textarea

HTML Textarea element enhancements (vanilla JavaScript; no dependencies)
TypeScript
3
star
53

aclweb

Make-driven ACL anthology downloader
JavaScript
3
star
54

BluetoothLE-Explorer

Command line explorer for Bluetooth Low Energy (BLE) devices
JavaScript
3
star
55

domlike

A better DomHandler for fb55's htmlparser2
TypeScript
3
star
56

disqust-python

Disqus API client
Python
3
star
57

xdoc-python

Python DOCX parsing. You should use xdoc instead: https://github.com/chbrown/xdoc
Python
3
star
58

to-sql

Read tabular data (Excel, csv, tsv) into PostgreSQL
TypeScript
3
star
59

xdoc

Document object manipulation
TypeScript
2
star
60

iTunesMeta

Tools for manipulating iTunes in Python
Python
2
star
61

kdd-2013-usb

Contents of the KDD 2013 USB drive
CSS
2
star
62

macos-notification

Generate plain notifications on Mac OS X from the command line
Swift
2
star
63

lexing

Regex-based lexer
TypeScript
2
star
64

ansible-wordpress

Ansible playbook for installing WordPress on a Digital Ocean droplet
PHP
2
star
65

npm-search-server

NPM registry ElasticSearch API with download counts
TypeScript
2
star
66

regex-router

Route http requests via regular expressions
TypeScript
2
star
67

jsonarea

React component for editing/validating JSON (as text)
TypeScript
2
star
68

plist-utils

Tools for manipulating files/streams in Apple's "property list" format
Shell
2
star
69

pbwatch

Polling the Mac OS X pasteboard with Python
Python
2
star
70

macos-location

Logger daemon for monitoring your macOS's location via CoreLocation updates
Swift
2
star
71

github-corpora

Tools for crawling the GitHub API and data pulled from the public API
Python
2
star
72

chicken

Port of 'Chicken of the VNC' from SourceForge
Shell
2
star
73

topic-sentiment-authorship

Topic-Sentiment Authorship
Jupyter Notebook
2
star
74

routes-clojure

URL path parsing and generation via routes data structures
Clojure
2
star
75

libpam-storepw

PAM module to store password
C
2
star
76

filesequence

Write to an indexed sequence of files using the standard Python file API
Python
2
star
77

streaming

Common stream.Transform implementations and other Node.js streaming helpers
TypeScript
2
star
78

divvy-history

Historical data for http://divvybikes.com/stations/json
Python
1
star
79

set

Javascript to display set cards through HTML5 canvas
JavaScript
1
star
80

xmltree

DOM-driven tools for XML viewing
TypeScript
1
star
81

walk-stream

Recursive filesystem walker for Node.js that implements stream.Readable
JavaScript
1
star
82

misc-js

Custom client-side JavaScript libraries for use with jQuery, Backbone, and Handlebars
JavaScript
1
star
83

cameo-twitter

Small-scale Twitter crawling and archiving
JavaScript
1
star
84

appfog-mongo-bottle

Minimum working example of connecting MongoDB and Bottle on Appfog
Python
1
star
85

photos-python

Photo management utilities implemented in Python
Python
1
star
86

npm-reallink

Publish-like 'npm link' replacement (for TypeScript development)
JavaScript
1
star
87

citation-analysis

Citation analysis tools
Python
1
star
88

npm-ui

Web UI companion to 'npm-search-server'
JavaScript
1
star
89

notify-ui

Client-side helper for displaying flash messages
TypeScript
1
star
90

sv

Any-separated values
TypeScript
1
star
91

tarry

Utility library for manipulating JavaScript Arrays
TypeScript
1
star
92

ritual

Database and API for enhancing shell history and clipboard processing
TypeScript
1
star
93

hackpad

Hackpad API client with CLI for archiving
JavaScript
1
star
94

marked-cli

Alternate CLI for Markdown interpreter, 'marked'
JavaScript
1
star
95

taskdb

Database + REST API server for managing (storing / allocating) annotation tasks
TypeScript
1
star
96

confrm

Conference Resource Management
JavaScript
1
star
97

yaml-utils

CLI tools for converting between JSON and YAML
JavaScript
1
star
98

dbml

Homework for Dana Ballard's Machine Learning course
MATLAB
1
star
99

xmlconv

XML conversion by convention
JavaScript
1
star
100

wiktionary

Tools for working with Wiktionary data
Python
1
star