• 1(current)
• 2
• 3
• 4
• 5
• 8
• Next

• 1 Vote(s) - 5 Average
Windows - HOW-TO get uTorrent to tell XBMC to update its library

Hi I just set up the new version of uTorrent (2.2) that has the ability to always run a program when it has finished downloading a torrent. This feature is able to pass on the user set label that the torrent has.

So the automatic setup works like this:
1. uTorrent watches a RSS-feed with torrents
2. It downloads and starts the torrents that I have selected through filters
3. I have set a label for each filter so that torrents that match my Bones-filter gets a "TV-shows/Bones"-label
5. When it has completed the download it moves the files to d:\ and appends the label to the path as well. so if it is a bones episode it will put it in d:\TV-shows\Bones
6. After completion it also calls the above vbs-file with Update.vbs "%L". The %L passes the label of the completed torrent.
7. XBMC executes the command and checks if there are any new files in the specified folder.
• Livingroom - C2D E8400, P5N7A-VM on a Samsung 46" LE46M86 FullHD via HDMI
• Kitchen - ASRock 330 HT Displayed on a Samsung Lapfit 22" dual touch screen LD220Z
• Bedroom - LG Laptop on a 32" tv
1. Enable the http-server in XBMC

2. Change settings in uTorrent

• Livingroom - C2D E8400, P5N7A-VM on a Samsung 46" LE46M86 FullHD via HDMI
• Kitchen - ASRock 330 HT Displayed on a Samsung Lapfit 22" dual touch screen LD220Z
• Bedroom - LG Laptop on a 32" tv

5. Create the script
Open up notepad and paste the code posted below
Code:
Dim objSvrHTTP Dim connectionString Dim JSONstring Dim xbmcConnection Dim sourcePath Dim message Dim header Dim myPath Set objSvrHTTP = CreateObject("MSXML2.XMLHTTP") On Error Resume Next '================================================================================= 'edit this line to work with your setup xbmcConnection = "http://user:[email protected]:port/jsonrpc?request=" 'examples 'xbmcConnection = "http://xbmc:[email protected]:8080/jsonrpc?request=" 'xbmcConnection = "http://xbmc:[email protected]:80/jsonrpc?request=" 'set this parameter to your main sourcepath.  "c:\path\to\main\folder\" for when you have local sources and "smb://computer/path/to/main/folder/" when you have network sources sourcePath = "YOUR/PATH/TO/SOURCE/" 'examples 'sourcePath = "c:\downloaded\" 'sourcePath = "smb://HTPC/" '================================================================================= 'if the first argument is -U (for update) then it performs the update procedure and sends a notification to xbmc. if WScript.Arguments.Item(0) = "-U" then     'Send a command to xbmc to display a notification when a torrent finishes         JSONstring = URLEncode(Replace("{''jsonrpc'':''2.0'',''method'':''GUI.ShowNotification'',''params'':{''title'':''uTorrent'',''message'':''Finished downloading " & WScript.Arguments.Item(1) & "''},''id'':1}","''",Chr(34)))     connectionString =  xbmcConnection & JSONstring     objSvrHTTP.open "GET", connectionString, False     objSvrHTTP.send          'Send a command to xbmc that tells it to update the supplied directory     JSONstring = URLEncode(Replace("{''jsonrpc'':''2.0'',''method'':''VideoLibrary.Scan'',''params'':{''directory'':''"& sourcePath & WScript.Arguments.Item(2) &"/''},''id'':1}","''",Chr(34)))     connectionString =  xbmcConnection & JSONstring     WScript.Sleep 1000 * 10     objSvrHTTP.open "GET", connectionString, False     objSvrHTTP.send          'if the first argument is -S (for status) then it performs the status procedure and in this case only when the status is "Queued". 'That way I get a notification in xbmc when a new torrent is added elseif WScript.Arguments.Item(0) = "-S" then     'check if the status is Queued     if WScript.Arguments.Item(1) = "Queued" then         header = WScript.Arguments.Item(1)         message = WScript.Arguments.Item(2)         JSONstring = URLEncode(Replace("{''jsonrpc'':''2.0'',''method'':''GUI.ShowNotification'',''params'':{''title'':''uTorrent'',''message'':''Queued: " & message & "''},''id'':1}","''",Chr(34)))         objSvrHTTP.open "GET", connectionString, False         objSvrHTTP.send     end if end if Function URLEncode(ByVal str) Dim strTemp, strChar Dim intPos, intASCII strTemp = "" strChar = "" For intPos = 1 To Len(str)   intASCII = Asc(Mid(str, intPos, 1))   If intASCII = 32 Then    strTemp = strTemp & "+"   ElseIf ((intASCII < 123) And (intASCII > 96)) Then    strTemp = strTemp & Chr(intASCII)   ElseIf ((intASCII < 91) And (intASCII > 64)) Then    strTemp = strTemp & Chr(intASCII)   ElseIf ((intASCII < 58) And (intASCII > 47)) Then    strTemp = strTemp & Chr(intASCII)   Else    strChar = Trim(Hex(intASCII))    If intASCII < 16 Then     strTemp = strTemp & "%0" & strChar    Else     strTemp = strTemp & "%" & strChar    End If   End If Next URLEncode = strTemp End Function
Edit the two marked lines and save the file as C:\update\update.vbs (if that is the path you wrote in utorrent settings)

