Last active
December 13, 2023 09:30
-
-
Save fabricionaweb/8de0634c1131129240faf195018ed4cf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env sh | |
log_file="$(dirname $0)/xseed.log" | |
log() { | |
echo "[$(date +'%Y-%m-%d %T')] $1" >> "$log_file" | |
} | |
log "----------------" | |
if [ "$radarr_eventtype" == "Test" ] || [ "$sonarr_eventtype" == "Test" ]; then | |
log "Test" | |
exit 0 | |
fi | |
if [ -n "$radarr_moviefile_path" ]; then | |
file_path="$radarr_moviefile_path" | |
file_source="$radarr_moviefile_sourcefolder" | |
fi | |
if [ -n "$sonarr_episodefile_path" ]; then | |
file_path="$sonarr_episodefile_path" | |
file_source="$sonarr_episodefile_sourcefolder" | |
fi | |
is_usenet=$(echo "$file_source" | grep -c "/data/usenet") | |
log "file_path: $file_path" | |
log "file_source: $file_source" | |
log "is_usenet: $is_usenet" | |
if [ -f "$file_path" ] && [ "$is_usenet" == "1" ]; then | |
( | |
flock 200 | |
code=$(curl -sX POST http://cross-seed:2468/api/webhook \ | |
-H "x-api-key: [redacted]" \ | |
--data-urlencode "path=$file_path" \ | |
-w "%{http_code}" | |
) | |
log "response: $code" | |
sleep 60 | |
) 200>/tmp/.xseed.lock | |
fi | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment