Last active
May 22, 2024 09:45
-
-
Save davenicoll/0aa2a6346523f01acdf636248b38fae8 to your computer and use it in GitHub Desktop.
get-iplayer hasn't downloaded properly for a long time, but youtube-dl works great. get-iplayer is still the best iplayer search though, and I already have a download_history, so this script bridges the gap and gives you the best of both worlds.
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/bash | |
DOWNLOAD_HISTORY="$HOME/.get_iplayer/download_history" | |
already_downloaded(){ | |
if [ "$(grep -c $1 ~/.get_iplayer/download_history)" -gt 0 ]; then | |
return | |
else | |
false | |
fi | |
} | |
download() | |
{ | |
youtube-dl "https://www.bbc.co.uk/iplayer/episode/$1" | |
if [ $? -eq 0 ]; then | |
add_to_download_history $1 | |
fi | |
} | |
add_to_download_history() | |
{ | |
echo "$1|Downloaded by get_iplayer_next||||||||||||||||" >> "$DOWNLOAD_HISTORY" | |
} | |
RESULTS=$(get-iplayer "$@" --nocopyright | tail -n +3 | head -n -1) | |
OLDIFS=$IFS | |
IFS=$'\n' | |
for LINE in $RESULTS | |
do | |
TITLE="$(echo ${LINE##* } | cut -d ',' -f 1 )" | |
PID=$(echo "$LINE" | cut -d ',' -f 3 | sed -e 's/^[[:space:]]*//') | |
echo -e "\033[95m$TITLE\033[0m" | |
if already_downloaded "$PID"; then | |
echo "- Already downloaded" | |
else | |
echo "- Downloading..." | |
download "$PID" | |
fi | |
done | |
IFS=$OLDIFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment