From e15213c24ba8e849bdcafcc9331c4debf8448705 Mon Sep 17 00:00:00 2001 From: Justin E Date: Thu, 17 Jan 2019 23:07:12 -0800 Subject: [PATCH] Added multi-channel scripts: viewer/api plus bash script to generate html files. --- main-dir/generate-html-schedules.sh | 72 +++++++++ main-dir/multi-channel-api.php | 64 ++++++++ main-dir/multi-channel-viewer.php | 217 ++++++++++++++++++++++++++++ 3 files changed, 353 insertions(+) create mode 100644 main-dir/generate-html-schedules.sh create mode 100644 main-dir/multi-channel-api.php create mode 100644 main-dir/multi-channel-viewer.php diff --git a/main-dir/generate-html-schedules.sh b/main-dir/generate-html-schedules.sh new file mode 100644 index 0000000..3440e89 --- /dev/null +++ b/main-dir/generate-html-schedules.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# file: generate-html-schedules.sh + +#---- +# Simple script to generate the ONLY the html schedule for each individual channel. Useful when using the multi-channel-viewer.php file. +# +#---- + +#---- +# To Use: +# ./generate-html-schedules.sh +#---- + +#----BEGIN EDITABLE VARS---- + +SCRIPT_TO_EXECUTE_PLUS_ARGS='PseudoChannel.py -m' + +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" + + echo "+++++ Virtualenv found, using: $VIRTUAL_ENV_DIR/bin/python" + +fi + +# 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 daily schedule generator +if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then + + echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected." + + for channel in "${CHANNEL_DIR_ARR[@]}" + do + + # If the .pid file exists for this channel, skip it because it updated the html when running. + if [ ! -f "$channel/running.pid" ]; then + + echo "+++++ Trying to generate HTML schedule: ""$PYTHON_TO_USE" ./"$channel"/$SCRIPT_TO_EXECUTE_PLUS_ARGS + + cd "$channel" && $PYTHON_TO_USE $SCRIPT_TO_EXECUTE_PLUS_ARGS + + echo "+++++ Generated: $channel - HTML schedule." + + sleep 1 + + cd ../ + + sleep 1 + + fi + + done + +fi + +exit 0 \ No newline at end of file diff --git a/main-dir/multi-channel-api.php b/main-dir/multi-channel-api.php new file mode 100644 index 0000000..4411aa3 --- /dev/null +++ b/main-dir/multi-channel-api.php @@ -0,0 +1,64 @@ + +$output"; +?> \ No newline at end of file diff --git a/main-dir/multi-channel-viewer.php b/main-dir/multi-channel-viewer.php new file mode 100644 index 0000000..12681e4 --- /dev/null +++ b/main-dir/multi-channel-viewer.php @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $value) + { + echo $key." ".$value."
"; + }*/ + echo " Update Complete"; + } + if (isset($_GET['update'])) { + echo 'Generating new html schedules.'; + updateNowPlayingSchedules(); + } + ?> + +
">
+ +

Multi-Channel

+ +
+ + Generate Now Playing Schedules +
+ +
+ < +

+ > +
+ + + +
+ + + \ No newline at end of file