Created
June 18, 2023 13:20
-
-
Save normand1/37dfea6cdad39314b52858b682ca9fe8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Download the RSS feed | |
curl -s https://feeds.noagendaassets.com/noagenda.xml > rss.xml | |
# Initialize an empty JSON object | |
json='{}' | |
# Iterate over the items in the feed | |
awk '/<item>/,/<\/item>/' rss.xml | while read -r line; do | |
if [[ $line =~ '<title>' ]]; then | |
# Extract the title | |
title=$(echo $line | awk -F'<title>' '{n=split($2,a,"</title>"); if (n>1) print a[1]}') | |
elif [[ $line =~ '<podcast:chapters' ]]; then | |
# Extract the URL | |
url=$(echo $line | awk -F'url="' '{n=split($2,a,"\""); if (n>1) print a[1]}') | |
# Add the title and URL to the JSON object | |
json=$(echo $json | jq --arg t "$title" --arg u "$url" '.[$t] = {"chapters": $u}') | |
fi | |
done | |
# Print the JSON object | |
echo $json | jq . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment