Jump to content

Improve "run this program when download finishes" feature


alextorex

Recommended Posts

  • Replies 97
  • Created
  • Last Reply

Here is how I did it:

Created a test.cmd

@echo off

echo D:%1 N:%2 S:%3 L:%4 T:%5 M:%6 I:%7

pause

Add this line to both fields in µTorrent:

C:\test.cmd "%D" "%N" "%S" "%L" %T "%M" %I

As Firon previously stated, this function is for power users and a power user should be able to retrieve this info by themselves. I did.

Link to comment
Share on other sites

  • 2 weeks later...

Hey, great feature, thanks for putting it in. I'm having problems with it triggering though. I have the following on state change...

X:\scru\batch.bat %S "%D"

batch.bat contains...

@echo off
IF (%1)==(5) (
X:\scru\scru.exe %2 *
) ELSE (
echo nothing
)

now this all works, except the batch file doesn't get triggered unless I go, stop + start... so if the RSS filter matches a torrent, downloads it, it completes, changes state to seeding, but utorrent doesn't run the batch file. Guess what I'm saying is, its not recognising there is a change of state when it finishes a download, goes to queue seeding then seeding. Hope that makes sense...

btw. SCRU is great, been using if for ages, thanks Spartacus.

Link to comment
Share on other sites

oh wow, as simple as that... completely eliminates the need for my batch file as well haha, I didn't realise Finished was triggered at the end of a download, thought it was only triggered when you hit stop on the torrent... now I have

X:\scru\scru "%D" *

on the finished trigger and it works a treat, thanks heaps!

Link to comment
Share on other sites

  • 3 weeks later...

Using 2.2 build 22538.

When a torrent finishes Downloading and switches state to Seeding, should it fire the "Run this program when a torrent finishes" box then or only when it's completed the required seeding goal when the status will actually change to Finished.

I understand that by using the "changes state" box and clicking Stop on a torrent will cause it to fire, but it also fires on any other state change and I only need/want to fire my batch file when the torrent hits 100% downloaded as random command windows opening and closing is rather annoying if you're using the computer at the time.

Link to comment
Share on other sites

Using 2.2 build 22538.

When a torrent finishes Downloading and switches state to Seeding, should it fire the "Run this program when a torrent finishes" box then or only when it's completed the required seeding goal when the status will actually change to Finished.

I understand that by using the "changes state" box and clicking Stop on a torrent will cause it to fire, but it also fires on any other state change and I only need/want to fire my batch file when the torrent hits 100% downloaded as random command windows opening and closing is rather annoying if you're using the computer at the time.

When a torrent reaches 100% it goes from downloading -> finished -> seeding. So the Run on Finished command does go through when download reaches 100%.

Link to comment
Share on other sites

Thanks for adding this feature guys, been wanting it for a while now.

With the iphone and Apple TV it really is a must have.

