Skip to main content

catholic-mass-readings

CI Build License PyPI Version versions

Provides an API for scraping the web page from Daily Readings website of United States Conference of Catholic Bishops.

About catholic-mass-readings

This package was built to facilitate pulling the mass readings used as the description when scheduling the YouTube live stream. I'm happy if others want to use it. Please open new issues for any bugs you find, support is greatly appreciated! If you have a new feature, feel free to open a pull request.

Installation

To install catholic-mass-readings from PyPI, use the following command:

$ pip install catholic-mass-readings

You can also clone the repo and run the following command in the project root to install the source code as editable:

$ pip install -e .

JavaScript challenge (optional browser support)

The USCCB site sometimes answers with a "Checking connection" page that requires JavaScript to pass. When that happens, a browser is driven through Playwright to pass the challenge once, and its cookie is reused for the rest of the requests. Playwright is an optional dependency:

$ pip install 'catholic-mass-readings[browser]'

Without it, a catholic_mass_readings.challenge.ChallengeError is raised when the challenge is encountered.

The browser can be obtained in one of three ways, configured with environment variables or the matching CLI options (which take precedence over the environment variables):

Environment variable CLI option Description
(none) Launch Playwright's bundled headless Chromium (requires playwright install chromium).
CATHOLIC_MASS_READINGS_BROWSER_CHANNEL --browser-channel Launch an installed browser instead (chrome, msedge, ...).
CATHOLIC_MASS_READINGS_BROWSER_CDP_URL --browser-cdp-url Connect to an already running Chromium-based browser over the Chrome DevTools Protocol.
CATHOLIC_MASS_READINGS_BROWSER_WS_ENDPOINT --browser-ws-endpoint Connect to a Playwright server.
CATHOLIC_MASS_READINGS_BROWSER_HEADLESS --browser-headless/--browser-headed Whether a launched browser is headless (default: true).
CATHOLIC_MASS_READINGS_BROWSER_TIMEOUT --browser-timeout Seconds to wait for the challenge (default: 30).
CATHOLIC_MASS_READINGS_BROWSER_COOKIE_CACHE --browser-cookie-cache File in which to save the challenge cookie so separate runs reuse it until it expires (about 30 minutes).

Docker

The simplest image installs a browser alongside the package (larger, but self-contained):

FROM python:3.13-slim
RUN pip install --no-cache-dir 'catholic-mass-readings[browser]' \
    && playwright install --with-deps chromium
# Optional: reuse the challenge cookie across runs (mount a volume at /cache).
ENV CATHOLIC_MASS_READINGS_BROWSER_COOKIE_CACHE=/cache/cookies.json
ENTRYPOINT ["python", "-m", "catholic_mass_readings"]
docker build -t catholic-mass-readings .
docker run --rm -v catholic-mass-readings-cache:/cache catholic-mass-readings get-mass --date 2025-08-06

Connecting to a running browser instead means the image only needs the playwright Python package (pip install 'catholic-mass-readings[browser]', without playwright install), not a browser:

# Use Chrome running on the host (e.g. Windows), started with remote debugging enabled:
#   chrome.exe --remote-debugging-port=9222 --user-data-dir=%TEMP%\chrome-cdp
docker run --rm -e CATHOLIC_MASS_READINGS_BROWSER_CDP_URL=http://<host-ip>:9222 ...

# Or use a Playwright server container alongside it (match the Playwright version):
docker run -p 3000:3000 mcr.microsoft.com/playwright:v1.64.0-noble \
    npx -y playwright@1.64.0 run-server --port 3000 --host 0.0.0.0
docker run --rm -e CATHOLIC_MASS_READINGS_BROWSER_WS_ENDPOINT=ws://<playwright-host>:3000/ ...

Notes on connecting over CDP:

  • Use an IP address in the CDP URL. Chrome rejects DevTools requests whose Host is a name other than localhost, and localhost itself may first resolve to IPv6, adding a long delay (use 127.0.0.1).
  • Chrome only listens on 127.0.0.1, so reaching it from a container or another machine needs a port forward (e.g. netsh interface portproxy on Windows).
  • Anyone who can reach the debugging port has full control of that browser profile. Use a dedicated --user-data-dir and don't expose the port beyond the machines that need it.

See the browser and Docker documentation for a Docker Compose example and troubleshooting.

In code, pass a BrowserConfig instead:

from catholic_mass_readings import USCCB
from catholic_mass_readings.challenge import BrowserConfig

async with USCCB(BrowserConfig(cdp_url="http://127.0.0.1:9222")) as usccb:
    ...

API Usage:

import asyncio
import datetime

from catholic_mass_readings import USCCB, models