6. Let the magic do its thing
• Livingroom - C2D E8400, P5N7A-VM on a Samsung 46" LE46M86 FullHD via HDMI
• Kitchen - ASRock 330 HT Displayed on a Samsung Lapfit 22" dual touch screen LD220Z
• Bedroom - LG Laptop on a 32" tv
@watzen - Thanks for that. Now I can turn off the auto-update add-on and get real-time library updates.
-stoli-
Ok, so I have updated the script with the ability to send notifications as well. When the script gets one argument it sends it as an update library command and when it receives two arguments it sends those as header and message

Just put c:\update\update.vbs "uTorrent - %M" "%N" in the "Run this program when a torrent changes state" box in uTorrent preferences.
(this is only neccesary if you want notifications in XBMC for each time a torrent changes state, and they change state a lot. So this is not so useful)
• Livingroom - C2D E8400, P5N7A-VM on a Samsung 46" LE46M86 FullHD via HDMI
• Kitchen - ASRock 330 HT Displayed on a Samsung Lapfit 22" dual touch screen LD220Z
• Bedroom - LG Laptop on a 32" tv
Hmm. I wonder how to do this from Linux or from a NAS... since my torrents are downloading straight to my NAS using the embedded client
Nice one!
Too bad it doesn't work for me. I'm running uTorrent at the same pc as I run XBMC.

xbmcConnection = "http://user:[email protected]:80" (user/pass match XBMC)

When I type in cmd the following (to emulate uTorrent)
Code:
Update.vbs "Series\[name]"
XBMC just flashes "compressing database" and doesn't update.
What am I doing wrong?
GorillaHuman Wrote:Nice one!
Too bad it doesn't work for me. I'm running uTorrent at the same pc as I run XBMC.

xbmcConnection = "http://user:[email protected]:80" (user/pass match XBMC)

When I type in cmd the following (to emulate uTorrent)
Code:
Update.vbs "Series\[name]"
XBMC just flashes "compressing database" and doesn't update.
What am I doing wrong?

(note the trailing slash)
• Livingroom - C2D E8400, P5N7A-VM on a Samsung 46" LE46M86 FullHD via HDMI
• Kitchen - ASRock 330 HT Displayed on a Samsung Lapfit 22" dual touch screen LD220Z
• Bedroom - LG Laptop on a 32" tv
bmcclure937 Wrote:Hmm. I wonder how to do this from Linux or from a NAS... since my torrents are downloading straight to my NAS using the embedded client

yeah, well, get your software to GET this url when finished:
Code:
http://user:[email protected]:port/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video,pathwhereyourfilesare))

