This bot finds new audiobooks on Audible's "Free Listens" and "Audible Plus" (i.e. free with subscription) pages and posts them to a Mastodon account and/or a Discord channel.
This project uses uv for package management.
-
Install
uvFollow the official instructions to install
uv: https://github.com/astral-sh/uv -
Create a virtual environment
uv venv
-
Install dependencies
uv sync
-
Install in editable mode
uv pip install -e . -
Install Playwright browsers
uv run playwright install
You can configure the bot in two ways:
-
Environment Variables (recommended)
Create a
.envfile in the root of the project and add the following variables:MASTODON_INSTANCE=<your-mastodon-instance-url> MASTODON_TOKEN=<your-access-token> DISCORD_WEBHOOK=<your-discord-webhook-url>A
.env.examplefile is provided as a template. -
Command-line Arguments
You can also pass credentials as command-line arguments when running the bot. See the Usage section for examples.
You need to configure at least one of the following: Mastodon or Discord.
-
Get a Mastodon Access Token
You need to create a Mastodon application to get an access token.
- Go to your Mastodon instance's settings:
https://<your-instance>/settings/applications - Click "New Application".
- Give your application a name (e.g., "Audiblastodon").
- Make sure the
write:statusesscope is checked. - Click "Submit".
- You will see your access token on the next page. Copy it.
- Go to your Mastodon instance's settings:
-
Get a Discord Webhook URL
- In your Discord server, go to Server Settings > Integrations > Webhooks.
- Click "New Webhook".
- Give the webhook a name (e.g., "Audiblastodon").
- Choose the channel you want the bot to post in.
- Click "Copy Webhook URL".
The bot has two main commands: scrape and post.
scrape: Scrapes Audible for new books and adds them tobooks.csv.post: Posts any unposted books frombooks.csv.
Each command has a --dry-run option that will print the output to the console instead of performing the action.
-
To scrape for new books:
uv run main scrape
-
To post new books:
uv run main post
-
To do a dry run of the scrape:
uv run main scrape --dry-run
-
To do a dry run of the post:
uv run main post --dry-run
To run this bot automatically, you can set up cron jobs to execute the commands periodically. It is recommended to run the scrape command more frequently than the post command.
For example, to scrape every hour and post every day at 9:00 AM:
0 * * * * cd /path/to/audiblastodon && uv run main scrape
0 9 * * * cd /path/to/audiblastodon && uv run main post