# To get a mass for a particular date:
async with USCCB() as usccb:
    mass = await usccb.get_mass(datetime.date(2024, 12, 25), models.MassType.VIGIL)
    print(mass)

# To query for a range of Sunday masses:
async with USCCB() as usccb:
    dates = usccb.get_sunday_mass_dates(datetime.date(2024, 12, 25), datetime.date(2025, 1, 25))
    tasks = [usccb.get_mass_from_date(dt, types) for dt in dates]
    responses = await asyncio.gather(*tasks)
    masses = [m for m in responses if m]
    masses.sort(key=lambda m: m.date.toordinal() if m.date else -1)
    for mass in masses:
        end = "\n" if mass is masses[-1] else "\n\n"
        print(mass, end=end)

# To query for a range of masses (step how you want to):
async with USCCB() as usccb:
    dates = usccb.get_mass_dates(
        datetime.date(2024, 12, 25), datetime.date(2025, 1, 25), step=datetime.timedelta(days=1)
    )
    tasks = [usccb.get_mass_from_date(dt) for dt in dates]
    responses = await asyncio.gather(*tasks)
    masses = [m for m in responses if m]
    masses.sort(key=lambda m: m.date.toordinal() if m.date else -1)
    for mass in masses:
        end = "\n" if mass is masses[-1] else "\n\n"
        print(mass, end=end)

# To query for a list of all the mass types on a particular date:
async with USCCB() as usccb:
    mass_types = await usccb.get_mass_types(datetime.date(2024, 12, 25))
    for mass_type in mass_types:
        print(mass_type.name)

As a CLI

# To get a mass for a particular date:
python -m catholic_mass_readings get-mass --date 2024-12-25 --type vigil

# To query for a range of Sunday masses:
python -m catholic_mass_readings get-sunday-mass-range --start 2024-12-25 --end 2025-01-01

# To query for a range of masses (step how you want to):
python -m catholic_mass_readings get-mass-range --start 2024-12-25 --end 2025-01-01 --step 7

# To query for a list of mass types on a particular date:
python -m catholic_mass_readings get-mass-types --date 2025-12-25

# or saving to a file...

# To get a mass for a particular date:
python -m catholic_mass_readings get-mass --date 2024-12-25 --type vigil --save mass.json

# To query for a range of Sunday masses:
python -m catholic_mass_readings get-sunday-mass-range --start 2024-12-25 --end 2025-01-01 --save mass.json

# To query for a range of masses (step how you want to):
python -m catholic_mass_readings get-mass-range --start 2024-12-25 --end 2025-01-01 --step 7 --save mass.json

Documentation

The documentation for catholic-mass-readings can be found here or in the project's docstrings.

Development

Setup Python Environment:

Run scripts/console.sh uv install

The first time run

uvx pre-commit install

If you need to relock:

Run scripts/lock.sh

Run code

Run scripts/console.sh uv run python -m catholic_mass_readings

Testing

Generating Test Data

uv run python -m catholic_mass_readings get-mass --date "2025-08-06" -t DEFAULT --save tests/data/mass-single-reading.json

uv run python -m catholic_mass_readings get-mass --date "2025-08-10" -t DEFAULT --save tests/data/mass-multiple-readings.json

Run tests

uv run pytest

Metadata

Release files for catholic-mass-readings 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for catholic-mass-readings 0.8.1
File Size Uploaded Provenance Actions
catholic_mass_readings-0.8.1.tar.gz 79.7 kB Without provenance Details for catholic_mass_readings-0.8.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for catholic-mass-readings 0.8.1
File Interpreter ABI Platform Actions
catholic_mass_readings-0.8.1-py3-none-any.whl Python 3 none any Details for catholic_mass_readings-0.8.1-py3-none-any.whl

Total release size: 114.0 kB

Release files / catholic_mass_readings-0.8.1.tar.gz

Download URL catholic_mass_readings-0.8.1.tar.gz
Size 79.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1893f898567ee6cb3f0cce49f43d83303dc261edd07be0190d6db13e05caef76
BLAKE2b-256 checksum
How to use checksums
4c356a86048be52af13439e57f4f79ba47b7a3ba0b1110d02241f25a8bac15d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / catholic_mass_readings-0.8.1-py3-none-any.whl

Download URL catholic_mass_readings-0.8.1-py3-none-any.whl
Size 34.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9e6cd26f223ba9022bb587540f4cae0ab313d49de6eccc4b80365b9c8011ab0
BLAKE2b-256 checksum
How to use checksums
bfb0103321cec5d730459729f8039b7dab3c7cb17b1fe8329279dfb4df846325
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for catholic-mass-readings 0.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page