If you are a fan of Handbreak (http://sourceforge.net/projects/handbrake/ ) really good open source video conversion tool

Little script to convert files to Apple TV format:

"C:\Program Files\Handbrake\HandBrakeCLI.exe" -i "%D\%F" -t 1 -c 1 -o "%D\%F.m4v" -f mp4 -4 -X 624 --loose-anamorphic -e x264 -q 20 -a 1,1 -E faac,ac3 -6 dpl2,auto -R 48,Auto -B 160,auto -D 0.0,0.0 -x cabac=0:ref=2:me=umh:b-adapt=2:weightb=0:trellis=0:weightp=0 -v 1

And iPhone 4 format:

"C:\Program Files\Handbrake\HandBrakeCLI.exe" -i "%D\%F" -t 1 -c 1 -o "%D\%F.m4v" -f mp4 -X 320 -l 240 -e x264 -q 20 -a 1 -E faac -6 dpl2 -R 48 -B 128 -D 0.0 -x cabac=0:ref=2:me=umh:bframes=0:subq=6:8x8dct=0:trellis=0:weightb=0 -v 1

Just replace the directory path for the handbreak exe if you have changed it. Works well for me. Thanks again, keep up the good work

Link to comment
Share on other sites

  • 4 months later...

I love the global "run program on torrent state change" feature. Thanks so much for adding it!

I have one small issue with it.

If I add a torrent and have the Start torrent option selected, I get two events: 12/Queued and 6/Downloading. This is exactly what I expect.

However, if I add a torrent and have the Start torrent option unselected, no events occur! I would have expected at least one event: 13/Stopped.

Could you please update this feature to fire an event when torrents are added as unstarted. Thanks!

Link to comment
Share on other sites

  • 6 months later...

hm would it be possible to somehow announce it on irc when torrent finishes?

perhaps in some combination with irc script + run program option.. it would be a nice feature

best would be a script for xchat since it support python, perl and other scripting languages, but any client should do..

Link to comment
Share on other sites

  • 3 months later...

Not sure if it's better I create my own thread but for the life of me I can't get utorrent to write to a text file. I just want a simple torrent log that shows a list of torrents that have been downloaded.

In uTorrent I have

C:\Users\mrcomputer\Documents\UtorrentLogs\log.bat %L %N

(Note: I've also tried combinations with and without quotes -- Are these necessary? Edit: Ok I see the point of the quotes they are necessary is the output is going to contain spaces)

Then in log.bat I have:

@echo off
echo %1\%2 >> uTorrentLog.txt

The program executes but the log file does not get written. I have tested this just using the run command:

C:\Users\mrcomputer\Documents\UtorrentLogs\log.bat Label TorrentName

And this works just fine. I'm not sure how else to do this. I'm guessing one of three things is happening:

1. I'm not using the right syntax in uTorrent

2. The variables are not being pushed to the bat file the way I would expect them to

3. uTorrent doesn't have permission to write to the directory

EDIT: Ok so I've tested this with just a simple bat file and that works:

@echo off
echo 1: %1 2: %2
pause

The CMD window pops up with the correct information. So what is the correct way to get this to write to a text file? I've tried running uTorrent as an administrator and that didn't work either. Is there another way?

EDIT2: Ok I have this working now. In the bat file I needed to provide the full path to the text file I wanted to log to.

Link to comment
Share on other sites

this one works for me:

cmd.exe /c d:\log.cmd %S %F

Make sure you give full absolute path to the output file

echo 1: %1 2: %2 >> d:\out.txt

Thanks. Yeah yours is a little simpler, but mine is working so I'll just keep it. The key thing I was missing was the absolute path to the output file, one I added that I was good to go.

Link to comment
Share on other sites

I also went one step further and created a python script I call at the end of the bat file to replace the quotations that get inserted.

Bat file: (log.bat)

@echo off
echo %date% %time% %1\%2 >> "C:\Users\mrcomputer\Documents\My Dropbox\Dropbox Torrents\uTorrentLog.txt"
python "C:\Users\mrcomputer\Documents\My Dropbox\Dropbox Torrents\clean.py"

Python script: (clean.py)

import fileinput
import sys

def replaceAll(file,searchExp,replaceExp):
for line in fileinput.input(file, inplace=1):
if searchExp in line:
line = line.replace(searchExp,replaceExp)
sys.stdout.write(line)

replaceAll("C:\Users\mrcomputer\Documents\My Dropbox\Dropbox Torrents\uTorrentLog.txt","\"","")

Sample uTorrentLog.txt output:


Sun 01/08/2012 23:07:41.46 Other\Magda Herzberger's Book Previews - Tales of the Magic Forest
Sun 01/08/2012 23:09:52.46 HD Movies\Magda Herzberger's Book Previews - If You Truly Love Me

Link to comment
Share on other sites

  • 2 months later...

I really hope somebody can help me as I am banging my head against the wall at the moment.

All I want to do is launch a script when a torrent is FINISHED (which is to say has downloaded and then seeded to the appropriate ratio). If I try and launch it from the "Run on Finished State" box the script doesn't run even if I just put notepad in there. It will only run from the "Run on Changes State" box.

The problem is UT goes into the FINISHED stage temporarily (too quick to see) between each stage e.g between Downloading and Seeding.

I thought right I'll use the Previous State of the torrent to check whether it was previously Seeding and therefore the Finished is correct or whether it was Downloading and in which case the Finished is incorrect and to exit the script.

NOPE. That didn't work because if the torrent is Seeding and then goes into Queued Seed we hit the temporary Finished stage again and triggers the previous state check which it now passes (incorrectly though).

Here is the beginning of the script:


set State=%1
set Kind=%2
set Directory=%3
set FileName=%4
set Title=%5
set Label=%6
set FilePath=%~7
set Previous=%8

IF %State%=="Finished" GOTO PREVCHECK
IF NOT %State%=="Finished" GOTO END

:PREVCHECK
IF %Previous%=="5" GOTO OTHER
IF %Previous%=="8" GOTO OTHER
IF NOT %Previous%=="5" GOTO END

I am at a loss with what to do. The launch on Finished doesnt appear to work and on change state is next to useless.

Can someone please please help me figure out how to get this working.

Thanks

Gaz

Link to comment
Share on other sites

  • 5 months later...

I'm looking to set up a batch script, but I have no idea how to Write batch scripts.

Here is what I want to do in "plain English"

If label=Movie set state to "Force Start" copy downloaded folder to d:\nedlastinger\ferdig\Rename after 30 days remove and delete .torrent

If label=Movies2 set state to "Force Start" then Remove and Delete .torrent

If %L==Movies %S==8 copy %D to d:\nedlastinger\ferdig\Rename

If %L==Movies2 %S==8

Am I anywhere close to what it should look like? If not what should it look like?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...