From 62ed455d92ee0dfb48593b229f62892f7a8306fb Mon Sep 17 00:00:00 2001 From: Viktor Petersson Date: Sun, 31 Dec 2023 15:36:53 +0000 Subject: [PATCH 1/9] Adds arg parsing to pave way for GH Actions --- Dockerfile | 16 ++++++++++++++++ requirements.txt | 1 + rss_generator.py | 20 ++++++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a11d1c9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.9-slim + +# Install ffmpeg and yamllint +RUN apt-get update && \ + apt-get install -y ffmpeg yamllint && \ + 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"] diff --git a/requirements.txt b/requirements.txt index e3aa5cf..9b7fc7e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ PyYAML==6.0.1 requests==2.31.0 Markdown==3.5.1 sh==2.0.6 +yamllint==1.33.0 diff --git a/rss_generator.py b/rss_generator.py index fa0cfc5..43adac7 100644 --- a/rss_generator.py +++ b/rss_generator.py @@ -1,6 +1,8 @@ import xml.etree.ElementTree as ET from datetime import datetime from email.utils import format_datetime +import argparse +import sys import markdown import requests @@ -200,8 +202,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__": From ffce40700d1f09365661692699a57a4a768988b4 Mon Sep 17 00:00:00 2001 From: Viktor Petersson Date: Sun, 31 Dec 2023 15:40:37 +0000 Subject: [PATCH 2/9] Removes duplicate yamllint --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a11d1c9..922a35b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.9-slim # Install ffmpeg and yamllint RUN apt-get update && \ - apt-get install -y ffmpeg yamllint && \ + apt-get install -y ffmpeg && \ rm -rf /var/lib/apt/lists/* # Copy your script and requirements file From 910079cb93953c53b1ec64abaca57880c6143c5b Mon Sep 17 00:00:00 2001 From: Viktor Petersson Date: Sun, 31 Dec 2023 15:44:06 +0000 Subject: [PATCH 3/9] Formatting and remove unnecessary dep --- rss_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rss_generator.py b/rss_generator.py index 43adac7..e9c1fbd 100644 --- a/rss_generator.py +++ b/rss_generator.py @@ -1,8 +1,8 @@ +import argparse +import sys import xml.etree.ElementTree as ET from datetime import datetime from email.utils import format_datetime -import argparse -import sys import markdown import requests From ad9d607b9dedc1e24c65bdd69150da759ddd0094 Mon Sep 17 00:00:00 2001 From: Viktor Petersson Date: Sun, 31 Dec 2023 15:48:47 +0000 Subject: [PATCH 4/9] Cleanup --- Dockerfile | 2 +- rss_generator.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 922a35b..ecf97f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.9-slim -# Install ffmpeg and yamllint +# Install ffmpeg RUN apt-get update && \ apt-get install -y ffmpeg && \ rm -rf /var/lib/apt/lists/* diff --git a/rss_generator.py b/rss_generator.py index e9c1fbd..92a76fe 100644 --- a/rss_generator.py +++ b/rss_generator.py @@ -1,8 +1,7 @@ -import argparse -import sys import xml.etree.ElementTree as ET from datetime import datetime from email.utils import format_datetime +import argparse import markdown import requests From 9626ec06b53e9ee6b12f286e6437e0fa86221edb Mon Sep 17 00:00:00 2001 From: Viktor Petersson Date: Tue, 2 Jan 2024 15:23:05 +0000 Subject: [PATCH 5/9] Adds known issues --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index a0fa72d..b7c6352 100644 --- a/README.md +++ b/README.md @@ -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 From cbbb4fc0491f5da7613782194b056a651b1eb455 Mon Sep 17 00:00:00 2001 From: Viktor Petersson Date: Tue, 2 Jan 2024 16:12:07 +0000 Subject: [PATCH 6/9] Adds actions.yml file --- actions.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 actions.yml diff --git a/actions.yml b/actions.yml new file mode 100644 index 0000000..35bf555 --- /dev/null +++ b/actions.yml @@ -0,0 +1,22 @@ +name: 'Podcast RSS Generator' +description: 'Generates a podcast RSS feed from a YAML configuration' +author: 'Your Name' + +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' From 27bd174406a1b3bc87daf9ab422b0f46ba17db42 Mon Sep 17 00:00:00 2001 From: Viktor Petersson Date: Tue, 2 Jan 2024 16:25:29 +0000 Subject: [PATCH 7/9] Adds README update --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index b7c6352..8125ce6 100644 --- a/README.md +++ b/README.md @@ -73,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: From 77f68849e616e2e5f07ad5153273fc7bd18573b0 Mon Sep 17 00:00:00 2001 From: Viktor Petersson Date: Tue, 2 Jan 2024 16:26:11 +0000 Subject: [PATCH 8/9] Adds author --- actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions.yml b/actions.yml index 35bf555..df8ffd5 100644 --- a/actions.yml +++ b/actions.yml @@ -1,6 +1,6 @@ name: 'Podcast RSS Generator' description: 'Generates a podcast RSS feed from a YAML configuration' -author: 'Your Name' +author: 'Viktor Petersson' runs: using: 'docker' From 1e707b205ef7bb5c1a5d3402ac5b63278102b524 Mon Sep 17 00:00:00 2001 From: Viktor Petersson Date: Tue, 2 Jan 2024 16:27:45 +0000 Subject: [PATCH 9/9] Fixes sentence --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8125ce6..2fa1f63 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ This tool was written for my podcast [Nerding Out with Viktor](https://blog.vikt ## 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 +* 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.