-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merging develop and tagging another release - almost alpha.
- Loading branch information
Showing
9 changed files
with
340 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
If you'd like to set up multi-channel support using PseudoChannel.py, use these scripts to: | ||
|
||
1) Use a remote or Alexa or some device to trigger the channelup.sh/channeldown.sh scripts to cycle through the channels. | ||
|
||
2) Setup a "crontab" to run generate-channels-daily-schedule.sh script to automate each PseudoChannel.py to generate the daily | ||
schedule. | ||
|
||
3) Use, "updatechannels.sh" to update each channels' local db with newly added Plex library items. | ||
|
||
4) Use, "manual.sh" to manually trigger a particular channel... i.e. `./manual.sh 9`, to switch to channel 9. | ||
|
||
All of these scripts need to be placed in the "./channels/" dir. Your directory structure should look something like this: | ||
|
||
```bash | ||
-channels/ | ||
--plex_token.py | ||
--channel_1/ | ||
---pseudo-channel.db | ||
---PseudoChannel.py | ||
---...etc. | ||
--channel_2/ | ||
---pseudo-channel.db | ||
---PseudoChannel.py | ||
---...etc. | ||
--channel_3/ | ||
---pseudo-channel.db | ||
---PseudoChannel.py | ||
---...etc. | ||
--channelup.sh | ||
--channeldown.sh | ||
--generate-channels-daily-schedule.sh | ||
--updatechannels.sh | ||
``` | ||
|
||
*Note: this functionality is still being tweaked as are the bash scripts so only attempt this implementation if you are somewhat confident to tinker with bash/crontabs, etc. Or feel free to contact us at github or the discord chat room dedicated to PseudoChannel.tv. Just check the repo for more info. |
This file contains 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
This file contains 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
72 changes: 72 additions & 0 deletions
72
multi-channel-bash-scripts/generate-channels-daily-schedules.sh
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
|
||
# file: generate-channels-daily-schedules.sh | ||
|
||
#---- | ||
# Simple script to generate the daily schedule for each individual channel. | ||
# | ||
#---- | ||
|
||
#---- | ||
# To Use: | ||
# This script needs to be setup with a crontab entry that runs everyday at midnight. | ||
#---- | ||
|
||
#----BEGIN EDITABLE VARS---- | ||
|
||
SCRIPT_TO_EXECUTE_PLUS_ARGS='PseudoChannel.py -g' | ||
|
||
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") ) | ||
|
||
# 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 will update while running. | ||
if [ ! -f "$channel/running.pid" ]; then | ||
|
||
echo "+++++ Trying to generate daily schedule: ""$PYTHON_TO_USE" ./"$channel"/$SCRIPT_TO_EXECUTE_PLUS_ARGS | ||
|
||
cd "$channel" && "./generate_daily_sched.sh" | ||
|
||
echo "+++++ Generated: $channel - new schedule." | ||
|
||
sleep 1 | ||
|
||
cd ../ | ||
|
||
sleep 1 | ||
|
||
fi | ||
|
||
done | ||
|
||
fi | ||
|
||
exit 0 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
|
||
# Credits: irodimus | ||
|
||
# file: manual.sh | ||
|
||
#---- | ||
# Simple script to change to specific channel given - triggering start / stop. | ||
#---- | ||
|
||
#---- | ||
# To Use: | ||
# Run script by including the channel you'd like to run as an argument: ex. ./manual.sh 2, ./manual.sh 9 | ||
# | ||
# Configure something (a tv remote or alexa) to trigger this script. Make sure you move this script just | ||
# outside of the pseudo-channel directories: | ||
# ------------------- | ||
# -channels/ | ||
# --pseudo-channel_1/ | ||
# ---startstop.sh | ||
# --pseudo-channel_2/ | ||
# ---startstop.sh | ||
# --pseudo-channel_3/ | ||
# ---startstop.sh | ||
# --manual.sh <--- on the same level as the 3 channels. | ||
#---- | ||
|
||
# Make sure that each channel dir ends with a "_" + an incrementing number as seen above. | ||
|
||
#----BEGIN EDITABLE VARS---- | ||
|
||
SCRIPT_TO_EXECUTE='startstop.sh' | ||
|
||
OUTPUT_PREV_CHANNEL_PATH=. | ||
|
||
OUTPUT_PREV_CHANNEL_FILE=".prevplaying" | ||
|
||
CHANNEL_DIR_INCREMENT_SYMBOL="_" | ||
|
||
#----END EDITABLE VARS------- | ||
|
||
FIRST_RUN=false | ||
|
||
# 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") ) | ||
|
||
# If the previous channel txt file doesn't exist already create it (first run?) | ||
if [ ! -e "$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE" ]; then | ||
|
||
#FIRST_RUN_NUM=$((${#CHANNEL_DIR_ARR[@]})) | ||
echo 1 > "$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE" | ||
|
||
echo "First run: $FIRST_RUN_NUM" | ||
|
||
FIRST_RUN=true | ||
|
||
fi | ||
|
||
# If this script see's there are multiple channels, | ||
# then read file, get prevchannel and nextchannel, and trigger next channel: | ||
if [ "${#CHANNEL_DIR_ARR[@]}" -gt 1 ]; then | ||
|
||
NEXT_CHANNEL=$1 | ||
|
||
NEXT_CHANNEL_DIR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL""$NEXT_CHANNEL" -printf "%P\n") ) | ||
|
||
PREV_CHANNEL_FOUND=false | ||
|
||
echo "+++++ There are ${#CHANNEL_DIR_ARR[@]} channels detected." | ||
|
||
PREV_CHANNEL=$(<$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE) | ||
|
||
PREV_CHANNEL_DIR=( $(find . -maxdepth 1 -type d -name '*'"$CHANNEL_DIR_INCREMENT_SYMBOL""$PREV_CHANNEL" -printf "%P\n") ) | ||
|
||
echo "+++++ It looks like the previous channel was: $PREV_CHANNEL" | ||
|
||
echo "+++++ The next channel is: $NEXT_CHANNEL" | ||
|
||
# Write next channel to previous channel file to reference later | ||
echo "$NEXT_CHANNEL" > "$OUTPUT_PREV_CHANNEL_PATH/$OUTPUT_PREV_CHANNEL_FILE" | ||
|
||
# Finally let's trigger the startstop script in both the previous channel and the next channel dirs. | ||
# This will stop the previous channels playback & trigger the next channels playback | ||
|
||
if [ "$FIRST_RUN" = false ]; then | ||
cd "$OUTPUT_PREV_CHANNEL_PATH"/"$PREV_CHANNEL_DIR" && ./"$SCRIPT_TO_EXECUTE" | ||
cd ../"$NEXT_CHANNEL_DIR" && ./"$SCRIPT_TO_EXECUTE" | ||
else | ||
|
||
cd "$OUTPUT_PREV_CHANNEL_PATH"/"$NEXT_CHANNEL_DIR" && ./"$SCRIPT_TO_EXECUTE" | ||
|
||
fi | ||
|
||
sleep 1 | ||
|
||
|
||
fi | ||
|
||
exit 0 |
Oops, something went wrong.