Created
September 18, 2019 00:48
-
-
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.
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
$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