-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from madslundt/empty_plex_trash
Empty plex trash
- Loading branch information
Showing
6 changed files
with
57 additions
and
4 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 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@reboot scripts/mount.remote &>> logs/mount.log | ||
@daily scripts/cloudupload &>> logs/cloudupload.log | ||
@weekly scripts/rmlocal &>> logs/rmlocal.log | ||
@hourly scripts/mountcheck &>> logs/status.log | ||
@hourly scripts/empty.trash &>> logs/emptytrash.log |
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,45 @@ | ||
#!/bin/bash | ||
. "INSERT_CONFIG_FILE" | ||
|
||
getSections() { | ||
if [ -z "${plex_url}" ]; then | ||
echo "Fill in plex url and plex token to retrieve sections. Aborting..." | ||
exit 02 | ||
fi | ||
|
||
sections=$(curl -s -G -L "${plex_url}/library/sections?X-Plex-Token=${plex_token}" | xpath -e "/MediaContainer/Directory/@key" 2>&1 | sed -re 's/-- NODE --//g'$ | ||
echo $sections | ||
} | ||
emptyTrash() { | ||
bash mountcheck | ||
cloud_dir="${cloud_encrypt_dir}" | ||
if [ "$encrypt_media" -eq "0" ]; then | ||
cloud_dir="${cloud_decrypt_dir}" | ||
fi | ||
if mountpoint -q "$cloud_dir" && mountpoint -q "$cloud_decrypt_dir" && mountpoint -q "${local_media_dir}"; then | ||
sections=$(getSections) | ||
if [ -z "${sections}" ]; then | ||
echo "Could not get sections from ${plex_url} with the inserted token. Aborting..." | ||
exit 02 | ||
fi | ||
IFS="," read -r -a arr <<< "$sections" | ||
for i in "${arr[@]}" | ||
do | ||
if [[ ! -z "${i}" ]]; then | ||
echo "${plex_url}/library/sections/${i}/emptyTrash" | ||
curl -s -G -L "${plex_url}/library/sections/${i}/emptyTrash?X-Plex-Token=${plex_token}" | ||
fi | ||
done | ||
exit 0 | ||
else | ||
echo "Mount is not up after mountcheck. Aborting..." | ||
exit 02 | ||
fi | ||
} | ||
emptyTrash |
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