-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathqnap-plex-auto-updater.sh
25 lines (23 loc) · 989 Bytes
/
qnap-plex-auto-updater.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
#!/bin/bash
current_dir=$(dirname "$0")
last=$( cat ${current_dir}/last)
echo "installed: ${last}"
plex_token=$(cat /share/PlexData/Plex\ Media\ Server/Preferences.xml | grep -oP 'PlexOnlineToken="\K[^"]+')
plex_token=$(cat /share/PlexData/Plex\ Media\ Server/Preferences.xml | grep -oE 'PlexOnlineToken="[^"]+"' | sed -E 's/PlexOnlineToken="([^"]+)"/\1/')
plex_url="https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=${plex_token}"
echo "Plex URL: ${plex_url}"
jq_filter=".nas.QNAP.releases[] | select(.build==\"linux-x86_64\") | .url"
latest_json=$(curl -sS "${plex_url}")
latest=$(echo "${latest_json}" | jq -r "${jq_filter}")
if [ "$last" != "$latest" ]; then
echo "new version $latest available (prev: $last). Downloading it."
curl "${latest}" -o ${current_dir}/plex.qpkg
sh ${current_dir}/plex.qpkg
rm ${current_dir}/plex.qpkg
echo ${latest} > ${current_dir}/last
echo "done"
else
echo "same versions"
echo $latest
echo $last
fi