Skip to content

Instantly share code, notes, and snippets.

@NotoriousPyro
Created September 18, 2019 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NotoriousPyro/e7bffdaed0acf27af0ae7fd6223ebc29 to your computer and use it in GitHub Desktop.
Save NotoriousPyro/e7bffdaed0acf27af0ae7fd6223ebc29 to your computer and use it in GitHub Desktop.
Transmission RPC to PowerShell Object calls example. Removes torrents which are completed. I may make this into a tool when I get more time.
$transmission = Join-Path "C:\Program Files\Transmission" transmission-remote.exe
$server = "127.0.0.1:9091"
function GetTorrentObjectList {
param (
$TorrentList
)
$torrents = [Collections.ArrayList]@()
foreach ($torrent in $TorrentList[1..($TorrentList.Count - 2)]) {
$t = $torrent.TrimStart(' ') -isplit '\s{2,}'
$torrents.Add([PSCustomObject]@{
ID = $t[0]
Done = $t[1]
Have = $t[2]
ETA = $t[3]
Up = $t[4]
Down = $t[5]
Ratio = $t[6]
Status = $t[7]
Name = "$($t[8..9999])"
}) | Out-Null
}
return $torrents
}
$torrentlist = & $transmission $server -l
$torrents = GetTorrentObjectList $torrentlist
$torrents | Where-Object { $_.Done -eq '100%' } | ForEach-Object {
Write-Host ('Removing Torrent by ID: {0}' -f $_.ID) -ForegroundColor Red
& $transmission -t $_.ID --remove
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment