Monthly Archives: March 2011

uTorrent RSS Downloader and e-mail notification for completed downloads

I recently found the nice feature RSS Downloader in uTorrent where you can choose to download things automatically using RSS.
This function lacks one thing – some kind of message or notification when it has started or finished a download.
So I created the below Windows Power Shell script that runs every 10 minutes and sends an e-mail if a new torrent has been added to the uTorrent data-directory and if that torrent´s name can be found in the uTorrent rss.dat file – which stores a list of all torrents downloaded using RSS Downloader.

#______________________________________________
# GetNewuTorrentDownloads.ps1
# uTorrent RSS Downloader notification script
#
$From = "you@your-isp.com"
$To = "you@your-isp.com"
$tenminutesago = (get-date).AddMinutes(-10)
# Note: you may need to change the path to your uTorrent data directory.
$recs = Get-ChildItem "C:\Users\Administrator\AppData\Roaming\uTorrent\*.torrent" |
        where-object {$_.lastwritetime -gt $tenminutesago} |
        Sort-Object LastWriteTime -Descending
if ( $recs.Length -gt 0 ) {
  foreach ($TorrentFile in $recs) {
    $TorrentName = $TorrentFile.Name.Replace(".torrent", "")
    $TorrentDownloaded = $TorrentFile.LastWriteTime
    # Note: you may need to change the path to your uTorrent data directory.
    $sel = select-string -pattern $TorrentName -path C:\Users\Administrator\AppData\Roaming\uTorrent\rss.dat
    if ($sel -ne $null) {
        $subject = "$TorrentName has been downloaded"
        $body = "The torrent $TorrentName was downloaded at $TorrentDownloaded ."
        $smtp = New-Object System.Net.Mail.SmtpClient("smtp.yourisp.com", "25");
        # Uncomment the below row if your ISP´s outgoing mail server requires authentication.
        #$smtp.Credentials = New-Object System.Net.NetworkCredential("username", "password");
        $smtp.Send($From, $To, $subject, $body);
    }
  }
}