• Livingroom - C2D E8400, P5N7A-VM on a Samsung 46" LE46M86 FullHD via HDMI
• Kitchen - ASRock 330 HT Displayed on a Samsung Lapfit 22" dual touch screen LD220Z
• Bedroom - LG Laptop on a 32" tv
Or you can just use Sickbeard to update your XBMC library by having utorrent move completed files to the directory that Sickbeard processes it's downloads from. As long as the show is listed as a Sickbeard show, the files should be processed. I believe this works the same way with Couchpotato.

Mark
mwkurt Wrote:Or you can just use Sickbeard to update your XBMC library by having utorrent move completed files to the directory that Sickbeard processes it's downloads from. As long as the show is listed as a Sickbeard show, the files should be processed. I believe this works the same way with Couchpotato.

Mark

I for one think that XBMC does a very good job in recognizing my downloads. So I rather skip any extra software that needs to process my files/manage them. Since if any extra processing occurs after uTorrent is finished (changing filenames, moving or whatever), I would not be able to seed anymore.
• Livingroom - C2D E8400, P5N7A-VM on a Samsung 46" LE46M86 FullHD via HDMI
• Kitchen - ASRock 330 HT Displayed on a Samsung Lapfit 22" dual touch screen LD220Z
• Bedroom - LG Laptop on a 32" tv
I totally agree. There is no reason at all to use Sickbeard if you get your series/movies via Torrents since you will still be using uTorrent and it has the RSS downloader, Labels feature and now "run program..." features.
Sickbeard is only useful if you use newsgroups/usenet.
This looks awesome but i I have a few questions.

1: How to I test if it's working without having to wait for a torrent to finish?

My folders are setup like this

Utorrent moves the completed downloads to e:\ and append the label which will be

Tv-Serier/Fringe
or
Tv-Serier\Fringe

?

And is this the correct sourcepath?

sourcePath = "E:\"

Cheers!
e2zippo Wrote:This looks awesome but i I have a few questions.

1: How to I test if it's working without having to wait for a torrent to finish?

open up a command window, run->cmd->enter. then navigate to the folder where the script is in. then type "nameofscript.vbs Tv-Serier\Fringe" (without quotes). Switch over to xbmc and it should scan that folder after 10 seconds.

Quote:
My folders are setup like this

Utorrent moves the completed downloads to e:\ and append the label which will be

Tv-Serier/Fringe
or
Tv-Serier\Fringe

?

And is this the correct sourcepath?

sourcePath = "E:\"

Cheers!

since I run a centralized mySQL solution, I have added all my local sources as SMB sources. that requires me to use "/"'s in my path. but if you are using local sources then you should use "\"''s. So the second one should be the correct one.
And the sourcepath should be as you wrote.
• Livingroom - C2D E8400, P5N7A-VM on a Samsung 46" LE46M86 FullHD via HDMI
• Kitchen - ASRock 330 HT Displayed on a Samsung Lapfit 22" dual touch screen LD220Z
• Bedroom - LG Laptop on a 32" tv
watzen Wrote:open up a command window, run->cmd->enter. then navigate to the folder where the script is in. then type "nameofscript.vbs Tv-Serier\Fringe" (without quotes). Switch over to xbmc and it should scan that folder after 10 seconds.

since I run a centralized mySQL solution, I have added all my local sources as SMB sources. that requires me to use "/"'s in my path. but if you are using local sources then you should use "\"''s. So the second one should be the correct one.
And the sourcepath should be as you wrote.

The scan seems to be working, yay!

But i just discovered something not so great, when i pause and/or resume my torrents in uTorrent i get "Windows Script Host" error window for each and every torrent that is in uTorrent right now (about 70 now )

It says

Script: D:\Appz\update.vbs
Line: 27
Char: 1
Error: The system cannot locate the resource specified

Code: 800C0005
Source: msxml3.dll

And one final question, will the seeding work with this procedure?

Before this i used the perl script also found on this forum and while it worked great, the moving of the files made it so they couldn't be seeded (unless i re-locate them, and that would be a real hassle for every torrent)

Cheers!
• 1(current)
• 2
• 3
• 4
• 5
• 8
• Next