Skip to content

Instantly share code, notes, and snippets.

@normand1
Created June 18, 2023 13:20
Show Gist options
  • Save normand1/37dfea6cdad39314b52858b682ca9fe8 to your computer and use it in GitHub Desktop.
Save normand1/37dfea6cdad39314b52858b682ca9fe8 to your computer and use it in GitHub Desktop.
#!/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