A script to notify you about new releases of Python packages via Discord webhooks. The script checks for updates on the specified packages at regular intervals, stores the information in a SQLite database, and sends notifications when a new version is released.
Upon initial launch, no notifications will be sent until a new update is detected.
- Discord
- Python 3.10 or higher
- Docker (if using Docker setup)
-
Install the package
poetry add pypi-notifier # or pip install pypi-notifier
-
Use in your Python code
from pypi_notifier import PyPiNotifier notifier = PyPiNotifier( discord_webhook="https://discord.com/api/webhooks/...", tracked_packages={ "PySide6": "https://pypi.org/rss/project/PySide6/releases.xml", "TkFontSelector": "https://pypi.org/rss/project/tkfontselector/releases.xml", }, cron_schedule="0 * * * *", # Cron schedule format for checking updates every hour ) # Run the notifier once notifier.run() # Or run continuously as scheduled by cron notifier.run_forever()
To run the Docker container with the appropriate environment variables, use the following command:
docker run -e "DISCORD_WEBHOOK=<your_webhook_url>" -e "TRACKED_PACKAGES=<your_tracked_packages_json>" -e "CRON_SCHEDULE=0 * * * *" -v "app_data:/app_data"
- Replace
<your_webhook_url>
with your Discord webhook URL. - Replace
<your_tracked_packages_json>
with the JSON string of your tracked packages, for example:
{
"PySide6": "https://pypi.org/rss/project/PySide6/releases.xml",
"TkFontSelector": "https://pypi.org/rss/project/tkfontselector/releases.xml"
}
This command will mount the app_data
volume to persist the database and logs across container restarts.
Outside of Docker, you can view the logs in ./app_data/logs/
.
- The
app_data
volume is used for persistent storage, including the SQLite database and logs. - If you're running the script outside Docker, the
app_data
folder will be created in your local directory to store logs and the database. - The cron_schedule format follows standard cron syntax for scheduling tasks. For example,
0 * * * *
runs the script every hour. - If no updates are detected for a package, no notifications will be sent until a newer version is found.
- Error Logs: If something goes wrong, check the logs at
./app_data/logs/
for more details. - Database Issues: Ensure that the SQLite database is properly initialized and accessible.