Skip to content

Instantly share code, notes, and snippets.

@EldonMcGuinness
Created October 16, 2024 19:05
Show Gist options
  • Save EldonMcGuinness/4ccbd011a6eb1252961fe08dc4551fd9 to your computer and use it in GitHub Desktop.
Save EldonMcGuinness/4ccbd011a6eb1252961fe08dc4551fd9 to your computer and use it in GitHub Desktop.
Manage TV Schedule for Kids
#!/bin/bash
TOKEN="YOUR_SECRET_KEY"
LUKAH=USERID1
MICAH=USERID2
NAME=""
LOG=/var/log/tvfilter.log
function datestamp {
echo $(date +'%Y/%m/%d %H:%M')
}
plex_call () {
echo "[$(datestamp)] Filter: [$1|$2]" | tee -a $LOG
curl -X PUT \
-d "filterTelevision=label%3D$1" \
-d "filterMovies=label%3D$1" \
-d "X-Plex-Token=$TOKEN" \
https://plex.tv/api/users/$2
echo "[$(datestamp)] Call Result: [$?]" | tee -a $LOG
}
case $2 in
micah)
NAME=$MICAH
;;
MICAH)
NAME=$MICAH
;;
lukah)
NAME=$LUKAH
;;
LUKAH)
NAME=$LUKAH
;;
esac
if [ "$1" == "edu-basic" ]; then
LABEL="Youth-Educational-Basic"
plex_call "$LABEL" $NAME
sleep 5;
plex_call "$LABEL" $NAME
sleep 5;
fi
if [ "$1" == "all" ]; then
LABEL="Youth"
plex_call "$LABEL" $NAME
sleep 5;
plex_call "$LABEL" $NAME
sleep 5;
elif [ "$1" == "sleep" ]; then
LABEL="Youth-Bedtime"
plex_call "$LABEL" $NAME
sleep 5;
plex_call "$LABEL" $NAME
sleep 5;
elif [ "$1" == "edu" ]; then
LABEL="Youth-Educational"
plex_call "$LABEL" $NAME
sleep 5;
plex_call "$LABEL" $NAME
sleep 5;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment