Skip to content

Commit

Permalink
clean-downloads script
Browse files Browse the repository at this point in the history
  • Loading branch information
youegraillot committed Jul 16, 2022
1 parent 6cb65bb commit aed1f94
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ In `AUTOCONFIG` mode (default), the only manual manipulation you'll only have to
- Deemix as an indexer
- Deemix as a download client
- Flac2Custom script connection if `FLAC2CUSTOM_ARGS` is set
- clean-downloads script connection to keep your downloads folder *clean* after each imports

In case you don't want the automagical part (which is really the only value of this image), just set `AUTOCONFIG` environment variable to `false`.

Expand Down
16 changes: 15 additions & 1 deletion root/etc/services.d/setup/run
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,21 @@ if [ "$AUTOCONFIG" = "true" ]; then
echo "[autoconfig] FLAC2CUSTOM_ARGS is set"
if ! isPresent "flac2" "notification"; then
echo "[autoconfig] Configuring flac2custom.sh custom script"
apiCall "POST" "notification" '{"onGrab":false,"onReleaseImport":true,"onUpgrade":true,"onRename":false,"onHealthIssue":false,"onDownloadFailure":false,"onImportFailure":false,"onTrackRetag":false,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnReleaseImport":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnHealthIssue":true,"includeHealthWarnings":false,"supportsOnDownloadFailure":false,"supportsOnImportFailure":false,"supportsOnTrackRetag":true,"supportsOnApplicationUpdate":true,"name":"Flac2Custom","fields":[{"name":"path","value":"/usr/local/bin/flac2custom.sh"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"https://wiki.servarr.com/lidarr/supported#customscript","message":{"message":"Testing will execute the script with the EventType set to Test, ensure your script handles this correctly","type":"warning"},"tags":[]}'
apiCall "POST" "notification" '{"onGrab":false,"onReleaseImport":true,"onUpgrade":true,"onRename":false,"onHealthIssue":false,"onDownloadFailure":false,"onImportFailure":false,"onTrackRetag":false,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnReleaseImport":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnHealthIssue":true,"includeHealthWarnings":false,"supportsOnDownloadFailure":false,"supportsOnImportFailure":false,"supportsOnTrackRetag":true,"supportsOnApplicationUpdate":true,"name":"Flac2Custom","fields":[{"name":"path","value":"/usr/local/bin/flac2custom.sh"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"","message":{"message":"","type":"warning"},"tags":[]}'
fi
fi
fi

echo "
----------------------------------------------------------------------
Utilities SETUP
----------------------------------------------------------------------
AUTOCONFIG=$AUTOCONFIG
----------------------------------------------------------------------
"
if [ "$AUTOCONFIG" = "true" ]; then
if ! isPresent "Clean Downloads" "notification"; then
echo "[autoconfig] Configuring flac2custom.sh custom script"
apiCall "POST" "notification" '{"onGrab":false,"onReleaseImport":true,"onUpgrade":true,"onRename":false,"onHealthIssue":false,"onDownloadFailure":false,"onImportFailure":false,"onTrackRetag":false,"onApplicationUpdate":false,"supportsOnGrab":true,"supportsOnReleaseImport":true,"supportsOnUpgrade":true,"supportsOnRename":true,"supportsOnHealthIssue":true,"includeHealthWarnings":false,"supportsOnDownloadFailure":false,"supportsOnImportFailure":false,"supportsOnTrackRetag":true,"supportsOnApplicationUpdate":true,"name":"Clean Downloads","fields":[{"name":"path","value":"/usr/local/bin/clean-downloads.sh"},{"name":"arguments"}],"implementationName":"Custom Script","implementation":"CustomScript","configContract":"CustomScriptSettings","infoLink":"","message":{"message":"","type":"warning"},"tags":[]}'
fi
fi
12 changes: 12 additions & 0 deletions root/usr/local/bin/clean-downloads.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

echo "Info|Lidarr event: $lidarr_eventtype" >&2

# Handle Lidarr Test event
if [[ "$lidarr_eventtype" = "Test" ]]; then
echo "Info|Script was test executed successfully." >&2
exit 0
fi

echo "Info|Cleaning empty folders" >&2
find /downloads -type d -empty -print -delete >&2

0 comments on commit aed1f94

Please sign in to comment.