Skip to content

Commit

Permalink
Merge pull request #3 from vpetersson/args
Browse files Browse the repository at this point in the history
Pave way for GH Actions
  • Loading branch information
vpetersson committed Jan 2, 2024
2 parents 89adf6d + 1e707b2 commit 7a8372d
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3.9-slim

# Install ffmpeg
RUN apt-get update && \
apt-get install -y ffmpeg && \
rm -rf /var/lib/apt/lists/*

# Copy your script and requirements file
COPY rss_generator.py /rss_generator.py
COPY requirements.txt /requirements.txt

# Install Python dependencies
RUN pip install --no-cache-dir -r /requirements.txt

# Set the entrypoint to your script
ENTRYPOINT ["python", "/rss_generator.py"]
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ This tool was written for my podcast [Nerding Out with Viktor](https://blog.vikt
- Converts ISO format dates to RFC 2822 format
- Attempts to follow [The Podcast RSS Standard](https://github.com/Podcast-Standards-Project/PSP-1-Podcast-RSS-Specification)

## Known Issues

* Videos uploaded to YouTube [via RSS](https://support.google.com/youtube/answer/13525207?hl=en#zippy=%2Ccan-i-deliver-an-rss-feed-if-i-already-have-a-podcast-on-youtube) will be uploaded as audio.
* Spotify can't handle videos via RSS yet. You will be able to see the episodes in Podcaster, but they will not be processed and sent to Spotify properly. This is apparently a known issue that they are working on resolving.

The workaround for the above issues is to manually upload the episodes.

## Installation

### Prerequisites
Expand Down Expand Up @@ -66,6 +73,57 @@ Now copy your `podcast_feed.xml` to S3/GCS/R2 using a tool like `s3cmd`, `aws` o

**Optional:** You can verify your RSS feed using a tool like [Podbase](https://podba.se/validate/).

## Usage with GitHub Actions

To incorporate this action into your workflow, follow these steps:

1. **Create a Workflow File**:
- In your repository, create a new file under `.github/workflows`, for example, `rss_workflow.yml`.

2. **Set Up the Workflow**:
- Use the following configuration as a starting point:

```yaml
name: Generate Podcast RSS Feed

on: [push, pull_request]

jobs:
generate-rss:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install yamllint
run: pip install yamllint

- name: Lint YAML file
run: yamllint ${{ github.workspace }}/path/to/your/podcast_config.yaml

- name: Run Podcast RSS Generator
uses: vpetersson/podcast-rss-generator@master
with:
input_file: '/workspace/podcast_config.yaml'
output_file: '/workspace/odcast_feed.xml'
```

3. **Customize Your Workflow**:
- Adjust paths to the YAML configuration and the output XML files as per your repository structure.
- Ensure the `uses` field points to `vpetersson/podcast-rss-generator@master` (or specify a specific release tag/version instead of `master`).

4. **Commit and Push Your Workflow**:
- Once you commit this workflow file to your repository, the action will be triggered based on the defined events (e.g., on push or pull request).

### Inputs

Note that you need `/workspace` is mapped to the root of your repository.

- `input_file`: Path to the input YAML file. Default: `podcast_config.yaml`.
- `output_file`: Path for the generated RSS feed XML file. Default: `podcast_feed.xml`.


## Running Tests

To run unit tests, use:
Expand Down
22 changes: 22 additions & 0 deletions actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Podcast RSS Generator'
description: 'Generates a podcast RSS feed from a YAML configuration'
author: 'Viktor Petersson'

runs:
using: 'docker'
image: 'Dockerfile'
args:
- "--input-file"
- ${{ inputs.input_file }}
- "--output-file"
- ${{ inputs.output_file }}

inputs:
input_file:
description: 'Input YAML file'
required: true
default: '/workspace/podcast_config.yaml'
output_file:
description: 'Output XML file'
required: true
default: '/workspace/podcast_feed.xml'
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ PyYAML==6.0.1
requests==2.31.0
Markdown==3.5.1
sh==2.0.6
yamllint==1.33.0
19 changes: 17 additions & 2 deletions rss_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import xml.etree.ElementTree as ET
from datetime import datetime
from email.utils import format_datetime
import argparse

import markdown
import requests
Expand Down Expand Up @@ -200,8 +201,22 @@ def generate_rss(config, output_file_path):


def main():
config = read_podcast_config("podcast_config.yaml")
generate_rss(config, "podcast_feed.xml")
parser = argparse.ArgumentParser(description="Process some parameters.")

parser.add_argument(
"--input-file", type=str, default="podcast_config.yaml", help="Input YAML file"
)
parser.add_argument(
"--output-file", type=str, default="podcast_feed.xml", help="Output XML file"
)

# Parse arguments from the command line
args = parser.parse_args()

print(f"Input file: {args.input_file}, Output file: {args.output_file}")

config = read_podcast_config(args.input_file)
generate_rss(config, args.output_file)


if __name__ == "__main__":
Expand Down

0 comments on commit 7a8372d

Please sign in to comment.