Skip to content

Presbyterian-Church-of-Coventry/sermon-api

Repository files navigation

Python for PCC

This is a custom API to download, process, and upload sermons automagically with minimal user input.

Manual Deployment

If you would like to run the uploading scripts manually, you can clone this repo, cd into the directory, and

pip3 install -r requirements.txt

Generate an API key with

python3 main.py -key

or simply edit data/api.txt.

Then run the API with

python3 main.py -a

You can find an example of a frontend for the API we actually use in upload.vue.

To authenticate with Google and upload to Youtube, you'll need to generate OAuth2 credentials here with Youtube API access. Download the client_secrets.json file to data/client_secrets.json, then run

python3 main.py -auth

This will open a webpage where you can authenticate your channel, which will generate an oauth2.json file you need to bind to /app/data/oauth2.json on your Docker container. This will keep the container permenantly authenticated.

Finally, rename .env_example to .env and fill the variables in there, then run python3 main.py -a.

Docker Deployment (recommended)

The easiest way to run this API is by pulling the Docker image from coventrypca/sermon-api:latest, or you could clone this repository and build it yourself with docker build ..

If you would like to run the API on bare metal, rename .env_example to .env and fill the variables in there, then run python3 main.py -a.

Use the Docker Compose File as a guide for filling in all the nessecary environment variables. See the chart below for further descriptions:

Env Variable Comment
SA_API_KEY Your SermonAudio API Key. You can find it by signing in and going here
S3_ACCESS_KEY Get your access token for your S3 storage if you have it. If not, don't supply it and this part won't run
S3_SECRET Same as above, but use your secret token here. You could also use Docker secrets as this is sensitive
CHANNEL_ID Supply the ID of the channel you would like to scrape for latest video to scrub through on the web interface.

Google Authentication

To authenticate with Google and upload to Youtube, you'll need to generate OAuth2 credentials here with Youtube API access. Download the client_secrets.json file and bind the file to /app/data/client_secrets.json. First, though, you must run

python3 main.py -auth

This will open a webpage where you can authenticate your channel, which will generate an oauth2.json file you need to bind to /app/data/oauth2.json on your Docker container. This will keep the container permenantly authenticated.

Enjoy! If anyone else ever tries to use this it'll need to be customized a great deal, but the upload pipelines should be ironed out at the very least. Shoot me a message if you have any problems, although the only person who will probably have any issues will be me ;)