forked from justinemter/pseudo-channel
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdatexml.sh
75 lines (49 loc) · 2 KB
/
updatexml.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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