have Max2Play on raraspberry pi and with the help of AI it made a script to download the SN podcast and keep the last 50 shows.
Put in it /usr/local/bin/get_security_now.sh
#!/bin/bash
# --- CONFIGURATION ---
AUTH_TOKEN="*******************************"
RSS_URL="https://twit.memberfulcontent.com/rss/9054?auth=$AUTH_TOKEN"
DEST_DIR="/media/USBdisk1-3TB/MEDIA/Audeo/security_now"
KEEP_COUNT=50
# 1. Get RSS data
RSS_DATA=$(curl -s "$RSS_URL")
# Extract the first MP3 URL
MP3_URL=$(echo "$RSS_DATA" | grep -oP '(?<=url=")[^"]+\.mp3' | head -1)
# Extract Title: Look for the first <title> that actually contains "SN "
RAW_TITLE=$(echo "$RSS_DATA" | grep -oP '(?<=<title>).*?(?=</title>)' | grep "SN " | head -1)
# Clean up the Title
if [ -z "$RAW_TITLE" ]; then
# Fallback if title extraction fails
FILE_NAME="SN_$(date +%F).mp3"
else
# Remove the long "Security Now (Audio - Club TWiT) — " prefix
# Remove colons, slashes, and quotes to prevent file system errors
CLEAN_TITLE=$(echo "$RAW_TITLE" | sed 's/Security Now (Audio - Club TWiT) — //g' | sed "s/[:'\"\/]//g")
FILE_NAME="$CLEAN_TITLE.mp3"
fi
# 2. Check if the episode already exists
if [ -f "$DEST_DIR/$FILE_NAME" ]; then
echo "Current episode ($FILE_NAME) is already downloaded."
exit 0
fi
# 3. Download the episode
echo "Downloading: $FILE_NAME"
wget -q -O "$DEST_DIR/$FILE_NAME" "$MP3_URL"
# Send High-Priority notification to iPhone
curl \
-H "Title: Security Now Ready" \
-H "Priority: high" \
-H "Tags: musical_note,floppy_disk" \
-d "Episode: $FILE_NAME" \
https://ntfy.sh/rayday_podcasts
# 4. Cleanup: Keep only the latest 50 files
echo "Ensuring only the latest $KEEP_COUNT episodes remain..."
cd "$DEST_DIR" || exit
# List by time (newest first), skip the first 50, and remove the rest
ls -t *.mp3 | tail -n +$((KEEP_COUNT + 1)) | while read -r old_file; do
rm -f "$old_file"
done
# 5. Trigger Lyrion/LMS Rescan
echo "Refreshing Lyrion library..."
curl -s "http://localhost:9000/rescan" > /dev/null
echo "Success! Total episodes in folder: $(ls -1 *.mp3 | wc -l)"
Then the cron job type in:
crontab -e
Not sure of the time it comes out so could edit this some but put 2 lines in the bottom of the crontab like this:
0 20-23 * * 2 /usr/local/bin/get_security_now.sh >> /var/log/sn_download.log 2>&1
# Check Wednesday early morning (Midnight to 4 AM)
0 0-4 * * 3 /usr/local/bin/get_security_now.sh >> /var/log/sn_download.log 2>&1
Maybe you can post this some place on your webpage if you think it's something all can use.
IA help me do a ntfy.sh I just have to go to this webpage:
https://ntfy.sh/rayday_podcasts
It will show it on my phone too.
I have the paid version so use that just find your AUTH_TOKEN= it will be at the end of the URL and copy it in that spot were the **** are.
Put in it /usr/local/bin/get_security_now.sh
#!/bin/bash
# --- CONFIGURATION ---
AUTH_TOKEN="*******************************"
RSS_URL="https://twit.memberfulcontent.com/rss/9054?auth=$AUTH_TOKEN"
DEST_DIR="/media/USBdisk1-3TB/MEDIA/Audeo/security_now"
KEEP_COUNT=50
# 1. Get RSS data
RSS_DATA=$(curl -s "$RSS_URL")
# Extract the first MP3 URL
MP3_URL=$(echo "$RSS_DATA" | grep -oP '(?<=url=")[^"]+\.mp3' | head -1)
# Extract Title: Look for the first <title> that actually contains "SN "
RAW_TITLE=$(echo "$RSS_DATA" | grep -oP '(?<=<title>).*?(?=</title>)' | grep "SN " | head -1)
# Clean up the Title
if [ -z "$RAW_TITLE" ]; then
# Fallback if title extraction fails
FILE_NAME="SN_$(date +%F).mp3"
else
# Remove the long "Security Now (Audio - Club TWiT) — " prefix
# Remove colons, slashes, and quotes to prevent file system errors
CLEAN_TITLE=$(echo "$RAW_TITLE" | sed 's/Security Now (Audio - Club TWiT) — //g' | sed "s/[:'\"\/]//g")
FILE_NAME="$CLEAN_TITLE.mp3"
fi
# 2. Check if the episode already exists
if [ -f "$DEST_DIR/$FILE_NAME" ]; then
echo "Current episode ($FILE_NAME) is already downloaded."
exit 0
fi
# 3. Download the episode
echo "Downloading: $FILE_NAME"
wget -q -O "$DEST_DIR/$FILE_NAME" "$MP3_URL"
# Send High-Priority notification to iPhone
curl \
-H "Title: Security Now Ready" \
-H "Priority: high" \
-H "Tags: musical_note,floppy_disk" \
-d "Episode: $FILE_NAME" \
https://ntfy.sh/rayday_podcasts
# 4. Cleanup: Keep only the latest 50 files
echo "Ensuring only the latest $KEEP_COUNT episodes remain..."
cd "$DEST_DIR" || exit
# List by time (newest first), skip the first 50, and remove the rest
ls -t *.mp3 | tail -n +$((KEEP_COUNT + 1)) | while read -r old_file; do
rm -f "$old_file"
done
# 5. Trigger Lyrion/LMS Rescan
echo "Refreshing Lyrion library..."
curl -s "http://localhost:9000/rescan" > /dev/null
echo "Success! Total episodes in folder: $(ls -1 *.mp3 | wc -l)"
Then the cron job type in:
crontab -e
Not sure of the time it comes out so could edit this some but put 2 lines in the bottom of the crontab like this:
0 20-23 * * 2 /usr/local/bin/get_security_now.sh >> /var/log/sn_download.log 2>&1
# Check Wednesday early morning (Midnight to 4 AM)
0 0-4 * * 3 /usr/local/bin/get_security_now.sh >> /var/log/sn_download.log 2>&1
Maybe you can post this some place on your webpage if you think it's something all can use.
IA help me do a ntfy.sh I just have to go to this webpage:
https://ntfy.sh/rayday_podcasts
It will show it on my phone too.
I have the paid version so use that just find your AUTH_TOKEN= it will be at the end of the URL and copy it in that spot were the **** are.

