From 8a05c816c6878628822602ff61656bc8bc86ddac Mon Sep 17 00:00:00 2001 From: Moe Fwacky Date: Sat, 13 Oct 2018 08:27:17 -0700 Subject: [PATCH 1/8] Add files via upload --- pseudo-channel-control.sh | 180 ++++++++++++ schedule-editor.sh | 584 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 764 insertions(+) create mode 100644 pseudo-channel-control.sh create mode 100644 schedule-editor.sh diff --git a/pseudo-channel-control.sh b/pseudo-channel-control.sh new file mode 100644 index 0000000..93dc386 --- /dev/null +++ b/pseudo-channel-control.sh @@ -0,0 +1,180 @@ +#!/bin/bash +source config.cache +re='^[0-9]+$' +number_of_channels=$(ls | grep pseudo-channel_ | wc -l) +clear +echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" +echo "Choose a CATEGORY" +select category in "CONTROL" "EDIT" "UPDATE" "EXIT" + do + sleep 1 + clear + echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" + if [[ "$category" == "CONTROL" ]] + then + echo "PSEUDO CHANNEL CONTROL OPTIONS" + select pseudo_channel_do in "START CHANNEL" "NEXT CHANNEL" "PREVIOUS CHANNEL" "STOP CHANNEL" "BACK" + do + sleep 1 + clear + echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" + if [[ "$pseudo_channel_do" == "START CHANNEL" ]] + then + echo "PSEUDO CHANNEL - START CHANNEL" + echo "Enter CHANNEL NUMBER between 1 and $number_of_channels" + read -p "Channel: " channel_number + while ! [[ $channel_number =~ $re ]] # VALIDATES THAT CHANNEL NUMBER IS ACTUALLY A NUMBER + do + echo "Enter CHANNEL NUMBER between 1 and $number_of_channels" + read -p "Channel: " channel_number + done + while ! [[ $channel_number -ge 1 && $channel_number -le $number_of_channels ]] + do + echo "ERROR: Channel NOT FOUND." + echo "Channels must be between 1 and $number_of_channels" + echo "Enter CHANNEL NUMBER" + read -p 'Channel: ' channel_number + done + if [[ $channel_number -ge 1 && $channel_number -le 9 ]] + then + (sudo ./manual.sh 0"$channel_number") + else + (sudo ./manual.sh "$channel_number") + fi + break + fi + if [[ "$pseudo_channel_do" == "NEXT CHANNEL" ]] + then + (sudo ./channelup.sh) + fi + if [[ "$pseudo_channel_do" == "PREVIOUS CHANNEL" ]] + then + (sudo ./channeldown.sh) + fi + if [[ "$pseudo_channel_do" == "STOP CHANNEL" ]] + then + (sudo ./stop-all-channels.sh) + fi + if [[ "$pseudo_channel_do" == "BACK" ]] + then + break + fi + sleep 1 + clear + echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" + echo "PSEUDO CHANNEL CONTROL OPTIONS" + echo "1) START CHANNEL 3) PREVIOUS CHANNEL 5) BACK" + echo "2) NEXT CHANNEL 4) STOP CHANNEL" + done + fi + if [[ "$category" == "EDIT" ]] + then + sleep 1 + clear + echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" + echo "PSEUDO CHANNEL EDIT OPTIONS" + select pseudo_channel_do in "EDIT SCHEDULE" "EDIT CONFIG" "ADD CLIENT" "BACK" + do + sleep 1 + clear + echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" + if [[ "$pseudo_channel_do" == "EDIT SCHEDULE" ]] + then + (sudo ./schedule-editor.sh) + fi + if [[ "$pseudo_channel_do" == "EDIT CONFIG" ]] + then + (sudo ./config_editor.sh) + fi + if [[ "$pseudo_channel_do" == "ADD CLIENT" ]] + then + echo "SELECT the PLEX CLIENT for the NEW CLIENT SETUP or ENTER one manually" + clientlist=$(xmllint --xpath "//Server/@name" "http://$server_ip:$server_port/clients" | sed "s|name=||g" | sed "s|^ ||g" && echo -e " Other") + eval set $clientlist + select create_box_client in "$@" + do + if [[ "$create_box_client" == "Other" ]] + then + read -p 'Client Name: ' create_box_client + create_box_client=$(eval echo $create_box_client) + fi + break + done + (sudo ./create_box.sh "$create_box_client") + fi + if [[ "$pseudo_channel_do" == "BACK" ]] + then + break + fi + sleep 1 + clear + echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" + echo "PSEUDO CHANNEL EDIT OPTIONS" + echo "1) EDIT SCHEDULE" + echo "2) EDIT CONFIG" + echo "3) ADD CLIENT" + echo "4) BACK" + done + fi + if [[ "$category" == "UPDATE" ]] + then + echo "PSEUDO CHANNEL UPDATE OPTIONS" + select pseudo_channel_do in "DATABASE UPDATE" "SOFTWARE UPDATE" "BACK" + do + sleep 1 + clear + echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" + if [[ "$pseudo_channel_do" == "DATABASE UPDATE" ]] + then + echo "Select DATABASE to UPDATE" + select update_database in "TV Shows" "Movies" "Commercials" "All" + do + if [[ "$update_database" == "TV Shows" ]] + then + (sudo python Global_DatabaseUpdate.py -ut) + elif [[ "$update_database" == "Movies" ]] + then + (sudo python Global_DatabaseUpdate.py -um) + elif [[ "$update_database" == "Commercials" ]] + then + (sudo python Global_DatabaseUpdate.py -uc) + elif [[ "$update_database" == "All" ]] + then + (sudo python Global_DatabaseUpdate.py -u) + fi + break + done + fi + if [[ "$pseudo_channel_do" == "SOFTWARE UPDATE" ]] + then + (sudo ./update-channels-from-git.sh) + fi + if [[ "$pseudo_channel_do" == "BACK" ]] + then + break + fi + sleep 1 + clear + echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" + echo "PSEUDO CHANNEL UPDATE OPTIONS" + echo "1) DATABASE UPDATE" + echo "2) SOFTWARE UPDATE" + echo "3) BACK" + done + fi + if [[ "$category" == "EXIT" ]] + then + echo "EXITING PSEUDO CHANNEL CONTROL SCRIPT..." + sleep 1 + clear + exit + fi +sleep 1 +clear +echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" +echo "Choose a CATEGORY" +echo "1) CONTROL" +echo "2) EDIT" +echo "3) UPDATE" +echo "4) EXIT" +done diff --git a/schedule-editor.sh b/schedule-editor.sh new file mode 100644 index 0000000..cd560ee --- /dev/null +++ b/schedule-editor.sh @@ -0,0 +1,584 @@ +#!/bin/bash +source config.cache +re='^[0-9]+$' +number_of_channels=$(ls | grep pseudo-channel_ | wc -l) +channel_number=$1 +loop_or_exit=loop + +time_entry() { +sleep 1 +clear +echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" +echo "ENTER the START TIME for THIS ENTRY in 24h format" +read -p 'Time (24h): ' start_time +echo "START TIME set to $start_time" +sleep 1 +clear +echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" +echo "Choose MEDIA TYPE to start at $start_time" +select media_type in "Movie" "TV Series" "Random TV Episode" + do + sleep 1 + clear + echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" + if [[ "$media_type" == "Movie" ]] + then + type="\"movie\"" + entry="MOVIE" + #echo "ENTER the MOVIE TITLE" + #read -p 'Title: ' title + title="\"random\"" + elif [[ "$media_type" == "TV Series" ]] + then + type="\"series\"" + echo "ENTER the TV SERIES title" + read -p 'Title: ' title + entry="SHOW" + title=$(echo $title | recode ..html) + title="\"$title\"" + elif [[ "$media_type" == "Random TV Episode" ]] + then + type="\"random\"" + echo "ENTER the NAME of the TV SHOW to schedule RANDOM EPISODES from" + read -p 'Title: ' title + entry="SHOW" + title=$(echo $title | recode ..html) + title="\"$title\"" + fi + break +done +sleep 1 +clear +echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" +echo "Start this $entry to start at the EXACT TIME specified or AFTER" +echo "the PREVIOUS show or movie ENDS?" +select strict_time_entry in "Exact Time" "After Previous" + do + if [[ $strict_time_entry == "Exact Time" ]] + then + strict_time="\"true\"" + time_shift="\"1\"" + echo "The $entry $title will play at exactly $start_time" + elif [[ $strict_time_entry == "After Previous" ]] + then + sleep 1 + clear + echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" + strict_time="\"false\"" + echo "TIME SHIFT VALUE" + echo "This value will determine how much commercial time will be placed" + echo "in between the end of the previous show or movie and the start of this $entry" + echo "The value entered will restrict the start time to a time that ends in that number" + echo "FOR EXAMPLE: A value of 5 will allow the $entry to start at" + echo "5, 10, 15, 20, etc. after the hour. A value of 30 will only allow the $entry to" + echo "start on the half-hour. A value of 2 will restrict start times to even-numbered minutes only." + echo "ENTER the TIME SHIFT value" + read -p 'Time Shift: ' time_shift_entry + time_shift="\"$time_shift_entry\"" + while ! [[ $time_shift_entry =~ $re ]] + do + echo "ENTER the TIME SHIFT value" + read -p 'Time Shift: ' time_shift_entry + time_shift="\"$time_shift_entry\"" + done + fi +break +done +if [[ $media_type == "Movie" ]] + then + sleep 1 + clear + echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" + echo "Restrict RANDOM MOVIE selection based on available PLEX METADATA?" + read -p 'Y/N: ' add_xtra + while [[ "$add_xtra" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "Restrict RANDOM MOVIE selection based on available PLEX METADATA?" + read -p 'Y/N: ' add_xtra + done + if [[ "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + sleep 1 + clear + echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" + select xtra_tag in "Studio" "MPAA Rating" "Year" "Decade" "Genre" "Director" "Writer" "Actor" "Collection" + do + sleep 1 + clear + echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" + if [[ "$xtra_tag" == "Studio" ]] + then + echo "Enter the NAME of the MOVIE STUDIO(S) to FILTER by (Example: Amblin Entertainment)." + enter_studio=yes + echo -n "studio:" > xtra.temp + while [[ "$enter_studio" == @(Y|y|Yes|yes|YES) ]] + do + read -p 'Studio(s) :' xtra_studio + echo -n "$xtra_studio" >> xtra.temp + echo "ENTER another STUDIO?" + echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." + read -p 'Y/N: ' enter_studio + while [[ "$enter_studio" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ENTER another STUDIO?" + read -p 'Y/N: ' enter_studio + done + if [[ "$enter_studio" == @(Y|y|Yes|yes|YES) ]] + then + echo -n "," >> xtra.temp + fi + done + fi + if [[ "$xtra_tag" == "MPAA Rating" ]] + then + echo "ADD the MPAA RATING(s) to FILTER by (Example: PG-13)" + enter_rating=yes + echo -n "contentRating:" > xtra.temp + while [[ "$enter_rating" == @(Y|y|Yes|yes|YES) ]] + do + read -p 'Rating(s): ' xtra_rating + echo -n "$xtra_rating" >> xtra.temp + echo "ENTER another RATING?" + echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." + read -p 'Y/N: ' enter_rating + while [[ "$enter_rating" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ENTER another RATING?" + read -p 'Y/N: ' enter_rating + done + if [[ "$enter_rating" == @(Y|y|Yes|yes|YES) ]] + then + echo -n "," >> xtra.temp + fi + done + fi + if [[ "$xtra_tag" == "Year" ]] + then + echo "ADD RELEASE YEAR(S) to FILTER by (Example: 1982)" + echo -n "year:" > xtra.temp + read -p 'Year(s): ' xtra_year + echo -n "$xtra_year" >> xtra.temp + fi + if [[ "$xtra_tag" == "Decade" ]] + then + echo "ADD the DECADE of release to FILTER by (Example: 1980)" + echo -n "decade:" > xtra.temp + read -p 'Decade: ' xtra_decade + echo -n "$xtra_decade" >> xtra.temp + fi + if [[ "$xtra_tag" == "Genre" ]] + then + echo "ENTER GENRES to the RANDOM MOVIE FILTER (Example: Action)" + enter_genre=yes + echo -n "genre:" > xtra.temp + while [[ "$enter_genre" == @(Y|y|Yes|yes|YES) ]] + do + read -p 'Genre: ' xtra_genre + echo -n "$xtra_genre" >> xtra.temp + echo "ENTER another GENRE?" + echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." + read -p 'Y/N: ' enter_genre + while [[ "$enter_genre" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ENTER another GENRE?" + read -p 'Y/N: ' enter_genre + done + if [[ "$enter_genre" == @(Y|y|Yes|yes|YES) ]] + then + echo -n "," >> xtra.temp + fi + done + fi + if [[ "$xtra_tag" == "Director" ]] + then + echo "FILTER by the following DIRECTOR(S) (Example: Taika Waititi)" + enter_director=yes + echo -n "director:" > xtra.temp + while [[ "$enter_director" == @(Y|y|Yes|yes|YES) ]] + do + read -p 'Director: ' xtra_director + echo -n "$xtra_genre" >> xtra.temp + echo "ENTER another GENRE?" + echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." + read -p 'Y/N: ' enter_director + while [[ "$enter_director" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ENTER another DIRECTOR?" + read -p 'Y/N: ' enter_director + done + if [[ "$enter_director" == @(Y|y|Yes|yes|YES) ]] + then + echo -n "," >> xtra.temp + fi + done + fi + if [[ "$xtra_tag" == "Writer" ]] + then + echo "ADD WRITER(S) to FILTER by (Example: Sandra Bullock)" + enter_writer=yes + echo -n "Writer:" > xtra.temp + while [[ "$enter_writer" == @(Y|y|Yes|yes|YES) ]] + do + read -p 'Writer: ' xtra_writer + echo -n "$xtra_writer" >> xtra.temp + echo "ENTER another WRITER?" + echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." + read -p 'Y/N: ' enter_writer + while [[ "$enter_writer" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ENTER another writer?" + read -p 'Y/N: ' enter_writer + done + if [[ "$enter_writer" == @(Y|y|Yes|yes|YES) ]] + then + echo -n "," >> xtra.temp + fi + done + fi + if [[ "$xtra_tag" == "Actor" ]] + then + echo "ADD ACTOR(S) to FILTER by (Example: Sandra Bullock)" + enter_actor=yes + echo -n "Actor:" > xtra.temp + while [[ "$enter_actor" == @(Y|y|Yes|yes|YES) ]] + do + read -p 'Actor: ' xtra_writer + echo -n "$xtra_actor" >> xtra.temp + echo "ENTER another ACTOR?" + echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." + read -p 'Y/N: ' enter_actor + while [[ "$enter_actor" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ENTER another actor?" + read -p 'Y/N: ' enter_actor + done + if [[ "$enter_actor" == @(Y|y|Yes|yes|YES) ]] + then + echo -n "," >> xtra.temp + fi + done + fi + if [[ "$xtra_tag" == "Collection" ]] + then + echo "A COLLECTION is a user-defined TAG. Any selection of MOVIES can be added to a COLLECTION" + echo "and DEFINED here to be FILTERED by. (Example: Marvel Movies or Halloween Movies)" + echo -n "collection:" > xtra.temp + read -p 'Collection(s): ' xtra_collection + echo -n "$xtra_collection" >> xtra.temp + fi + xtra=$(cat xtra.temp) + xtra="\"$xtra\"" + break + done + else + > xtra.temp + fi +fi +overlap_max="\"30\"" +} +clear +echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" +if [[ $channel_number == '' ]] # IF NO ARGUMENT PROVIDED, ASK IF USER WANTS TO EDIT THE MAIN CONFIG OR SELECT A CHANNEL + then + echo "CHOOSE which CHANNEL SCHEDULE to create." + echo "Enter CHANNEL NUMBER between 1 and $number_of_channels" + read -p 'Channel Number: ' channel_number + while ! [[ $channel_number =~ $re ]] # VALIDATES THAT CHANNEL NUMBER IS ACTUALLY A NUMBER + do + echo "Enter CHANNEL NUMBER" + read -p 'Channel Number: ' channel_number + done + while ! [[ $channel_number -ge 1 && $channel_number -le $number_of_channels ]] # VALIDATES CHANNEL NUMBER AGAINST ACTUAL CHANNELS + do + echo "ERROR: Channel NOT FOUND." + echo "Channels must be between 1 and $number_of_channels" + echo "Enter CHANNEL NUMBER" + read -p 'Channel Number: ' channel_number + done +fi + echo "Now editing the schedule for CHANNEL $channel_number" + if [[ $channel_number -ge 1 && $channel_number -le 9 ]] # SET DIRECTORY TO SELECTED CHANNEL + then + cd pseudo-channel_0"$channel_number" + elif [[ $channel_number -ge 10 ]] + then + cd pseudo-channel_"$channel_number" + fi +sleep 1 +clear +echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" +echo "Backing up CURRENT SCHEDULE FILE..." +sleep 1 +sudo cp pseudo_schedule.xml pseudo_schedule.backup +echo "Creating NEW SCHEDULE FILE..." +echo "" > pseudo_schedule.xml +echo "" >> pseudo_schedule.xml +sleep 1 +clear +echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" +echo "CHOOSE which DAY to SCHEDULE" +select day_of_week in "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Weekends" "Weekdays" "Every Day" "Exit" + do + sleep 1 + clear + echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" + if [[ "$day_of_week" == "Sunday" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Monday" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Tuesday" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Wednesday" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Thursday" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Friday" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Saturday" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Weekends" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Weekdays" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Every Day" ]] + then + echo "" >> pseudo_schedule.xml + enter_time=yes + while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] + do + time_entry + if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] + then + echo "" >> pseudo_schedule.xml + else + echo "" >> pseudo_schedule.xml + fi + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ADD another SHOW or MOVIE?" + read -p 'Y/N: ' enter_time + done + done + echo "" >> pseudo_schedule.xml + fi + if [[ "$day_of_week" == "Exit" ]] + then + echo "FINALIZING SCHEDULE FORMATTING..." + echo "" >> pseudo_schedule.xml + sudo python PseudoChannel.py -xml + echo "CLEANING UP TEMPORARY FILES" + sudo rm xtra.temp + echo "REMOVE BACKUP of Channel $channel_number's previous schedule?" + read -p 'Y/N: ' remove_backup_schedule + while [[ "$remove_backup_schedule" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + clear + echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" + echo "REMOVE BACKUP of Channel $channel_number's previous schedule?" + read -p 'Y/N: ' remove_backup_schedule + done + if [[ "$remove_backup_schedule" == @(Y|y|Yes|yes|YES) ]] + then + sudo rm pseudo_schedule.backup + fi + exit 0 + fi +sleep 1 +clear +echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" +echo "CHOOSE which DAY to SCHEDULE" +echo "1) Sunday 4) Wednesday 7) Saturday 10) Every Day" +echo "2) Monday 5) Thursday 8) Weekends 11) Exit" +echo "3) Tuesday 6) Friday 9) Weekdays" +done From ae86a81b819a3cf81b832858f3b17104e26a0477 Mon Sep 17 00:00:00 2001 From: Moe Fwacky Date: Sat, 13 Oct 2018 08:28:47 -0700 Subject: [PATCH 2/8] Delete pseudo-channel-control.sh --- pseudo-channel-control.sh | 180 -------------------------------------- 1 file changed, 180 deletions(-) delete mode 100644 pseudo-channel-control.sh diff --git a/pseudo-channel-control.sh b/pseudo-channel-control.sh deleted file mode 100644 index 93dc386..0000000 --- a/pseudo-channel-control.sh +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/bash -source config.cache -re='^[0-9]+$' -number_of_channels=$(ls | grep pseudo-channel_ | wc -l) -clear -echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" -echo "Choose a CATEGORY" -select category in "CONTROL" "EDIT" "UPDATE" "EXIT" - do - sleep 1 - clear - echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" - if [[ "$category" == "CONTROL" ]] - then - echo "PSEUDO CHANNEL CONTROL OPTIONS" - select pseudo_channel_do in "START CHANNEL" "NEXT CHANNEL" "PREVIOUS CHANNEL" "STOP CHANNEL" "BACK" - do - sleep 1 - clear - echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" - if [[ "$pseudo_channel_do" == "START CHANNEL" ]] - then - echo "PSEUDO CHANNEL - START CHANNEL" - echo "Enter CHANNEL NUMBER between 1 and $number_of_channels" - read -p "Channel: " channel_number - while ! [[ $channel_number =~ $re ]] # VALIDATES THAT CHANNEL NUMBER IS ACTUALLY A NUMBER - do - echo "Enter CHANNEL NUMBER between 1 and $number_of_channels" - read -p "Channel: " channel_number - done - while ! [[ $channel_number -ge 1 && $channel_number -le $number_of_channels ]] - do - echo "ERROR: Channel NOT FOUND." - echo "Channels must be between 1 and $number_of_channels" - echo "Enter CHANNEL NUMBER" - read -p 'Channel: ' channel_number - done - if [[ $channel_number -ge 1 && $channel_number -le 9 ]] - then - (sudo ./manual.sh 0"$channel_number") - else - (sudo ./manual.sh "$channel_number") - fi - break - fi - if [[ "$pseudo_channel_do" == "NEXT CHANNEL" ]] - then - (sudo ./channelup.sh) - fi - if [[ "$pseudo_channel_do" == "PREVIOUS CHANNEL" ]] - then - (sudo ./channeldown.sh) - fi - if [[ "$pseudo_channel_do" == "STOP CHANNEL" ]] - then - (sudo ./stop-all-channels.sh) - fi - if [[ "$pseudo_channel_do" == "BACK" ]] - then - break - fi - sleep 1 - clear - echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" - echo "PSEUDO CHANNEL CONTROL OPTIONS" - echo "1) START CHANNEL 3) PREVIOUS CHANNEL 5) BACK" - echo "2) NEXT CHANNEL 4) STOP CHANNEL" - done - fi - if [[ "$category" == "EDIT" ]] - then - sleep 1 - clear - echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" - echo "PSEUDO CHANNEL EDIT OPTIONS" - select pseudo_channel_do in "EDIT SCHEDULE" "EDIT CONFIG" "ADD CLIENT" "BACK" - do - sleep 1 - clear - echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" - if [[ "$pseudo_channel_do" == "EDIT SCHEDULE" ]] - then - (sudo ./schedule-editor.sh) - fi - if [[ "$pseudo_channel_do" == "EDIT CONFIG" ]] - then - (sudo ./config_editor.sh) - fi - if [[ "$pseudo_channel_do" == "ADD CLIENT" ]] - then - echo "SELECT the PLEX CLIENT for the NEW CLIENT SETUP or ENTER one manually" - clientlist=$(xmllint --xpath "//Server/@name" "http://$server_ip:$server_port/clients" | sed "s|name=||g" | sed "s|^ ||g" && echo -e " Other") - eval set $clientlist - select create_box_client in "$@" - do - if [[ "$create_box_client" == "Other" ]] - then - read -p 'Client Name: ' create_box_client - create_box_client=$(eval echo $create_box_client) - fi - break - done - (sudo ./create_box.sh "$create_box_client") - fi - if [[ "$pseudo_channel_do" == "BACK" ]] - then - break - fi - sleep 1 - clear - echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" - echo "PSEUDO CHANNEL EDIT OPTIONS" - echo "1) EDIT SCHEDULE" - echo "2) EDIT CONFIG" - echo "3) ADD CLIENT" - echo "4) BACK" - done - fi - if [[ "$category" == "UPDATE" ]] - then - echo "PSEUDO CHANNEL UPDATE OPTIONS" - select pseudo_channel_do in "DATABASE UPDATE" "SOFTWARE UPDATE" "BACK" - do - sleep 1 - clear - echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" - if [[ "$pseudo_channel_do" == "DATABASE UPDATE" ]] - then - echo "Select DATABASE to UPDATE" - select update_database in "TV Shows" "Movies" "Commercials" "All" - do - if [[ "$update_database" == "TV Shows" ]] - then - (sudo python Global_DatabaseUpdate.py -ut) - elif [[ "$update_database" == "Movies" ]] - then - (sudo python Global_DatabaseUpdate.py -um) - elif [[ "$update_database" == "Commercials" ]] - then - (sudo python Global_DatabaseUpdate.py -uc) - elif [[ "$update_database" == "All" ]] - then - (sudo python Global_DatabaseUpdate.py -u) - fi - break - done - fi - if [[ "$pseudo_channel_do" == "SOFTWARE UPDATE" ]] - then - (sudo ./update-channels-from-git.sh) - fi - if [[ "$pseudo_channel_do" == "BACK" ]] - then - break - fi - sleep 1 - clear - echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" - echo "PSEUDO CHANNEL UPDATE OPTIONS" - echo "1) DATABASE UPDATE" - echo "2) SOFTWARE UPDATE" - echo "3) BACK" - done - fi - if [[ "$category" == "EXIT" ]] - then - echo "EXITING PSEUDO CHANNEL CONTROL SCRIPT..." - sleep 1 - clear - exit - fi -sleep 1 -clear -echo "+++++++++++++++++++++++++++PSEUDO CHANNEL+++++++++++++++++++++++++++" -echo "Choose a CATEGORY" -echo "1) CONTROL" -echo "2) EDIT" -echo "3) UPDATE" -echo "4) EXIT" -done From 440fdb233afec0c39f49d306de8e97403abc3e61 Mon Sep 17 00:00:00 2001 From: Moe Fwacky Date: Sat, 13 Oct 2018 08:28:54 -0700 Subject: [PATCH 3/8] Delete schedule-editor.sh --- schedule-editor.sh | 584 --------------------------------------------- 1 file changed, 584 deletions(-) delete mode 100644 schedule-editor.sh diff --git a/schedule-editor.sh b/schedule-editor.sh deleted file mode 100644 index cd560ee..0000000 --- a/schedule-editor.sh +++ /dev/null @@ -1,584 +0,0 @@ -#!/bin/bash -source config.cache -re='^[0-9]+$' -number_of_channels=$(ls | grep pseudo-channel_ | wc -l) -channel_number=$1 -loop_or_exit=loop - -time_entry() { -sleep 1 -clear -echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" -echo "ENTER the START TIME for THIS ENTRY in 24h format" -read -p 'Time (24h): ' start_time -echo "START TIME set to $start_time" -sleep 1 -clear -echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" -echo "Choose MEDIA TYPE to start at $start_time" -select media_type in "Movie" "TV Series" "Random TV Episode" - do - sleep 1 - clear - echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" - if [[ "$media_type" == "Movie" ]] - then - type="\"movie\"" - entry="MOVIE" - #echo "ENTER the MOVIE TITLE" - #read -p 'Title: ' title - title="\"random\"" - elif [[ "$media_type" == "TV Series" ]] - then - type="\"series\"" - echo "ENTER the TV SERIES title" - read -p 'Title: ' title - entry="SHOW" - title=$(echo $title | recode ..html) - title="\"$title\"" - elif [[ "$media_type" == "Random TV Episode" ]] - then - type="\"random\"" - echo "ENTER the NAME of the TV SHOW to schedule RANDOM EPISODES from" - read -p 'Title: ' title - entry="SHOW" - title=$(echo $title | recode ..html) - title="\"$title\"" - fi - break -done -sleep 1 -clear -echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" -echo "Start this $entry to start at the EXACT TIME specified or AFTER" -echo "the PREVIOUS show or movie ENDS?" -select strict_time_entry in "Exact Time" "After Previous" - do - if [[ $strict_time_entry == "Exact Time" ]] - then - strict_time="\"true\"" - time_shift="\"1\"" - echo "The $entry $title will play at exactly $start_time" - elif [[ $strict_time_entry == "After Previous" ]] - then - sleep 1 - clear - echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" - strict_time="\"false\"" - echo "TIME SHIFT VALUE" - echo "This value will determine how much commercial time will be placed" - echo "in between the end of the previous show or movie and the start of this $entry" - echo "The value entered will restrict the start time to a time that ends in that number" - echo "FOR EXAMPLE: A value of 5 will allow the $entry to start at" - echo "5, 10, 15, 20, etc. after the hour. A value of 30 will only allow the $entry to" - echo "start on the half-hour. A value of 2 will restrict start times to even-numbered minutes only." - echo "ENTER the TIME SHIFT value" - read -p 'Time Shift: ' time_shift_entry - time_shift="\"$time_shift_entry\"" - while ! [[ $time_shift_entry =~ $re ]] - do - echo "ENTER the TIME SHIFT value" - read -p 'Time Shift: ' time_shift_entry - time_shift="\"$time_shift_entry\"" - done - fi -break -done -if [[ $media_type == "Movie" ]] - then - sleep 1 - clear - echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" - echo "Restrict RANDOM MOVIE selection based on available PLEX METADATA?" - read -p 'Y/N: ' add_xtra - while [[ "$add_xtra" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "Restrict RANDOM MOVIE selection based on available PLEX METADATA?" - read -p 'Y/N: ' add_xtra - done - if [[ "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - sleep 1 - clear - echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" - select xtra_tag in "Studio" "MPAA Rating" "Year" "Decade" "Genre" "Director" "Writer" "Actor" "Collection" - do - sleep 1 - clear - echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" - if [[ "$xtra_tag" == "Studio" ]] - then - echo "Enter the NAME of the MOVIE STUDIO(S) to FILTER by (Example: Amblin Entertainment)." - enter_studio=yes - echo -n "studio:" > xtra.temp - while [[ "$enter_studio" == @(Y|y|Yes|yes|YES) ]] - do - read -p 'Studio(s) :' xtra_studio - echo -n "$xtra_studio" >> xtra.temp - echo "ENTER another STUDIO?" - echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." - read -p 'Y/N: ' enter_studio - while [[ "$enter_studio" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ENTER another STUDIO?" - read -p 'Y/N: ' enter_studio - done - if [[ "$enter_studio" == @(Y|y|Yes|yes|YES) ]] - then - echo -n "," >> xtra.temp - fi - done - fi - if [[ "$xtra_tag" == "MPAA Rating" ]] - then - echo "ADD the MPAA RATING(s) to FILTER by (Example: PG-13)" - enter_rating=yes - echo -n "contentRating:" > xtra.temp - while [[ "$enter_rating" == @(Y|y|Yes|yes|YES) ]] - do - read -p 'Rating(s): ' xtra_rating - echo -n "$xtra_rating" >> xtra.temp - echo "ENTER another RATING?" - echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." - read -p 'Y/N: ' enter_rating - while [[ "$enter_rating" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ENTER another RATING?" - read -p 'Y/N: ' enter_rating - done - if [[ "$enter_rating" == @(Y|y|Yes|yes|YES) ]] - then - echo -n "," >> xtra.temp - fi - done - fi - if [[ "$xtra_tag" == "Year" ]] - then - echo "ADD RELEASE YEAR(S) to FILTER by (Example: 1982)" - echo -n "year:" > xtra.temp - read -p 'Year(s): ' xtra_year - echo -n "$xtra_year" >> xtra.temp - fi - if [[ "$xtra_tag" == "Decade" ]] - then - echo "ADD the DECADE of release to FILTER by (Example: 1980)" - echo -n "decade:" > xtra.temp - read -p 'Decade: ' xtra_decade - echo -n "$xtra_decade" >> xtra.temp - fi - if [[ "$xtra_tag" == "Genre" ]] - then - echo "ENTER GENRES to the RANDOM MOVIE FILTER (Example: Action)" - enter_genre=yes - echo -n "genre:" > xtra.temp - while [[ "$enter_genre" == @(Y|y|Yes|yes|YES) ]] - do - read -p 'Genre: ' xtra_genre - echo -n "$xtra_genre" >> xtra.temp - echo "ENTER another GENRE?" - echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." - read -p 'Y/N: ' enter_genre - while [[ "$enter_genre" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ENTER another GENRE?" - read -p 'Y/N: ' enter_genre - done - if [[ "$enter_genre" == @(Y|y|Yes|yes|YES) ]] - then - echo -n "," >> xtra.temp - fi - done - fi - if [[ "$xtra_tag" == "Director" ]] - then - echo "FILTER by the following DIRECTOR(S) (Example: Taika Waititi)" - enter_director=yes - echo -n "director:" > xtra.temp - while [[ "$enter_director" == @(Y|y|Yes|yes|YES) ]] - do - read -p 'Director: ' xtra_director - echo -n "$xtra_genre" >> xtra.temp - echo "ENTER another GENRE?" - echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." - read -p 'Y/N: ' enter_director - while [[ "$enter_director" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ENTER another DIRECTOR?" - read -p 'Y/N: ' enter_director - done - if [[ "$enter_director" == @(Y|y|Yes|yes|YES) ]] - then - echo -n "," >> xtra.temp - fi - done - fi - if [[ "$xtra_tag" == "Writer" ]] - then - echo "ADD WRITER(S) to FILTER by (Example: Sandra Bullock)" - enter_writer=yes - echo -n "Writer:" > xtra.temp - while [[ "$enter_writer" == @(Y|y|Yes|yes|YES) ]] - do - read -p 'Writer: ' xtra_writer - echo -n "$xtra_writer" >> xtra.temp - echo "ENTER another WRITER?" - echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." - read -p 'Y/N: ' enter_writer - while [[ "$enter_writer" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ENTER another writer?" - read -p 'Y/N: ' enter_writer - done - if [[ "$enter_writer" == @(Y|y|Yes|yes|YES) ]] - then - echo -n "," >> xtra.temp - fi - done - fi - if [[ "$xtra_tag" == "Actor" ]] - then - echo "ADD ACTOR(S) to FILTER by (Example: Sandra Bullock)" - enter_actor=yes - echo -n "Actor:" > xtra.temp - while [[ "$enter_actor" == @(Y|y|Yes|yes|YES) ]] - do - read -p 'Actor: ' xtra_writer - echo -n "$xtra_actor" >> xtra.temp - echo "ENTER another ACTOR?" - echo "Multiples are treated as an AND, not OR. Results will be filtered by ALL VALUES." - read -p 'Y/N: ' enter_actor - while [[ "$enter_actor" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ENTER another actor?" - read -p 'Y/N: ' enter_actor - done - if [[ "$enter_actor" == @(Y|y|Yes|yes|YES) ]] - then - echo -n "," >> xtra.temp - fi - done - fi - if [[ "$xtra_tag" == "Collection" ]] - then - echo "A COLLECTION is a user-defined TAG. Any selection of MOVIES can be added to a COLLECTION" - echo "and DEFINED here to be FILTERED by. (Example: Marvel Movies or Halloween Movies)" - echo -n "collection:" > xtra.temp - read -p 'Collection(s): ' xtra_collection - echo -n "$xtra_collection" >> xtra.temp - fi - xtra=$(cat xtra.temp) - xtra="\"$xtra\"" - break - done - else - > xtra.temp - fi -fi -overlap_max="\"30\"" -} -clear -echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" -if [[ $channel_number == '' ]] # IF NO ARGUMENT PROVIDED, ASK IF USER WANTS TO EDIT THE MAIN CONFIG OR SELECT A CHANNEL - then - echo "CHOOSE which CHANNEL SCHEDULE to create." - echo "Enter CHANNEL NUMBER between 1 and $number_of_channels" - read -p 'Channel Number: ' channel_number - while ! [[ $channel_number =~ $re ]] # VALIDATES THAT CHANNEL NUMBER IS ACTUALLY A NUMBER - do - echo "Enter CHANNEL NUMBER" - read -p 'Channel Number: ' channel_number - done - while ! [[ $channel_number -ge 1 && $channel_number -le $number_of_channels ]] # VALIDATES CHANNEL NUMBER AGAINST ACTUAL CHANNELS - do - echo "ERROR: Channel NOT FOUND." - echo "Channels must be between 1 and $number_of_channels" - echo "Enter CHANNEL NUMBER" - read -p 'Channel Number: ' channel_number - done -fi - echo "Now editing the schedule for CHANNEL $channel_number" - if [[ $channel_number -ge 1 && $channel_number -le 9 ]] # SET DIRECTORY TO SELECTED CHANNEL - then - cd pseudo-channel_0"$channel_number" - elif [[ $channel_number -ge 10 ]] - then - cd pseudo-channel_"$channel_number" - fi -sleep 1 -clear -echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" -echo "Backing up CURRENT SCHEDULE FILE..." -sleep 1 -sudo cp pseudo_schedule.xml pseudo_schedule.backup -echo "Creating NEW SCHEDULE FILE..." -echo "" > pseudo_schedule.xml -echo "" >> pseudo_schedule.xml -sleep 1 -clear -echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" -echo "CHOOSE which DAY to SCHEDULE" -select day_of_week in "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Weekends" "Weekdays" "Every Day" "Exit" - do - sleep 1 - clear - echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" - if [[ "$day_of_week" == "Sunday" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Monday" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Tuesday" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Wednesday" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Thursday" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Friday" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Saturday" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Weekends" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Weekdays" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Every Day" ]] - then - echo "" >> pseudo_schedule.xml - enter_time=yes - while [[ $enter_time == @(Y|y|Yes|yes|YES) ]] - do - time_entry - if [[ "$entry" == "MOVIE" && "$add_xtra" == @(Y|y|Yes|yes|YES) ]] - then - echo "" >> pseudo_schedule.xml - else - echo "" >> pseudo_schedule.xml - fi - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - while [[ "$enter_time" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ADD another SHOW or MOVIE?" - read -p 'Y/N: ' enter_time - done - done - echo "" >> pseudo_schedule.xml - fi - if [[ "$day_of_week" == "Exit" ]] - then - echo "FINALIZING SCHEDULE FORMATTING..." - echo "" >> pseudo_schedule.xml - sudo python PseudoChannel.py -xml - echo "CLEANING UP TEMPORARY FILES" - sudo rm xtra.temp - echo "REMOVE BACKUP of Channel $channel_number's previous schedule?" - read -p 'Y/N: ' remove_backup_schedule - while [[ "$remove_backup_schedule" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - clear - echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" - echo "REMOVE BACKUP of Channel $channel_number's previous schedule?" - read -p 'Y/N: ' remove_backup_schedule - done - if [[ "$remove_backup_schedule" == @(Y|y|Yes|yes|YES) ]] - then - sudo rm pseudo_schedule.backup - fi - exit 0 - fi -sleep 1 -clear -echo "++++++++++++++++++++PSEUDO CHANNEL SCHEDULE EDITOR++++++++++++++++++++" -echo "CHOOSE which DAY to SCHEDULE" -echo "1) Sunday 4) Wednesday 7) Saturday 10) Every Day" -echo "2) Monday 5) Thursday 8) Weekends 11) Exit" -echo "3) Tuesday 6) Friday 9) Weekdays" -done From 598f6a05afe16094edd5c515701c44cc80555c6e Mon Sep 17 00:00:00 2001 From: Moe Fwacky Date: Sat, 13 Oct 2018 08:29:16 -0700 Subject: [PATCH 4/8] Add files via upload --- main-dir/schedule-editor.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main-dir/schedule-editor.sh b/main-dir/schedule-editor.sh index 095790b..cd560ee 100644 --- a/main-dir/schedule-editor.sh +++ b/main-dir/schedule-editor.sh @@ -73,12 +73,13 @@ select strict_time_entry in "Exact Time" "After Previous" echo "5, 10, 15, 20, etc. after the hour. A value of 30 will only allow the $entry to" echo "start on the half-hour. A value of 2 will restrict start times to even-numbered minutes only." echo "ENTER the TIME SHIFT value" - read -p 'Time Shift: ' time_shift - while ! [[ $time_shift =~ $re ]] + read -p 'Time Shift: ' time_shift_entry + time_shift="\"$time_shift_entry\"" + while ! [[ $time_shift_entry =~ $re ]] do echo "ENTER the TIME SHIFT value" - read -p 'Time Shift: ' time_shift - time_shift="\"$time_shift\"" + read -p 'Time Shift: ' time_shift_entry + time_shift="\"$time_shift_entry\"" done fi break @@ -555,6 +556,7 @@ select day_of_week in "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday then echo "FINALIZING SCHEDULE FORMATTING..." echo "" >> pseudo_schedule.xml + sudo python PseudoChannel.py -xml echo "CLEANING UP TEMPORARY FILES" sudo rm xtra.temp echo "REMOVE BACKUP of Channel $channel_number's previous schedule?" From ad278cf01196243a545e34b589d2939f1144e4c4 Mon Sep 17 00:00:00 2001 From: Moe Fwacky Date: Sat, 13 Oct 2018 08:30:55 -0700 Subject: [PATCH 5/8] Add files via upload --- update-channels-from-git.sh | 354 ++++++++++++++++++++++++++++++++++++ 1 file changed, 354 insertions(+) create mode 100644 update-channels-from-git.sh diff --git a/update-channels-from-git.sh b/update-channels-from-git.sh new file mode 100644 index 0000000..221120f --- /dev/null +++ b/update-channels-from-git.sh @@ -0,0 +1,354 @@ +#!/bin/bash +# file: update-channels-from-git.sh + +#---- +# Simple script to update every channel with updates from the github repo. +# BACKUP EACH XML/DB IN EACH CHANNEL. +# Code will take in one argument: To take from the master or development branch +# For ALL installs, simply place this file in the location you would like your channels to be installed/updated +#---- + +#---- +# To Use: +# chmod +x update-channels-from-git.sh +# ./update-channels-from-git.sh +#---- + +dir=$(pwd) +#----BEGIN EDITABLE VARS---- +if [ $# -gt 1 ]; then + echo "ERROR: Please only supply one argument" + exit 9999 +elif [ "$1" == "develop" ]; then + echo "Downloading the develop branch" + SCRIPT_TO_EXECUTE_PLUS_ARGS='git clone https://github.com/mutto233/pseudo-channel . --branch develop' + +else + echo "Downloading the master branch" + SCRIPT_TO_EXECUTE_PLUS_ARGS='git clone https://github.com/mutto233/pseudo-channel . --branch master' +fi + +OUTPUT_PREV_CHANNEL_PATH=. + +CHANNEL_DIR_INCREMENT_SYMBOL="_" + +# This does a check for the pseudo-channel_## directories that manage each channel. +# As this script generates those directories on first run, if those directories do +# not exist, then logically this is the first run. +FIND_CHANNEL_FOLDER='' +FIND_CHANNEL_FOLDERS=$(find ./ -name "pseudo-channel_*" -type d) +if [[ "$FIND_CHANNEL_FOLDERS" == '' ]] + then + FIRST_INSTALL=true + else + FIRST_INSTALL=false +fi + + +#----END EDITABLE VARS------- + + + +# First, we need to figure out if we have actually installed this already +# To do this, we are going to check if we go up one level we have the folder "channels" +# We will also check if the current directory has "channels" +# FIRST_INSTALL=true + +# if [ -d "$INSTALL_FOLDER" ] || [ -d "../$INSTALL_FOLDER" ]; then + # echo "This is NOT the first install" + # FIRST_INSTALL=false +# else + # echo "This IS the first install, installing 'channels' directory in current directory with five starting channels." + # FIRST_INSTALL=true +# fi + + +# If this is our first install, we will now make all necessary directories to prepare for install +if [ "$FIRST_INSTALL" == "true" ]; then +echo "This is a FIRST INSTALL, ENTER the NUMBER of PSEUDO CHANNELS to SET UP" +read -p 'Number of Channels: ' number_of_channels + if (( $number_of_channels >= 1 )) + then + entry_is_number=yes + else + entry_is_number=no + fi + while [[ $entry_is_number == "no" ]] + do + echo "Enter the number of channels you would like this script to generate?" + read -p 'Number of Channels: ' number_of_channels + if (( $number_of_channels >= 1 )) + then + entry_is_number=yes + else + entry_is_number=no + fi + done + for (( num=1; num<="$number_of_channels"; num++ )) + do + if [ $num -ge 1 -a $num -le 9 ] + then + mkdir "pseudo-channel_0$num" + else + mkdir "pseudo-channel_$num" + fi + done + mkdir github_download + cd github_download + $SCRIPT_TO_EXECUTE_PLUS_ARGS + else + mkdir github_download + cd github_download + $SCRIPT_TO_EXECUTE_PLUS_ARGS +fi + + +#### Next, let's download the latest master version of information from GitHub and store it in a temporary folder +#mkdir github_download +#cd github_download +#$SCRIPT_TO_EXECUTE_PLUS_ARGS + +#### If necessary, install the required elements as defined by requirements.txt +#### Also, ask user for information to fill in the plex_token and pseudo_config files +if [ "$FIRST_INSTALL" == "true" ] + then + echo "INSTALLING REQUIREMENTS because this is a FIRST RUN" + sudo pip install -r requirements.txt + sudo apt-get -y install libxml2-utils recode # NEEDED FOR XML PARSING + cd .. + echo "ENTER the IP ADDRESS of your PLEX SERVER" #GET PLEX SERVER IP AND PORT + read -p 'Plex Server IP: ' server_ip + echo "ENTER the PUBLIC PORT number for your PLEX SERVER" + read -p 'Public Port (default: 32400): ' server_port + if [ "$server_port" == '' ] + then + server_port='32400' + fi + echo "ENTER your PLEX AUTHENTICATION TOKEN" # GET PLEX SERVER AUTH TOKEN + echo "(for help finding token, check here: https://bit.ly/2p7RtOu)" + read -p 'Plex Auth Token: ' server_token + echo "PLEX SERVER is $server_ip:$server_port" + echo "PLEX AUTH TOKEN is $server_token" + echo "SELECT the PLEX CLIENT for this install or ENTER one manually" + # DISPLAY A LIST OF CONNECTED CLIENTS AND ALLOW THE USER TO SELECT ONE OR ENTER ONE THAT ISN'T DISPLAYED + clientlist=$(xmllint --xpath "//Server/@name" "http://$server_ip:$server_port/clients" | sed "s|name=||g" | sed "s|^ ||g" && echo -e " Other") + eval set $clientlist + select ps_client_entry in "$@" + do + if [[ "$ps_client_entry" == "Other" ]] + then + read -p 'Client Name: ' ps_client_entry + ps_client_entry=$(eval echo $ps_client_entry) + fi + ps_client="[\"$ps_client_entry\"]" + break + done + # ALLOW THE USER TO ENTER ALL PLEX LIBRARIES + echo "++++++SETTING UP PLEX LIBRARIES WITH PSEUDO CHANNEL++++++" + echo "Add ALL LIBRARIES that may be used for ANY CHANNEL here." + echo "ENTER the name of EACH Plex library defined as TV SHOWS" + enter_tv_shows=yes + echo -n "[" > tv-libraries.temp + while [[ "$enter_tv_shows" == @(Y|y|Yes|yes|YES) ]] + do + read -p 'TV Show Library Name: ' tv_library_entry + echo -n "\"$tv_library_entry\"" >> tv-libraries.temp + echo "ENTER another TV SHOW LIBRARY?" + read -p 'Y/N: ' enter_tv_shows + while [[ "$enter_tv_shows" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ENTER another TV SHOW LIBRARY?" + read -p 'Y/N: ' enter_tv_shows + done + if [[ "$enter_tv_shows" == @(Y|y|Yes|yes|YES) ]] + then + echo -n ", " >> tv-libraries.temp + fi + done + echo -n "]," >> tv-libraries.temp + echo "ENTER the name of EACH Plex library defined as MOVIES" + enter_movies=yes + echo -n "[" > movie-libraries.temp + while [[ "$enter_movies" == @(Y|y|Yes|yes|YES) ]] + do + read -p 'Movie Library Name: ' movie_library_entry + echo -n "\"$movie_library_entry\"" >> movie-libraries.temp + echo "ENTER another MOVIE LIBRARY?" + read -p 'Y/N: ' enter_movies + while [[ "$enter_movies" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ENTER another MOVIE LIBRARY?" + read -p 'Y/N: ' enter_movies + done + if [[ "$enter_movies" == @(Y|y|Yes|yes|YES) ]] + then + echo -n ", " >> movie-libraries.temp + fi + done + echo -n "]," >> movie-libraries.temp + echo "Use COMMERCIALS in between scheduled content?" # ASK IF THE USER WANTS TO ADD COMMERCIAL LIBRARIES + read -p 'Y/N: ' enter_commercials + while [[ "$enter_commercials" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "Use COMMERCIALS in between scheduled content?" + read -p 'Y/N: ' enter_commercials + done + if [[ "$enter_commercials" == @("Y"|"y"|"yes"|"Yes"|"YES") ]] + then + commercials_true=True + echo "ENTER the name of EACH Plex library defined as COMMERCIALS" + echo -n "[" > commercial-libraries.temp + else + commercials_true=False + fi + while [[ "$enter_commercials" == @(Y|y|Yes|yes|YES) ]] + do + read -p 'Commercial Library Name: ' commercial_library_entry + echo -n "\"$commercial_library_entry\", " >> commercial-libraries.temp + echo "ENTER another COMMERCIAL LIBRARY?" + read -p 'Y/N: ' enter_commercials + while [[ "$enter_commercials" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] + do + echo "ENTER another COMMERCIAL LIBRARY?" + read -p 'Y/N: ' enter_commercials + done + done + if [[ "$commercials_true" == "True" ]] + then + truncate -s-2 commercial-libraries.temp + echo -n "]," >> commercial-libraries.temp + fi + # DEFINE THE DAILY RESET TIME + echo "Set the TIME for PSEUDO CHANNEL to GENERATE the DAILY SCHEDULE" + echo "USE 24H FORMAT (ex: 23:00)" + read -p 'Schedule Reset Time: ' reset_time_entry + reset_time_formatted=$(echo $reset_time_entry | sed -e "s|^[0-9]:.*|0$reset_time_entry|g") + reset_time_hour="${reset_time_formatted:0:2}" + reset_time_hour=$(echo $reset_time_hour | sed -e "s|^[0]||") + reset_time_minute="${reset_time_formatted: -2}" + reset_time_minute=$(echo $reset_time_minute | sed "-e s|^[0]||") + # SET UP CRON JOB TO RUN DAILY RESET + sudo crontab -l | grep -v 'daily-cron.sh' | crontab - + sudo echo \#\!/bin/bash > ./daily-cron.sh && echo "cd $PWD" >> ./daily-cron.sh && echo "sudo ./generate-channels-daily-schedules.sh" >> ./daily-cron.sh + ( sudo crontab -l ; echo "$reset_time_minute $reset_time_hour * * * $PWD/daily-cron.sh" ) | sudo crontab - + + #### WRITE VARIABLES TO TOKEN AND CONFIG FILES #### + reset_time="\"$reset_time_entry\"" + echo "token = '$server_token'" > plex_token.py # WRITE PLEX SERVER TOKEN TO FILE + echo "baseurl = 'http://$server_ip:$server_port'" >> plex_token.py # WRITE PLEX URL TO FILE + tv_libraries=$(cat tv-libraries.temp) + sudo sed -i "s/plexClients = .*/plexClients = $ps_client/" github_download/both-dir/pseudo_config.py # WRITE CLIENT TO CONFIG + sudo sed -i "/.\"TV Shows\" :*./c\ \"TV Shows\" : $tv_libraries" github_download/both-dir/pseudo_config.py # WRITE TV LIBRARIES TO CONFIG + movie_libraries=$(cat movie-libraries.temp) + sudo sed -i "/.\"Movies\" :*./c\ \"Movies\" : $movie_libraries" github_download/both-dir/pseudo_config.py # WRITE MOVIE LIBRARIES TO CONFIG + if [[ "$commercials_true" == "True" ]] #WRITE COMMERCIAL LIBRARIES TO CONFIG + then + commercial_libraries=$(cat commercial-libraries.temp) + sudo sed -i "/.\"Commercials\" :*./c\ \"Commercials\" : $commercial_libraries" github_download/both-dir/pseudo_config.py + fi + # WRITE OTHER CONFIG OPTIONS TO THE CONFIG FILE + sudo sed -i "s/useCommercialInjection =.*/useCommercialInjection = $commercials_true/" github_download/both-dir/pseudo_config.py + sudo sed -i "s/dailyUpdateTime =.*/dailyUpdateTime = $reset_time/" github_download/both-dir/pseudo_config.py + sudo sed -i "s/controllerServerPath =.*/controllerServerPath = \"\"/" github_download/both-dir/pseudo_config.py + sudo sed -i "s/controllerServerPort =.*/controllerServerPort = \"\"/" github_download/both-dir/pseudo_config.py + sudo sed -i "s/debug_mode =.*/debug_mode = False/" github_download/both-dir/pseudo_config.py + # CLEAN UP TEMP FILES AND COPY CONFIG + sudo rm movie-libraries.temp + sudo rm tv-libraries.temp + sudo rm commercial-libraries.temp + sudo cp github_download/both-dir/pseudo_config.py ./ + sudo cp github_download/both-dir/PseudoChannel.py ./ + cd .. + else + cd .. +fi + +#### With information downloaded, we will first go to each channel folder and update important things +#### This will take the following form +#### - Enter folder +#### - Copy database, xml, and config file to temporary folder +#### - copy all files from the download/channel-dir and download/both-dir to the channel folder. +#### - Replace files that were originally removed + +# Scan the dir to see how many channels there are, store them in an arr. +CHANNEL_DIR_ARR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL"'[[:digit:]]*' -printf "%P\n" | sort -t"$CHANNEL_DIR_INCREMENT_SYMBOL" -n) ) + +if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then + echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected." + for channel in "${CHANNEL_DIR_ARR[@]}" + do + echo "+++++ Trying to update channel:"./"$channel" + cd "$channel" + + # Export critical files + mkdir ../.pseudo-temp + + cp ./pseudo-channel.db ../.pseudo-temp 2>/dev/null + + cp ./pseudo_schedule.xml ../.pseudo-temp 2>/dev/null + + cp ./pseudo_config.py ../.pseudo-temp 2>/dev/null + + # Copy new elements + + cp -r ../github_download/channel-dir/* . + cp -r ../github_download/both-dir/* . + + # Replace the files originally moved + + cp ../.pseudo-temp/pseudo-channel.db . 2>/dev/null + + cp ../.pseudo-temp/pseudo_schedule.xml . 2>/dev/null + + cp ../.pseudo-temp/pseudo_config.py . 2>/dev/null + + rm -rf ../.pseudo-temp + + cd .. + done +fi + +#### Now we will return to the original file, and ensure that everything is in the main folder +#### This will include the following form +#### - Return to folder +#### - Copy config, db, and token file +#### - Copy relevant files from github +#### - Replace files originally removed +echo "Updating channels folder" +cd $dir +# Export critical files +mkdir .pseudo-temp + +cp ./pseudo-channel.db .pseudo-temp 2>/dev/null + +cp ./pseudo_config.py .pseudo-temp 2>/dev/null + +cp ./plex_token.py .pseudo-temp 2>/dev/null + +# Copy new elements + +cp -r ./github_download/main-dir/* . +cp -r ./github_download/both-dir/* . + +# Replace the files originally moved + +cp ./.pseudo-temp/pseudo-channel.db . 2>/dev/null + +cp ./.pseudo-temp/pseudo_config.py . 2>/dev/null + +cp ./.pseudo-temp/plex_token.py . 2>/dev/null + +rm -rf ./.pseudo-temp + +rm -rf ./github_download + +#### Change permissions to 777 for all files, so that things will run +sudo chmod -R 777 . + +echo "Update Complete" + +#### Write variables to config.cache +> config.cache +sudo sed -i "s/server_ip=.*/server_ip=$server_ip/" config.cache +sudo sed -i "s/server_port=.*/server_port=$server_port/" config.cache +sudo sed -i "s/server_token=.*/server_token=$server_token/" config.cache From 16157299a8f5bb38d53d403f35785feddac26d8a Mon Sep 17 00:00:00 2001 From: Moe Fwacky Date: Sat, 13 Oct 2018 08:31:21 -0700 Subject: [PATCH 6/8] Delete update-channels-from-git.sh --- update-channels-from-git.sh | 354 ------------------------------------ 1 file changed, 354 deletions(-) delete mode 100644 update-channels-from-git.sh diff --git a/update-channels-from-git.sh b/update-channels-from-git.sh deleted file mode 100644 index 221120f..0000000 --- a/update-channels-from-git.sh +++ /dev/null @@ -1,354 +0,0 @@ -#!/bin/bash -# file: update-channels-from-git.sh - -#---- -# Simple script to update every channel with updates from the github repo. -# BACKUP EACH XML/DB IN EACH CHANNEL. -# Code will take in one argument: To take from the master or development branch -# For ALL installs, simply place this file in the location you would like your channels to be installed/updated -#---- - -#---- -# To Use: -# chmod +x update-channels-from-git.sh -# ./update-channels-from-git.sh -#---- - -dir=$(pwd) -#----BEGIN EDITABLE VARS---- -if [ $# -gt 1 ]; then - echo "ERROR: Please only supply one argument" - exit 9999 -elif [ "$1" == "develop" ]; then - echo "Downloading the develop branch" - SCRIPT_TO_EXECUTE_PLUS_ARGS='git clone https://github.com/mutto233/pseudo-channel . --branch develop' - -else - echo "Downloading the master branch" - SCRIPT_TO_EXECUTE_PLUS_ARGS='git clone https://github.com/mutto233/pseudo-channel . --branch master' -fi - -OUTPUT_PREV_CHANNEL_PATH=. - -CHANNEL_DIR_INCREMENT_SYMBOL="_" - -# This does a check for the pseudo-channel_## directories that manage each channel. -# As this script generates those directories on first run, if those directories do -# not exist, then logically this is the first run. -FIND_CHANNEL_FOLDER='' -FIND_CHANNEL_FOLDERS=$(find ./ -name "pseudo-channel_*" -type d) -if [[ "$FIND_CHANNEL_FOLDERS" == '' ]] - then - FIRST_INSTALL=true - else - FIRST_INSTALL=false -fi - - -#----END EDITABLE VARS------- - - - -# First, we need to figure out if we have actually installed this already -# To do this, we are going to check if we go up one level we have the folder "channels" -# We will also check if the current directory has "channels" -# FIRST_INSTALL=true - -# if [ -d "$INSTALL_FOLDER" ] || [ -d "../$INSTALL_FOLDER" ]; then - # echo "This is NOT the first install" - # FIRST_INSTALL=false -# else - # echo "This IS the first install, installing 'channels' directory in current directory with five starting channels." - # FIRST_INSTALL=true -# fi - - -# If this is our first install, we will now make all necessary directories to prepare for install -if [ "$FIRST_INSTALL" == "true" ]; then -echo "This is a FIRST INSTALL, ENTER the NUMBER of PSEUDO CHANNELS to SET UP" -read -p 'Number of Channels: ' number_of_channels - if (( $number_of_channels >= 1 )) - then - entry_is_number=yes - else - entry_is_number=no - fi - while [[ $entry_is_number == "no" ]] - do - echo "Enter the number of channels you would like this script to generate?" - read -p 'Number of Channels: ' number_of_channels - if (( $number_of_channels >= 1 )) - then - entry_is_number=yes - else - entry_is_number=no - fi - done - for (( num=1; num<="$number_of_channels"; num++ )) - do - if [ $num -ge 1 -a $num -le 9 ] - then - mkdir "pseudo-channel_0$num" - else - mkdir "pseudo-channel_$num" - fi - done - mkdir github_download - cd github_download - $SCRIPT_TO_EXECUTE_PLUS_ARGS - else - mkdir github_download - cd github_download - $SCRIPT_TO_EXECUTE_PLUS_ARGS -fi - - -#### Next, let's download the latest master version of information from GitHub and store it in a temporary folder -#mkdir github_download -#cd github_download -#$SCRIPT_TO_EXECUTE_PLUS_ARGS - -#### If necessary, install the required elements as defined by requirements.txt -#### Also, ask user for information to fill in the plex_token and pseudo_config files -if [ "$FIRST_INSTALL" == "true" ] - then - echo "INSTALLING REQUIREMENTS because this is a FIRST RUN" - sudo pip install -r requirements.txt - sudo apt-get -y install libxml2-utils recode # NEEDED FOR XML PARSING - cd .. - echo "ENTER the IP ADDRESS of your PLEX SERVER" #GET PLEX SERVER IP AND PORT - read -p 'Plex Server IP: ' server_ip - echo "ENTER the PUBLIC PORT number for your PLEX SERVER" - read -p 'Public Port (default: 32400): ' server_port - if [ "$server_port" == '' ] - then - server_port='32400' - fi - echo "ENTER your PLEX AUTHENTICATION TOKEN" # GET PLEX SERVER AUTH TOKEN - echo "(for help finding token, check here: https://bit.ly/2p7RtOu)" - read -p 'Plex Auth Token: ' server_token - echo "PLEX SERVER is $server_ip:$server_port" - echo "PLEX AUTH TOKEN is $server_token" - echo "SELECT the PLEX CLIENT for this install or ENTER one manually" - # DISPLAY A LIST OF CONNECTED CLIENTS AND ALLOW THE USER TO SELECT ONE OR ENTER ONE THAT ISN'T DISPLAYED - clientlist=$(xmllint --xpath "//Server/@name" "http://$server_ip:$server_port/clients" | sed "s|name=||g" | sed "s|^ ||g" && echo -e " Other") - eval set $clientlist - select ps_client_entry in "$@" - do - if [[ "$ps_client_entry" == "Other" ]] - then - read -p 'Client Name: ' ps_client_entry - ps_client_entry=$(eval echo $ps_client_entry) - fi - ps_client="[\"$ps_client_entry\"]" - break - done - # ALLOW THE USER TO ENTER ALL PLEX LIBRARIES - echo "++++++SETTING UP PLEX LIBRARIES WITH PSEUDO CHANNEL++++++" - echo "Add ALL LIBRARIES that may be used for ANY CHANNEL here." - echo "ENTER the name of EACH Plex library defined as TV SHOWS" - enter_tv_shows=yes - echo -n "[" > tv-libraries.temp - while [[ "$enter_tv_shows" == @(Y|y|Yes|yes|YES) ]] - do - read -p 'TV Show Library Name: ' tv_library_entry - echo -n "\"$tv_library_entry\"" >> tv-libraries.temp - echo "ENTER another TV SHOW LIBRARY?" - read -p 'Y/N: ' enter_tv_shows - while [[ "$enter_tv_shows" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ENTER another TV SHOW LIBRARY?" - read -p 'Y/N: ' enter_tv_shows - done - if [[ "$enter_tv_shows" == @(Y|y|Yes|yes|YES) ]] - then - echo -n ", " >> tv-libraries.temp - fi - done - echo -n "]," >> tv-libraries.temp - echo "ENTER the name of EACH Plex library defined as MOVIES" - enter_movies=yes - echo -n "[" > movie-libraries.temp - while [[ "$enter_movies" == @(Y|y|Yes|yes|YES) ]] - do - read -p 'Movie Library Name: ' movie_library_entry - echo -n "\"$movie_library_entry\"" >> movie-libraries.temp - echo "ENTER another MOVIE LIBRARY?" - read -p 'Y/N: ' enter_movies - while [[ "$enter_movies" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ENTER another MOVIE LIBRARY?" - read -p 'Y/N: ' enter_movies - done - if [[ "$enter_movies" == @(Y|y|Yes|yes|YES) ]] - then - echo -n ", " >> movie-libraries.temp - fi - done - echo -n "]," >> movie-libraries.temp - echo "Use COMMERCIALS in between scheduled content?" # ASK IF THE USER WANTS TO ADD COMMERCIAL LIBRARIES - read -p 'Y/N: ' enter_commercials - while [[ "$enter_commercials" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "Use COMMERCIALS in between scheduled content?" - read -p 'Y/N: ' enter_commercials - done - if [[ "$enter_commercials" == @("Y"|"y"|"yes"|"Yes"|"YES") ]] - then - commercials_true=True - echo "ENTER the name of EACH Plex library defined as COMMERCIALS" - echo -n "[" > commercial-libraries.temp - else - commercials_true=False - fi - while [[ "$enter_commercials" == @(Y|y|Yes|yes|YES) ]] - do - read -p 'Commercial Library Name: ' commercial_library_entry - echo -n "\"$commercial_library_entry\", " >> commercial-libraries.temp - echo "ENTER another COMMERCIAL LIBRARY?" - read -p 'Y/N: ' enter_commercials - while [[ "$enter_commercials" != @(Y|y|Yes|yes|YES|N|n|No|no|NO) ]] - do - echo "ENTER another COMMERCIAL LIBRARY?" - read -p 'Y/N: ' enter_commercials - done - done - if [[ "$commercials_true" == "True" ]] - then - truncate -s-2 commercial-libraries.temp - echo -n "]," >> commercial-libraries.temp - fi - # DEFINE THE DAILY RESET TIME - echo "Set the TIME for PSEUDO CHANNEL to GENERATE the DAILY SCHEDULE" - echo "USE 24H FORMAT (ex: 23:00)" - read -p 'Schedule Reset Time: ' reset_time_entry - reset_time_formatted=$(echo $reset_time_entry | sed -e "s|^[0-9]:.*|0$reset_time_entry|g") - reset_time_hour="${reset_time_formatted:0:2}" - reset_time_hour=$(echo $reset_time_hour | sed -e "s|^[0]||") - reset_time_minute="${reset_time_formatted: -2}" - reset_time_minute=$(echo $reset_time_minute | sed "-e s|^[0]||") - # SET UP CRON JOB TO RUN DAILY RESET - sudo crontab -l | grep -v 'daily-cron.sh' | crontab - - sudo echo \#\!/bin/bash > ./daily-cron.sh && echo "cd $PWD" >> ./daily-cron.sh && echo "sudo ./generate-channels-daily-schedules.sh" >> ./daily-cron.sh - ( sudo crontab -l ; echo "$reset_time_minute $reset_time_hour * * * $PWD/daily-cron.sh" ) | sudo crontab - - - #### WRITE VARIABLES TO TOKEN AND CONFIG FILES #### - reset_time="\"$reset_time_entry\"" - echo "token = '$server_token'" > plex_token.py # WRITE PLEX SERVER TOKEN TO FILE - echo "baseurl = 'http://$server_ip:$server_port'" >> plex_token.py # WRITE PLEX URL TO FILE - tv_libraries=$(cat tv-libraries.temp) - sudo sed -i "s/plexClients = .*/plexClients = $ps_client/" github_download/both-dir/pseudo_config.py # WRITE CLIENT TO CONFIG - sudo sed -i "/.\"TV Shows\" :*./c\ \"TV Shows\" : $tv_libraries" github_download/both-dir/pseudo_config.py # WRITE TV LIBRARIES TO CONFIG - movie_libraries=$(cat movie-libraries.temp) - sudo sed -i "/.\"Movies\" :*./c\ \"Movies\" : $movie_libraries" github_download/both-dir/pseudo_config.py # WRITE MOVIE LIBRARIES TO CONFIG - if [[ "$commercials_true" == "True" ]] #WRITE COMMERCIAL LIBRARIES TO CONFIG - then - commercial_libraries=$(cat commercial-libraries.temp) - sudo sed -i "/.\"Commercials\" :*./c\ \"Commercials\" : $commercial_libraries" github_download/both-dir/pseudo_config.py - fi - # WRITE OTHER CONFIG OPTIONS TO THE CONFIG FILE - sudo sed -i "s/useCommercialInjection =.*/useCommercialInjection = $commercials_true/" github_download/both-dir/pseudo_config.py - sudo sed -i "s/dailyUpdateTime =.*/dailyUpdateTime = $reset_time/" github_download/both-dir/pseudo_config.py - sudo sed -i "s/controllerServerPath =.*/controllerServerPath = \"\"/" github_download/both-dir/pseudo_config.py - sudo sed -i "s/controllerServerPort =.*/controllerServerPort = \"\"/" github_download/both-dir/pseudo_config.py - sudo sed -i "s/debug_mode =.*/debug_mode = False/" github_download/both-dir/pseudo_config.py - # CLEAN UP TEMP FILES AND COPY CONFIG - sudo rm movie-libraries.temp - sudo rm tv-libraries.temp - sudo rm commercial-libraries.temp - sudo cp github_download/both-dir/pseudo_config.py ./ - sudo cp github_download/both-dir/PseudoChannel.py ./ - cd .. - else - cd .. -fi - -#### With information downloaded, we will first go to each channel folder and update important things -#### This will take the following form -#### - Enter folder -#### - Copy database, xml, and config file to temporary folder -#### - copy all files from the download/channel-dir and download/both-dir to the channel folder. -#### - Replace files that were originally removed - -# Scan the dir to see how many channels there are, store them in an arr. -CHANNEL_DIR_ARR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL"'[[:digit:]]*' -printf "%P\n" | sort -t"$CHANNEL_DIR_INCREMENT_SYMBOL" -n) ) - -if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then - echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected." - for channel in "${CHANNEL_DIR_ARR[@]}" - do - echo "+++++ Trying to update channel:"./"$channel" - cd "$channel" - - # Export critical files - mkdir ../.pseudo-temp - - cp ./pseudo-channel.db ../.pseudo-temp 2>/dev/null - - cp ./pseudo_schedule.xml ../.pseudo-temp 2>/dev/null - - cp ./pseudo_config.py ../.pseudo-temp 2>/dev/null - - # Copy new elements - - cp -r ../github_download/channel-dir/* . - cp -r ../github_download/both-dir/* . - - # Replace the files originally moved - - cp ../.pseudo-temp/pseudo-channel.db . 2>/dev/null - - cp ../.pseudo-temp/pseudo_schedule.xml . 2>/dev/null - - cp ../.pseudo-temp/pseudo_config.py . 2>/dev/null - - rm -rf ../.pseudo-temp - - cd .. - done -fi - -#### Now we will return to the original file, and ensure that everything is in the main folder -#### This will include the following form -#### - Return to folder -#### - Copy config, db, and token file -#### - Copy relevant files from github -#### - Replace files originally removed -echo "Updating channels folder" -cd $dir -# Export critical files -mkdir .pseudo-temp - -cp ./pseudo-channel.db .pseudo-temp 2>/dev/null - -cp ./pseudo_config.py .pseudo-temp 2>/dev/null - -cp ./plex_token.py .pseudo-temp 2>/dev/null - -# Copy new elements - -cp -r ./github_download/main-dir/* . -cp -r ./github_download/both-dir/* . - -# Replace the files originally moved - -cp ./.pseudo-temp/pseudo-channel.db . 2>/dev/null - -cp ./.pseudo-temp/pseudo_config.py . 2>/dev/null - -cp ./.pseudo-temp/plex_token.py . 2>/dev/null - -rm -rf ./.pseudo-temp - -rm -rf ./github_download - -#### Change permissions to 777 for all files, so that things will run -sudo chmod -R 777 . - -echo "Update Complete" - -#### Write variables to config.cache -> config.cache -sudo sed -i "s/server_ip=.*/server_ip=$server_ip/" config.cache -sudo sed -i "s/server_port=.*/server_port=$server_port/" config.cache -sudo sed -i "s/server_token=.*/server_token=$server_token/" config.cache From a885d95481c85e2a50b2aa314158847f17602485 Mon Sep 17 00:00:00 2001 From: Moe Fwacky Date: Sat, 13 Oct 2018 08:31:35 -0700 Subject: [PATCH 7/8] Add files via upload --- main-dir/update-channels-from-git.sh | 42 +++++++++++++++++----------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/main-dir/update-channels-from-git.sh b/main-dir/update-channels-from-git.sh index 0d19a9e..221120f 100644 --- a/main-dir/update-channels-from-git.sh +++ b/main-dir/update-channels-from-git.sh @@ -14,19 +14,18 @@ # ./update-channels-from-git.sh #---- +dir=$(pwd) #----BEGIN EDITABLE VARS---- - -if [ $# -gt 1 ] - then +if [ $# -gt 1 ]; then echo "ERROR: Please only supply one argument" exit 9999 - elif [ "$1" == "develop" ] - then +elif [ "$1" == "develop" ]; then echo "Downloading the develop branch" - SCRIPT_TO_EXECUTE_PLUS_ARGS='git clone https://github.com/MoeFwacky/pseudo-channel . --branch develop' - else + SCRIPT_TO_EXECUTE_PLUS_ARGS='git clone https://github.com/mutto233/pseudo-channel . --branch develop' + +else echo "Downloading the master branch" - SCRIPT_TO_EXECUTE_PLUS_ARGS='git clone https://github.com/MoeFwacky/pseudo-channel . --branch master' + SCRIPT_TO_EXECUTE_PLUS_ARGS='git clone https://github.com/mutto233/pseudo-channel . --branch master' fi OUTPUT_PREV_CHANNEL_PATH=. @@ -45,6 +44,7 @@ if [[ "$FIND_CHANNEL_FOLDERS" == '' ]] FIRST_INSTALL=false fi + #----END EDITABLE VARS------- @@ -93,13 +93,20 @@ read -p 'Number of Channels: ' number_of_channels mkdir "pseudo-channel_$num" fi done + mkdir github_download + cd github_download + $SCRIPT_TO_EXECUTE_PLUS_ARGS + else + mkdir github_download + cd github_download + $SCRIPT_TO_EXECUTE_PLUS_ARGS fi #### Next, let's download the latest master version of information from GitHub and store it in a temporary folder -mkdir github_download -cd github_download -$SCRIPT_TO_EXECUTE_PLUS_ARGS +#mkdir github_download +#cd github_download +#$SCRIPT_TO_EXECUTE_PLUS_ARGS #### If necessary, install the required elements as defined by requirements.txt #### Also, ask user for information to fill in the plex_token and pseudo_config files @@ -188,11 +195,11 @@ if [ "$FIRST_INSTALL" == "true" ] done if [[ "$enter_commercials" == @("Y"|"y"|"yes"|"Yes"|"YES") ]] then - commercials_true=true + commercials_true=True echo "ENTER the name of EACH Plex library defined as COMMERCIALS" echo -n "[" > commercial-libraries.temp else - commercials_true=false + commercials_true=False fi while [[ "$enter_commercials" == @(Y|y|Yes|yes|YES) ]] do @@ -206,7 +213,7 @@ if [ "$FIRST_INSTALL" == "true" ] read -p 'Y/N: ' enter_commercials done done - if [[ "$commercials_true" == "true" ]] + if [[ "$commercials_true" == "True" ]] then truncate -s-2 commercial-libraries.temp echo -n "]," >> commercial-libraries.temp @@ -234,7 +241,7 @@ if [ "$FIRST_INSTALL" == "true" ] sudo sed -i "/.\"TV Shows\" :*./c\ \"TV Shows\" : $tv_libraries" github_download/both-dir/pseudo_config.py # WRITE TV LIBRARIES TO CONFIG movie_libraries=$(cat movie-libraries.temp) sudo sed -i "/.\"Movies\" :*./c\ \"Movies\" : $movie_libraries" github_download/both-dir/pseudo_config.py # WRITE MOVIE LIBRARIES TO CONFIG - if [[ "$commercials_true" == "true" ]] #WRITE COMMERCIAL LIBRARIES TO CONFIG + if [[ "$commercials_true" == "True" ]] #WRITE COMMERCIAL LIBRARIES TO CONFIG then commercial_libraries=$(cat commercial-libraries.temp) sudo sed -i "/.\"Commercials\" :*./c\ \"Commercials\" : $commercial_libraries" github_download/both-dir/pseudo_config.py @@ -250,6 +257,8 @@ if [ "$FIRST_INSTALL" == "true" ] sudo rm tv-libraries.temp sudo rm commercial-libraries.temp sudo cp github_download/both-dir/pseudo_config.py ./ + sudo cp github_download/both-dir/PseudoChannel.py ./ + cd .. else cd .. fi @@ -306,7 +315,7 @@ fi #### - Copy relevant files from github #### - Replace files originally removed echo "Updating channels folder" - +cd $dir # Export critical files mkdir .pseudo-temp @@ -339,6 +348,7 @@ sudo chmod -R 777 . echo "Update Complete" #### Write variables to config.cache +> config.cache sudo sed -i "s/server_ip=.*/server_ip=$server_ip/" config.cache sudo sed -i "s/server_port=.*/server_port=$server_port/" config.cache sudo sed -i "s/server_token=.*/server_token=$server_token/" config.cache From 846c02093caf8812fafd52163af00ef60f04d259 Mon Sep 17 00:00:00 2001 From: Moe Fwacky Date: Sat, 13 Oct 2018 09:23:20 -0700 Subject: [PATCH 8/8] Add files via upload --- updatexml.sh | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 updatexml.sh diff --git a/updatexml.sh b/updatexml.sh new file mode 100644 index 0000000..05e768f --- /dev/null +++ b/updatexml.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# file: updatechannels.sh + +#---- +# Simple script to updates each channels local db with new Plex lib items / xml. +#---- + +#---- +# To Use: +# If you added new content to your Plex Library, just make this file executable move it +# to where the plex_token.py file is and run ./updatechannels.sh +#---- + +# Make sure that each channel dir ends with a "_" + an incrementing number as seen above. + +#----BEGIN EDITABLE VARS---- + +SCRIPT_TO_EXECUTE_PLUS_ARGS='PseudoChannel.py -xml' + +OUTPUT_PREV_CHANNEL_PATH=. + +CHANNEL_DIR_INCREMENT_SYMBOL="_" + +PYTHON_TO_USE="$(which python)" + +# If using 'virtualenv' with python, specify the local virtualenv dir. +VIRTUAL_ENV_DIR="env" + +#----END EDITABLE VARS------- + +# If virtualenv specified & exists, using that version of python instead. +if [ -d "$VIRTUAL_ENV_DIR" ]; then + + PYTHON_TO_USE="$VIRTUAL_ENV_DIR/bin/python" + +fi + +# If virtualenv specified & exists at root of project, using that version of python instead. +if [ -d "../$VIRTUAL_ENV_DIR" ]; then + + PYTHON_TO_USE="../$VIRTUAL_ENV_DIR/bin/python" + +fi + +# If the file exists b + +# Scan the dir to see how many channels there are, store them in an arr. +CHANNEL_DIR_ARR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL"'[[:digit:]]*' -printf "%P\n" | sort -t"$CHANNEL_DIR_INCREMENT_SYMBOL" -n) ) + +# If this script see's there are multiple channels, +# then loop through each channel and run the updates +if [ "${#CHANNEL_DIR_ARR[@]}" -gt 0 ]; then + + # If virtualenv specified & exists, using that version of python instead. + if [ -d "./$channel/$VIRTUAL_ENV_DIR" ]; then + + PYTHON_TO_USE=./"$channel"/"$VIRTUAL_ENV_DIR/bin/python" + + fi + + echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected." + + for channel in "${CHANNEL_DIR_ARR[@]}" + do + echo "+++++ Trying to update: $PYTHON_TO_USE $channel/$SCRIPT_TO_EXECUTE_PLUS_ARGS" + # If the running.pid file doesn't exists, create it, start PseudoChannel.py and add the PID to it. + cd "$channel" + "$PYTHON_TO_USE" $SCRIPT_TO_EXECUTE_PLUS_ARGS + cd .. + sleep 1 + + done +fi + +exit 0