Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterprovoost committed Jul 23, 2024
0 parents commit ccd5ec7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Generate feed

on:
workflow_dispatch:
schedule:
- cron: "0 10 * * 2"

jobs:
generate-data:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Generate feed
run: python script.py
- name: Commit results
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add feed.rss
git commit -m "Update feed"
git push
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
1 change: 1 addition & 0 deletions feed.rss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<rss><channel><pubDate>Tue, 23 Jul 2024 23:55:21 -0000</pubDate><item><title>https://invertebase.org/portal/content/dwca/DMNH-Mollusk_DwC-A.zip</title><link>https://invertebase.org/portal/content/dwca/DMNH-Mollusk_DwC-A.zip</link><ipt:dwca>https://invertebase.org/portal/content/dwca/DMNH-Mollusk_DwC-A.zip</ipt:dwca><pubDate>Tue, 23 Jul 2024 23:55:21 -0000</pubDate></item><item><title>https://invertebase.org/portal/content/dwca/ANSP-MAL_DwC-A.zip</title><link>https://invertebase.org/portal/content/dwca/ANSP-MAL_DwC-A.zip</link><ipt:dwca>https://invertebase.org/portal/content/dwca/ANSP-MAL_DwC-A.zip</ipt:dwca><pubDate>Tue, 23 Jul 2024 23:55:21 -0000</pubDate></item></channel></rss>
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-dateutil
20 changes: 20 additions & 0 deletions script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from email.utils import format_datetime
from datetime import datetime


pubdate = format_datetime(datetime.now())
output = f"<rss><channel><pubDate>{pubdate}</pubDate>"

endpoints = [
"https://invertebase.org/portal/content/dwca/DMNH-Mollusk_DwC-A.zip",
"https://invertebase.org/portal/content/dwca/ANSP-MAL_DwC-A.zip"
]

for endpoint in endpoints:
output = output + f"<item><title>{endpoint}</title><link>{endpoint}</link><ipt:dwca>{endpoint}</ipt:dwca><pubDate>{pubdate}</pubDate></item>"

output = output + "</channel></rss>"

file = open("feed.rss", "w")
file.write(output)
file.close()

0 comments on commit ccd5ec7

Please sign in to comment.