Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save g-r-a-v-e-l-y/35a91ca9948700b00b6a043cfcbaeb3d to your computer and use it in GitHub Desktop.
Save g-r-a-v-e-l-y/35a91ca9948700b00b6a043cfcbaeb3d to your computer and use it in GitHub Desktop.
I use Transmission and sabnzbd behind a basic auth http proxy kinda like this now
on adding folder items to thisFolder after receiving added_items
repeat with addedFile in added_items
tell application "Finder"
if (the name of the addedFile ends with "torrent") then
set transmissionRemote to "/usr/local/bin/transmission-remote https://TRANSMISSION_HOST/transmission -n 'USERNAME:PASSWORD' --add '" & POSIX path of addedFile & "' | sed 's/\"//g' | grep -oE '[^ ]+$'"
set fileName to name of (info for addedFile)
display notification fileName with title "Torrent Janitor - Queueing Torrent"
set transmissionResponse to do shell script transmissionRemote
display notification fileName with title "Torrent Janitor - " & transmissionResponse
tell application "Finder"
delete addedFile
end tell
end if
if (the name of the addedFile ends with "nzb") then
set curlOneLiner to "/usr/bin/curl -u USERNAME:PASSWORD --basic https://SABNZBD_HOST/api -F 'apikey=API_KEY' -F 'mode=addfile' -F 'name=@" & POSIX path of addedFile & "'"
set fileName to name of (info for addedFile)
display notification "Queueing " & fileName & "for download." with title "Usenet NZB Janitor"
set curlOneLinerResponse to do shell script curlOneLiner
display notification fileName & ": " & curlOneLinerResponse with title "Usenet NZB Janitor"
tell application "Finder"
delete addedFile
end tell
end if
end tell
end repeat
end adding folder items to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment