Axman84 Posted December 10, 2011 Report Posted December 10, 2011 Hi all,First off: thanks to the uTorrent team for an EXCELLENT function-rich, simple and lightweight piece of software. There should be more software developed this way.In my quest to make my entertainment center setup(s) automated, I wanted to automatically handle my torrents. I got tired of all the manual but repetitive extracting, moving, copying, and deleting, so I created two batch scripts to handle this. One for new downloads and one for deleting old torrents, and they get parameters directly from uTorrent.Under uTorrent preferences -> Advanced -> Run Program I have it set up like this:For "Run this program when a torrent finishes", I have the following:C:\scripts\torrentscript.bat "%D" "%N" "%L" "%K" "%F" >> torrentlog.txtFor "Run this program when a torrent changes state", I have the following:C:\scripts\deletescript.bat "%D" "%N" "%S" "%K" "%F" >> deletelog.txtThe output of the scripts is piped into logfiles for debugging purposes.Scripts follow in posts 2 and 3.Note: These are Windows batch scripts (.bat files). I don't have much experience with win batch programming but I quickly realized that it certainly has its limitations, especially with respect to dealing with strings and quotation marks for example. If anyone decides to check this out and make a Unix/shell script version, I'd like to have it, as I may go that route if I continue to expand the scripts. Thanks!
Axman84 Posted December 10, 2011 Author Report Posted December 10, 2011 Here is the first script, torrentscript.bat, which handles newly downloaded torrents. It is fairly customized for my use, so everything may not be entirely logical to everyone. Feel free to suggest changes, and of course ask questions if anything needs clarification. Essentially it uses the label to determine the type of download, and extracts or copies files accordingly.If type cannot be determined by label it checks for files to copy. The "rem" comments in the scripts below are intended to do some explaining. The trickiest part is the label prefix logic - I use labels with slashes for shows to determine the destination path. So that for example a torrent with label "Shows\Boardwalk Empire" can be extracted/copied to D:\Shows\Boardwalk Empire. Winrar needs to be installed for extraction of rars. I recommend reading the script in an editor such as Notepad++ to make it easier to read, with color coding and all.Code:@echo offtitle Axmans torrent-file scriptrem Parameter usage: fromdir torrent-name label kind [filename]rem corresponds to uTorrents flags: %D %N %L %K %F echo *********************************************echo Run on %date% at %time%set fromdir=%1set name=%2set label=%3set kind=%4set filename=%5set savepartition=D:set moviedir=%savepartition%\Moviesset musicdir=%savepartition%\Musicset label_prefix=""echo Input: %fromdir% %name% %label% %kind% %filename%rem Determine length of label stringecho.%label%>lenfor %%a in (len) do set /a len=%%~za -2rem This is to pick up if label begins with "Shows" (ex. "Shows\Boardwalk Empire")if %len% geq 7 set label_prefix=%label:~1,5%echo label_prefix = %label_prefix%echo %date% at %time%: Handling torrent %name% >> handled_torrents.txtrem If label is "Movies"if %label%=="Movies" goto moviesrem If label starts with "Shows"if %label_prefix%==Shows goto showsrem If label is "Music"if %label%=="Music" goto copymp3srem If there are mp3 files in fromdir and it is a multi-file torrentif exist %fromdir%\*.mp3 if %kind%=="multi" goto copymp3srem Last resortrem Double underscores so the folders are easier to spot (listed on top in explorer)set todir=%savepartition%\__%name%if %kind%=="single" goto copyfileif %kind%=="multi" goto copyallGOTO:EOFrem xcopy switches:rem S Copies directories and subdirectories except empty ones.rem I If destination does not exist and copying more than one file, assumes that destination must be a directory.rem L Displays files that would be copied. FOR DEBUGrem Y Suppresses prompting to confirm you want to overwrite an existing destination file.:moviesecho **Movieset todir=%moviedir%\%name%echo todir = %todir%rem If there are rar files in the folder, extract them.rem If there are mkvs, copy them. Check for rars first in case there is a sample.mkv, then we want the rarsif %kind%=="single" goto copyfileif exist %fromdir%\*.rar goto extractrarif exist %fromdir%\*.mkv goto copymkvsecho Guess we didnt find anythingGOTO:EOF:showsecho **Showset todir=%savepartition%\%label%if %kind%=="single" goto copyfileif exist %fromdir%\*.rar goto extractrarif exist %fromdir%\*.mkv goto copymkvsecho Guess we didnt find anythingGOTO:EOF:copymp3secho **Musicset todir=%musicdir%\%name%if %kind%=="single" goto copyfileecho Copy all mp3s from %fromdir% and subdirs to %musicdir%\%name%xcopy %fromdir%\*.mp3 %todir% /S /I /YGOTO:EOF:copyallecho **Undefinedecho Copy all contents of %fromdir% to %todir%xcopy %fromdir%\*.* %todir% /S /I /YGOTO:EOF:copyfilerem Copies single file from fromdir to todirecho Copy %filename% from %fromdir% to %todir%xcopy %fromdir%\%filename% %todir%\ /S /YGOTO:EOF:copymkvsecho Copy all mkvs from %fromdir% and subdirs to %todir%xcopy %fromdir%\*.mkv %todir% /S /I /YGOTO:EOF:extractrarecho Extracts all rars in %fromdir% to %todir%. rem Requires WinRar installed to c:\Program filesif not exist %todir% mkdir %todir%"c:\program files\winrar\winrar.exe" x -ilog %fromdir%\*.rar *.* %todir%GOTO:EOF
Axman84 Posted December 10, 2011 Author Report Posted December 10, 2011 This script, deletescript.bat, simply deletes the files of a torrent if it has reached the "Finished" state, i.e. has reached the seeding goal. At this point I dont need the files any more. The data was properly copied/extracted when the download finished anyways.@echo offtitle Axmans delete scriptrem Only run if state is finished (11), delete torrent with all filesif not %3%=="11" exitrem Parameter usage: basedir torrent-name state kind [filename]rem corresponds to uTorrents flags: %D %N %S %K %F echo *********************************************echo Run on %date% at %time%set basedir=%1set name=%2set state=%3set kind=%4set filename=%5echo Input: %basedir% %name% %state% %kind% %filename%echo %date% at %time%: Handling torrent %name% >> deleted_torrents.txtecho **Deletingif %kind%=="single" goto deletefileif %kind%=="multi" goto deleteallecho ERROR - Unrecognized kind (%kind%)GOTO:EOF:deletefileecho Deleting file %basedir%\%filename%del %basedir%\%filename%GOTO:EOF:deleteallrem Simply some precautions hereif %basedir%=="D:\_Temp" exitif %basedir%=="D:\Shows" exitif %basedir%=="D:\Movies" exitif %basedir%=="D:\Music" exitif %basedir%=="D:\" exitif %basedir%=="C:\" exitecho Deleting directory %basedir% with all subcontentrmdir /S /Q %basedir%GOTO:EOF
Axman84 Posted December 10, 2011 Author Report Posted December 10, 2011 Again, do yourself a favor and read the scripts in an editor if you want to try to go through the logic.Also, uTorrent 3.0 is required for this to work due to the parameters. Some things I'd like to implement next is a way of sending notifications to my phone when handling a torrent. The script currently updates a log file with torrent name date and time, but thats it. I could use a command line email client and email myself, but all the outgoing servers I use (gmail for example) use TLS encryption and the simple command line email programs dont play well with encryption, so I'd have to set up an emailserver on my machine, which isnt worth the hassle imo.All comments and improvement suggestions are most welcome!
LitlJay Posted December 11, 2011 Report Posted December 11, 2011 Those scripts are awesome! Thanks!Miranda is a pretty garden-variety IM client, with the unique exception that it supports sending messages via the CLI, so it is great for this application. It is compatible with all of the major IM protocols (AIM, ICQ, etc) so it can message you on your phone over one of those. I have a private XMPP/Jabber network running in my office (OpenFire on W2K3) so that we can IM each other without the network being open to the public and spimmers and such, so I have utorrent/Miranda using that instead and I installed Xabber on my phone to receive the messages.The main downside to Miranda is that the configuration dialogue is anything but intuitive. It takes some patience to find your way around and set up. It works great once you get it going, though.
Trix44 Posted January 20, 2012 Report Posted January 20, 2012 Axman, first off thanks a lot for this script. It really solved some headaches I had.Maybe you may have a clue, why it works for tv shows, but doesn't work for Movies - they seem to be not copied at all. What I've changed in you script is that I set a fixed movie dir, which is completely different from TV Shows dir, but on the same drive. This line:set moviedir=%savepartition%\Movieswas changed to:set moviedir=C:\Users\user\videos\MoviesI suspect that may have caused issues, though don't understand what to change to make it work. In the log file it's showing that it tries to copy the movie file to let's say:C:\Users\user\videos\Movies\"name.name.of.the.torrent.BRrip.avi" But after that there goes line"Guess nothing was found"Could it be that it fails to create a directory with the same name as the torrent's name? I've set same shared permissions for both directories, should be no issue with that. Same situation with the movies those have multiple files in the log file it says "0 files copied"Any advice where to look for problems?
krowie Posted April 8, 2012 Report Posted April 8, 2012 Axman84, Thank you for a fantastic script - seriously well done. Has really helped me create a custom version using some of your methods. For yours or anyone elses info I used "C:\Program Files\theRenamer\theRenamer.exe" -fetchAt the end of my TV routine to automatically rename downloaded eps. Works a treat. Thanks again mate
retnak Posted April 16, 2012 Report Posted April 16, 2012 which version of "the renamer" are you using? I am having problem with the auto rename function (there is a paw you have to click in version 7.57)Axman84, Thank you for a fantastic script - seriously well done. Has really helped me create a custom version using some of your methods. For yours or anyone elses info I used "C:\Program Files\theRenamer\theRenamer.exe" -fetchAt the end of my TV routine to automatically rename downloaded eps. Works a treat. Thanks again mate
retnak Posted April 16, 2012 Report Posted April 16, 2012 also does anyone know how to run multiple scripts in utorrent at once? for instance one to rename the files using "therenamer" and then one to move them to my htpc?<<programming noob
fazered Posted May 4, 2012 Report Posted May 4, 2012 Hey as I found this post so useful I thought I'd share the changes I made so it might help others. I had a slightly different requirement as most of my download goes into the same containing folder. I specify the absolute position for the log in the my call (utorrent preferences > Advanced > Run Program > Run this program when torrent finishes: C:\Development\Scripts\utorrent\torrentscript.bat "%D" "%N" "%L" "%K" "%F" >> C:\Development\Scripts\utorrent\torrentlog.txtI've made the sub label parsing more robust for different length labels. I don't currently do much with the suffix but it's there if you need it.I also copy over the subs folder manually and the nfo file as too many downloads annoyingly didn't have the nfo in the rar, I also do some post processing to update my plex media server (if you're not using it then why not?!?!) I do nearly all my downloading using newsgroups with sickbeard, couchpotato and SABnzbd. These uTorrent scripts are just for problem episodes or movies, MMA, training and software. To update Plex I use wget which is part of GNUwin http://gnuwin32.sourceforge.net/packages/wget.htm This can all be deleted if you do not require it.This is not perfect, there is code that I don't really make use of currently but it's there as I will be changing in the future. There's certainly bits that could be cleaner so expect to get a little dirty. Obviously you'll need to update the script with your locations. Most of the variables are up top in the "Set Variables" section, please change to your requirements. @echo offtitle Jamie's torrent-file scriptrem Based on: http://forum.utorrent.com/viewtopic.php?id=110024rem Parameter usage: fromdir torrent-name label kind [filename]rem corresponds to uTorrents flags: %D %N %L %K %F echo *********************************************echo Run on %date% at %time%set fromdir=%1set name=%2set label=%3set kind=%4set filename=%5set savepartition=F:\Mediaset gamesavedir=C:\Users\Jamie\Downloads\Completedset sickbeardscript="C:\Development\Scripts\utorrent\autoProcessTV\sabToSickBeard.py"set wget="C:\Program Files\GnuWin32\bin\wget.exe"set winrar="c:\program files\winrar\winrar.exe"set torrentlog=C:\Development\Scripts\utorrent\torrentlog.txtset handledlog=C:\Development\Scripts\utorrent\handled_torrents.txtset sickbeardlog=C:\Development\Scripts\utorrent\SickbeardLog.txtset errorlog=C:\Development\Scripts\utorrent\ErrorLog.txtset label_prefix=""echo Input: %fromdir% %name% %label% %kind% %filename%rem Check if the label has a sub label by searching for \if x%label:\=%==x%label% goto skipsublabelrem Has a sub label so split into prefix and suffix so we can process properly laterecho sub labelfor /f "tokens=1,2 delims=\ " %%a in ("%label%") do set label_prefix=%%a&set label_suffix=%%brem add the removed quote markset label_prefix=%label_prefix%"set label_suffix="%label_suffix%echo.prefix : %label_prefix%echo.suffix : %label_suffix%goto:startprocess:skipsublabelecho Skipped Sub Labelgoto:startprocess:startprocessecho %date% at %time%: Handling %label% torrent %name% >> %handledlog%rem Process the labelif %label%=="Movies" goto knownif %label%=="AV" goto knownif %label%=="MMA" goto knownif %label%=="Software" goto knownif %label%=="UNPACK" goto knownif %label_prefix%=="Training" goto knownif %label%=="Games" goto otherif %label%=="TV" goto TVrem Last resortrem Double underscores so the folders are easier to spot (listed on top in explorer)echo Last Resortset todir=%savepartition%\Unsorted\__%name%if %kind%=="single" goto copyfileif %kind%=="multi" goto copyallGOTO:EOF:knownecho **Known Download Type - %label%set todir=%savepartition%\%label%\%name%echo todir = %todir%GOTO:process:otherrem Handle downloads that aren't going into my main save directoryrem add as requiredecho **Other Download Type - %label%if %label%==Games set todir=%gamesavedir%\%name%echo todir = %todir%GOTO:process:TVecho **Known Download Type - %label%REM as it's TV I need to keep the directory name to give sickbeard the best chance of successfully processingREM Strip out the last part of directory name and use it to create the todir namefor /D %%i in (%fromdir%) do set todir=%savepartition%\Unsorted\%%~ni%%~xiecho todir = %todir%GOTO:process:processrem If there are rar files in the folder, extract them.rem If there are mkvs, copy them. Check for rars first in case there is a sample.mkv, then we want the rarsif %kind%=="single" goto copyfileif exist %fromdir%\*.rar goto extractrarif exist %fromdir%\*.mkv goto copymkvsif %kind%=="multi" goto copyallecho Guess we didnt find anythingGOTO:EOF:copyallecho **Type unidentified so copying allecho Copy all contents of %fromdir% to %todir%xcopy %fromdir%\*.* %todir% /S /I /YGOTO:POSTPROCESSING:copyfilerem Copies single file from fromdir to todirecho Single file so just copyingecho Copy %filename% from %fromdir% to %todir%xcopy %fromdir%\%filename% %todir%\ /S /YGOTO:POSTPROCESSING:copymkvsecho Copy all mkvs from %fromdir% and subdirs to %todir%xcopy %fromdir%\*.mkv %todir% /S /I /YGOTO:POSTPROCESSING:extractrarecho Extracts all rars in %fromdir% to %todir%. rem Requires WinRar installed to c:\Program filesif not exist %todir% mkdir %todir%IF EXIST %fromdir%\subs xcopy %fromdir%\subs %todir% /S /I /YIF EXIST %fromdir%\subtitles xcopy %fromdir%\subtitles %todir% /S /I /Ycall %winrar% x %fromdir%\*.rar *.* %todir% -IBCK -ilog"%todir%\RarErrors.log"IF EXIST %fromdir%\*.nfo xcopy %fromdir%\*.nfo %todir% /S /I /YGOTO:POSTPROCESSING:POSTPROCESSINGrem If the file is media Then update Plex. rem Not used for other file types at this point but it might be expandedrem update the plex section. For more info see http://wiki.plexapp.com/index.php/PlexNine_AdvancedInfo#Terminal_Commandsif %label%=="MMA" call %wget% -O NUL http://localhost:32400/library/sections/11/refresh?deep=1if %label%=="Movies" call %wget% -O NUL http://localhost:32400/library/sections/3/refresh?deep=1if %label%=="TV" GOTO:tvpostprocessingGOTO:EOF:tvpostprocessingechoecho ****************BEGIN SICKBEARD PROCESSING >> %sickbeardlog%echo %date% at %time%: Handling %name% from %todir% >> %sickbeardlog%call python %sickbeardscript% %todir% >> %sickbeardlog%REM Check the sickbeard log for errorsREM Count the number of lines so we can show just the last line in the main logfor /f "tokens=3" %%i in ('find /v /c "Wont@findthisin#anyfile" %sickbeardlog%') do set countoflines=%%iset /a countoflines=countoflines-1echo Sickbeard processing result:echo | more +%countoflines% < %sickbeardlog%REM Check the last line again to check resultSET sbresult=SUCCEEDEDecho | more +%countoflines% < %sickbeardlog% | FIND "Processing succeeded" > NULIF ERRORLEVEL 1 SET sbresult=FAILEDECHO Sickbeard processing %sbresult% REM The sickbeard processing failed so write to the error log and open the fileIF %sbresult%==FAILED ECHO %date% at %time%: Sickbeard processing %sbresult%. Handling %filename% from %todir%. Check the main logs >> %errorlog%IF %sbresult%==FAILED start notepad %errorlog%REM Update Plex TV sectioncall %wget% -O NUL http://localhost:32400/library/sections/10/refresh?deep=1GOTO:EOF
fazered Posted May 4, 2012 Report Posted May 4, 2012 also does anyone know how to run multiple scripts in utorrent at once? for instance one to rename the files using "therenamer" and then one to move them to my htpc?<<programming noobAs you can probably see from my code you use 'call' so:call C:\scripts\script.bat
fazered Posted May 4, 2012 Report Posted May 4, 2012 Idiot. I posted up the wrong version. I have updated the code.
TheNextBillGates Posted May 7, 2012 Report Posted May 7, 2012 HI, I'm working on a program to handle downloads in uTorrentThe program will be maintained here http://code.google.com/p/utorrent-sorter/Some features I plan on implementing are:automatic sorting of files into appropriate directories for my media servers // Currently working though limitedautomatic deletion of torrents after seeding automatic deletion of torrents that fail to downloadPlease give me some more Ideas of common tasks or features that would be cool
fazered Posted May 9, 2012 Report Posted May 9, 2012 I made loads of changes so I've updated the code. Mainly to the Sickbeard processing.
fazered Posted May 9, 2012 Report Posted May 9, 2012 HI, Some features I want are:Checksums to verify itegrityTrigger anti-virus scanautomatic sorting of files into appropriate directories for my media serversautomatic deletion of torrents after seeding //plan on using uTorrent to seed to a ratio and then deleting //torrent when %S == 11(finished)automatic deletion of torrents that fail to downloadI'm not really your man for this but I do have to say that many of your goals are already reached with uTorrent out of the box. Checksums are part of the bitorrent protocol. Your anti-virus should be checking all downloads as standard. For the rest you can use this work as a basis for deleting the torrents. http://forum.utorrent.com/viewtopic.php?pid=659028 I'm sure you can work out the sorting from the scripts above. Good luck
TheNextBillGates Posted May 9, 2012 Report Posted May 9, 2012 Yes I did realize that uTorrent was checking the checksums and that my anti-virus is checking the files as they are downloading but like I said its a project to hone my skills and just sorting the torrents and deleting them would be too easy.Thanks for the link to the vbs code though.
rudewest Posted May 18, 2012 Report Posted May 18, 2012 Thanks a lot for the posts !!! .. Modified to sort by trackerecho *********************************************echo Run on %date% at %time%set fromdir=%1set name=%2set tracker=%3set savepartition=D:set moviedir=%savepartition%\BTecho Input: %fromdir% %name% %tracker%echo %date% at %time%: Handling torrent %name% >> handled_torrents.txtrem trimming the tracker informationset tracker_prefix=%tracker:~1,12%echo %tracker_prefix%rem If Tracker contains "http://tamil"if "%tracker_prefix%"=="http://tamil" goto moviesecho SorryGOTO:EOF:moviesecho **Movieset todir=%moviedir%\%name%echo todir = %todir%xcopy %fromdir%\*.* %todir% /S /IGOTO:EOF
kuzama Posted June 2, 2012 Report Posted June 2, 2012 I'm a noob.. well not toally a noob but damned if I don't feel like one right now. Having major issue getting a bat to run after the state changes. I've seen a lot on this but no straight up defininitive answers unless i'm that clueless.. My bat runs fine if I drop it in the created directory and run it. If it's called on I see it triggering but I get file not found. Any help would be greatly appreciated. (probably save a brother from pulling out what's left of his hair too).
TheNextBillGates Posted June 2, 2012 Report Posted June 2, 2012 . My bat runs fine if I drop it in the created directory and run it. If it's called on I see it triggering but I get file not found.Have you checked to see that you are forming a valid absolute pathname inside of you .bat?
snic Posted June 23, 2012 Report Posted June 23, 2012 I would love to be able to move files to specific directories after they finish downloading, based on the tracker. I usually have three categories; movies, music, and tv-shows. Is there anyway i can accomplish this using a script? Or even a better option will be first to label them based on the tracker, then move them to directories.
ZaPHoN Posted August 23, 2012 Report Posted August 23, 2012 Is there any way to do this with utorrent in linux?
Lynkz83 Posted September 14, 2012 Report Posted September 14, 2012 hate to resurrect old thread but im curious about this script, attempted using it and modifying it, but when it comes to downloading a torrent that has more than one subdirectory such as a 2CD or a boxset such as a season it just copies over the files but does not extract the rar files, and im not entirely sure how to actually get it working pastebin link to scripthttp://pastebin.com/QpG64vdh
Spartakus Posted September 26, 2012 Report Posted September 26, 2012 I use a seedbox, so I want to start a FTP script that automatically upload a finished torrent back to my home server. I have found an excellent client named "lftp" for this purpose as it allows parallel upload and recursive functionality. Script supports both multi and single file torrents. This script assumes you have a label set, you might have errors without it.Command in µTorrent: C:\Utils\Scripts\ftp.vbs %K "%D" "%N" %L "%F"Script:'save as ftp.vbsDim path,label,cmd,nm,file,tp,host,user,pass,dir,drive,login,lftp,wd, contexthost = "myHostOrIP"user = "myUsername"pass = "myPassword"login = user & ":" & pass & "@" & hostlftp = "C:\Utils\lftp\lftp.exe"wd = "C:\"tp = WScript.Arguments.Item(0) 'single/multidir = WScript.Arguments.Item(1)drive = LCase(Mid(dir, 1, 1))path = "/cygdrive/" & drive & Right(dir,Len(dir)-2)path = Replace(Replace(path,"\","/")," ","\ ")nm = Replace(Replace(WScript.Arguments.Item(2),"\","/")," ","\ ")file = path & "/" & Replace(Replace(WScript.Arguments.Item(4),"\","/")," ","\ ")label = WScript.Arguments.Item(3)If tp = "single" Thencontext = "cd /" & label & "; put " & fileElse'multifilecontext = "mirror -R -v --parallel=3 --depth-first " & path & " /" & label & "/" & nmEnd Ifcmd = "ftp://" & login & " -e " & chr(34) & "set ftp:nop-interval 1; set net:timeout 5; "& context & "; quit" & chr(34)Set objShell = CreateObject("Shell.Application")objShell.ShellExecute lftp, cmd, wd, "runas", 1Set objShell = Nothing
moad Posted October 16, 2012 Report Posted October 16, 2012 Firstly, thanks for the script! I have modified it slightly to work for me, I have no idea how the label part works unfortunately. The rest of it is pretty straight forward, I wish I could work it out because I'd like to do the same with music as what is being done with shows. ie rather than shows\showname\season. I would like music\artist\album, not a big deal I do a bit of manual work with music anyway.I also send myself an email once a torrent is finished seeding so that I know to remove it from utorrent (working on automating this) using stunnel and blat. It works well.Emailing from cmd line - http://phonefullofbooks.wordpress.com/2011/10/07/adding-e-mail-notification-to-utorrent-when-a-download-finishes/I also run utorrent on my xbmc and when the scripts would run it would make the cmd line window active, to get around this you invoke the command line from a vbs script. Just grab the script from the following thread and then where you have specified the scripts in utorrent just refer to the vbs first. You will see what I mean.http://filebot.sourceforge.net/forums/viewtopic.php?t=215&p=1561Thanks again!
Cubefreak Posted October 17, 2012 Report Posted October 17, 2012 Emailing from cmd line - http://phonefullofbooks.wordpress.com/2011/10/07/adding-e-mail-notification-to-utorrent-when-a-download-finishes/I recently wrote a powershell script that also sends me an e-mail when a torrent is finished. For those who are interested, I'll share it .First, I created a file named TorrentFinished.html with tags like !Title!, that can later be replaced by the script. You can create it yourself, to make it look the way you like, or you can use this HTML code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">table.gridtable { font-family: verdana,arial,sans-serif; font-size:11px; color:#333333; border-width: 0px; border-color: green; border-collapse: collapse;}table.gridtable th { border-width: 0x; padding: 8px; border-style: solid; border-color: green; background-color: green; align: left;}table.gridtable td { border-width: 0px; padding: 8px; border-style: solid; border-color: white; background-color: #ffffff;}</style></head><body bgcolor="black"><table class="gridtable"><colgroup><col/><col/></colgroup><tr><th align="left">Variable</th><th align="left">Value</th></tr><tr><td>Title:</td><td>!Title!</td></tr><tr><td>Directory:</td><td>!Dir!</td></tr><tr><td>Filename:</td><td>!Name!</td></tr><tr><td>PreviousState:</td><td>!PreviousState!</td></tr><tr><td>Label:</td><td>!Label!</td></tr><tr><td>Tracker:</td><td>!Tracker!</td></tr><tr><td>Status message:</td><td>!StatusMessage!</td></tr><tr><td>Hex encoded info-hash:</td><td>!HexInfoHash!</td></tr><tr><td>State:</td><td>!State!</td></tr><tr><td>Kind of torrent:</td><td>!Kind!</td></tr></table></body></html>Then, I created a script named TorrentFinished.ps1. I only tested this with Gmail. If you want to use it, you'll have to change 'username' into whatever your username is. Same goes for 'password'. If you don't use Gmail, you'd also have change the "smtp.gmail.com", and probably the port (check here). You also need to adjust the path to TorrentFinished.html. The code:Param( [alias("f")] $Name, [alias("d")] $Dir, [alias("n")] $Title, [alias("p")] $PreviousState, [alias("l")] $Label, [alias("t")] $Tracker, [alias("m")] $StatusMessage, [alias("i")] $HexInfoHash, [alias("s")] $State, [alias("k")] $Kind)$EmailFrom = “username@gmail.com”$EmailTo = “username@gmail.com”$Pass = "mypassword"$Subject = “Torrent Finished Downloading!”$EmailMessage = New-Object System.Net.Mail.MailMessage( $emailFrom , $emailTo )$emailMessage.Subject = "Torrent Finished Downloading!"$emailMessage.IsBodyHtml = $true$emailMessage.Body = get-content "C:\Scripts\TorrentFinished.html"$emailMessage.Body = $emailMessage.Body -replace "!Title!", $Title$emailMessage.Body = $emailMessage.Body -replace "!Dir!", $Dir$emailMessage.Body = $emailMessage.Body -replace "!Name!", $Name$emailMessage.Body = $emailMessage.Body -replace "!PreviousState!", $PreviousState$emailMessage.Body = $emailMessage.Body -replace "!Label!", $Label$emailMessage.Body = $emailMessage.Body -replace "!Tracker!", $Tracker$emailMessage.Body = $emailMessage.Body -replace "!StatusMessage!", $StatusMessage$emailMessage.Body = $emailMessage.Body -replace "!HexInfoHash!", $HexInfoHash$emailMessage.Body = $emailMessage.Body -replace "!State!", $State$emailMessage.Body = $emailMessage.Body -replace "!Kind!", $Kind$SMTPServer = “smtp.gmail.com”$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)$SMTPClient.EnableSsl = $true$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“username”, $Pass);$SMTPClient.Send($emailMessage)In the "Run this program when a torrent finishes:", I put the following command (replace "D:\Scripts\TorrentFinished.ps1" with the correct path.C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy unrestricted -file "D:\Scripts\TorrentFinished.ps1" -Name "%F" -Dir "%D" -Title "%N" -PreviousState "%P" -Label "%L" -Tracker "%T" -StatusMessage "%M" -HexInfoHash "%I" -State "%S" -Kind "%K"I also have an app called 'Tasker' on my Android, that allows me to play a custom sound based on the subject of an e-mail .Hopefully someone finds this useful.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.