From d8d826844b345ead3a0c2179e0b8f1a2e3eb34ef Mon Sep 17 00:00:00 2001 From: mutto233 <39921339+mutto233@users.noreply.github.com> Date: Fri, 29 Jun 2018 23:39:35 -0400 Subject: [PATCH] Add files via upload --- channel-dir/generate_daily_sched.sh | 108 +++--- channel-dir/pseudo_schedule.xml | 528 ++++++++++++++++++++++++++++ channel-dir/report_MediaFolders.py | 58 +-- channel-dir/startstop.sh | 180 +++++----- 4 files changed, 701 insertions(+), 173 deletions(-) create mode 100644 channel-dir/pseudo_schedule.xml diff --git a/channel-dir/generate_daily_sched.sh b/channel-dir/generate_daily_sched.sh index bd40e53..ff7361b 100644 --- a/channel-dir/generate_daily_sched.sh +++ b/channel-dir/generate_daily_sched.sh @@ -1,55 +1,55 @@ -#!/bin/bash - -# file: generate_daily_sched.sh - -#---- -# This file is meant to be setup with a crontab task to generate daily schedule (even if app is already running). -# -# **This file is also used to startstop a running channel, trigger an update and restart the channel** -# -# If planning on using the ./startstop.sh script to save power, etc. this script needs to be used to -# update the daily schedule if the app is not running. -#---- - -#---- -# To Use: -# % crontab -e -# 0 0 * * * cd /home/pi/pseudo-channel/ && /home/pi/pseudo-channel/env/bin/python /home/pi/pseudo-channel/PseudoChannel.py -g >> /home/pi/pseudo-channel/pseudo-channel.log 2>&1 -# -# INFO: The above runs every midnight, triggering the virtualenv python version to trigger PsuedoChannel.py -g & send all output to the log. -# Update the paths as you see fit using your user / directories. Mine is using the defualt pi /home dir and virtualenv dirs. -#---- - -#----BEGIN EDITABLE VARS---- - -pid_file=running.pid - -output_pid_path=. - -python_to_use="$(which python)" - -log_file=pseudo-channel.log - -SCRIPT_PATH=$(pwd) - -#----END EDITABLE VARS------- - -if [ ! -e $SCRIPT_PATH/$pid_file ]; then - - $python_to_use $SCRIPT_PATH/PseudoChannel.py -g >> $SCRIPT_PATH/$log_file - - echo "+++++ PseudoChannel.py is not already running am generating the daily schedule." >> $SCRIPT_PATH/$log_file - -else - - echo "+++++ PseudoChannel.py @: $the_pid is already running, stopping channel and running daily schedule update." >> $SCRIPT_PATH/$log_file - - bash $SCRIPT_PATH/startstop.sh - - $python_to_use $SCRIPT_PATH/PseudoChannel.py -g >> $SCRIPT_PATH/$log_file - - bash $SCRIPT_PATH/startstop.sh - - echo "+++++ Successfully stopped running channel, generated daily schedule and restarted script." - +#!/bin/bash + +# file: generate_daily_sched.sh + +#---- +# This file is meant to be setup with a crontab task to generate daily schedule (even if app is already running). +# +# **This file is also used to startstop a running channel, trigger an update and restart the channel** +# +# If planning on using the ./startstop.sh script to save power, etc. this script needs to be used to +# update the daily schedule if the app is not running. +#---- + +#---- +# To Use: +# % crontab -e +# 0 0 * * * cd /home/pi/pseudo-channel/ && /home/pi/pseudo-channel/env/bin/python /home/pi/pseudo-channel/PseudoChannel.py -g >> /home/pi/pseudo-channel/pseudo-channel.log 2>&1 +# +# INFO: The above runs every midnight, triggering the virtualenv python version to trigger PsuedoChannel.py -g & send all output to the log. +# Update the paths as you see fit using your user / directories. Mine is using the defualt pi /home dir and virtualenv dirs. +#---- + +#----BEGIN EDITABLE VARS---- + +pid_file=running.pid + +output_pid_path=. + +python_to_use="$(which python)" + +log_file=pseudo-channel.log + +SCRIPT_PATH=$(pwd) + +#----END EDITABLE VARS------- + +if [ ! -e $SCRIPT_PATH/$pid_file ]; then + + $python_to_use $SCRIPT_PATH/PseudoChannel.py -g >> $SCRIPT_PATH/$log_file + + echo "+++++ PseudoChannel.py is not already running am generating the daily schedule." >> $SCRIPT_PATH/$log_file + +else + + echo "+++++ PseudoChannel.py @: $the_pid is already running, stopping channel and running daily schedule update." >> $SCRIPT_PATH/$log_file + + bash $SCRIPT_PATH/startstop.sh + + $python_to_use $SCRIPT_PATH/PseudoChannel.py -g >> $SCRIPT_PATH/$log_file + + bash $SCRIPT_PATH/startstop.sh + + echo "+++++ Successfully stopped running channel, generated daily schedule and restarted script." + fi \ No newline at end of file diff --git a/channel-dir/pseudo_schedule.xml b/channel-dir/pseudo_schedule.xml new file mode 100644 index 0000000..b4145f5 --- /dev/null +++ b/channel-dir/pseudo_schedule.xml @@ -0,0 +1,528 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/channel-dir/report_MediaFolders.py b/channel-dir/report_MediaFolders.py index c4a90cd..b945452 100644 --- a/channel-dir/report_MediaFolders.py +++ b/channel-dir/report_MediaFolders.py @@ -1,29 +1,29 @@ -# -*- coding: utf-8 -*- -""" -Created on Thu Jun 28 22:59:57 2018 - -@author: Matt -""" - -from pseudo_config import plexLibraries as local_commercials - -commercials = local_commercials["Commercials"] -movies = local_commercials["Movies"] -tvs = local_commercials["TV Shows"] - -commercials_file = open('Commercial_Libraries.txt','w') -movies_file = open('Movie_Libraries.txt','w') -tvs_file = open('TV_Libraries.txt','w') -for commercial in commercials: - commercials_file.write(commercial + '\n') -for movie in movies: - movies_file.write(movie + '\n') -for tv in tvs: - tvs_file.write(tv + '\n') - -commercials_file.close() -movies_file.close() -tvs_file.close() - - - +# -*- coding: utf-8 -*- +""" +Created on Thu Jun 28 22:59:57 2018 + +@author: Matt +""" + +from pseudo_config import plexLibraries as local_commercials + +commercials = local_commercials["Commercials"] +movies = local_commercials["Movies"] +tvs = local_commercials["TV Shows"] + +commercials_file = open('Commercial_Libraries.txt','w') +movies_file = open('Movie_Libraries.txt','w') +tvs_file = open('TV_Libraries.txt','w') +for commercial in commercials: + commercials_file.write(commercial + '\n') +for movie in movies: + movies_file.write(movie + '\n') +for tv in tvs: + tvs_file.write(tv + '\n') + +commercials_file.close() +movies_file.close() +tvs_file.close() + + + diff --git a/channel-dir/startstop.sh b/channel-dir/startstop.sh index 1bac057..82756ed 100644 --- a/channel-dir/startstop.sh +++ b/channel-dir/startstop.sh @@ -1,91 +1,91 @@ -#!/bin/bash - -# file: startstop.sh - -#---- -# Simple script to start / stop a python script in the background. -#---- - -#---- -# To Use: -# Just run: "./startstop.sh". If the process is running it will stop it or it will start it if not. -#---- - -#----BEGIN EDITABLE VARS---- - -SCRIPT_TO_EXECUTE_PLUS_ARGS='PseudoChannel.py -m -r' - -OUTPUT_PID_FILE=running.pid - -OUTPUT_PID_PATH=. - -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 the .pid file doesn't exist (let's assume no processes are running)... -if [ ! -e "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" ]; then - - # If the running.pid file doesn't exists, create it, start PseudoChannel.py and add the PID to it. - "$PYTHON_TO_USE" ./$SCRIPT_TO_EXECUTE_PLUS_ARGS > /dev/null 2>&1 & echo $! > "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" - - echo "Started $SCRIPT_TO_EXECUTE_PLUS_ARGS @ Process: $!" - - sleep .7 - - echo "Created $OUTPUT_PID_FILE file in $OUTPUT_PID_PATH dir" - -else - - # If the running.pid exists, read it & try to kill the process if it exists, then delete it. - the_pid=$(<$OUTPUT_PID_PATH/$OUTPUT_PID_FILE) - - rm "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" - - echo "Deleted $OUTPUT_PID_FILE file in $OUTPUT_PID_PATH dir" - - echo "kill: $the_pid" - - kill "$the_pid" - - COUNTER=1 - - while [ -e /proc/$the_pid ] - - do - - echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid is still running" - - sleep .7 - - COUNTER=$[$COUNTER +1] - - if [ $COUNTER -eq 20 ]; then - - kill -9 "$the_pid" - - fi - - if [ $COUNTER -eq 40 ]; then - - exit 1 - - fi - - done - - echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid has finished" - -fi - +#!/bin/bash + +# file: startstop.sh + +#---- +# Simple script to start / stop a python script in the background. +#---- + +#---- +# To Use: +# Just run: "./startstop.sh". If the process is running it will stop it or it will start it if not. +#---- + +#----BEGIN EDITABLE VARS---- + +SCRIPT_TO_EXECUTE_PLUS_ARGS='PseudoChannel.py -m -r' + +OUTPUT_PID_FILE=running.pid + +OUTPUT_PID_PATH=. + +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 the .pid file doesn't exist (let's assume no processes are running)... +if [ ! -e "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" ]; then + + # If the running.pid file doesn't exists, create it, start PseudoChannel.py and add the PID to it. + "$PYTHON_TO_USE" ./$SCRIPT_TO_EXECUTE_PLUS_ARGS > /dev/null 2>&1 & echo $! > "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" + + echo "Started $SCRIPT_TO_EXECUTE_PLUS_ARGS @ Process: $!" + + sleep .7 + + echo "Created $OUTPUT_PID_FILE file in $OUTPUT_PID_PATH dir" + +else + + # If the running.pid exists, read it & try to kill the process if it exists, then delete it. + the_pid=$(<$OUTPUT_PID_PATH/$OUTPUT_PID_FILE) + + rm "$OUTPUT_PID_PATH/$OUTPUT_PID_FILE" + + echo "Deleted $OUTPUT_PID_FILE file in $OUTPUT_PID_PATH dir" + + echo "kill: $the_pid" + + kill "$the_pid" + + COUNTER=1 + + while [ -e /proc/$the_pid ] + + do + + echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid is still running" + + sleep .7 + + COUNTER=$[$COUNTER +1] + + if [ $COUNTER -eq 20 ]; then + + kill -9 "$the_pid" + + fi + + if [ $COUNTER -eq 40 ]; then + + exit 1 + + fi + + done + + echo "$SCRIPT_TO_EXECUTE_PLUS_ARGS @: $the_pid has finished" + +fi + exit 0 \ No newline at end of file