• 1(current)
  • 2
  • 3
  • 4
  • 5
  • 8
Win HOW-TO get uTorrent to tell XBMC to update its library
#1
Thumbs Up 
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.
Download uTorrent

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
  4. It downloads the files to d:\incoming
  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
Reply
#2
1. Enable the http-server in XBMC
Image Image

2. Change settings in uTorrent
Image

Image Image
  • 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
Reply
#3
3. Add Feed
Image Image

4. Add Keywords to the autodownloader in uTorrent
Image Image

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:password@ip:port/jsonrpc?request="

'examples
'xbmcConnection = "http://xbmc:xbmc@localhost: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
Reply
#4
@watzen - Thanks for that. Now I can turn off the auto-update add-on and get real-time library updates.
-stoli-
Reply
#5
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
Reply
#6
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 Wink
Reply
#7
Nice one!
Too bad it doesn't work for me. I'm running uTorrent at the same pc as I run XBMC.
uTorrent downloads the shows to C:\Downloads\Series\[name] automatically. Their labels are Series\[name].

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

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?
Reply
#8
GorillaHuman Wrote:Nice one!
Too bad it doesn't work for me. I'm running uTorrent at the same pc as I run XBMC.
uTorrent downloads the shows to C:\Downloads\Series\[name] automatically. Their labels are Series\[name].

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

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?

I think you need to change the sourcePath to "C:\Downloads\"
(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
Reply
#9
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 Wink

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

Wink
  • 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
Reply
#10
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
Reply
#11
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
Reply
#12
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.
Reply
#13
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

My RSS-feed downloads to e:\nedladdat\tv-serier\

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!
Reply
#14
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

My RSS-feed downloads to e:\nedladdat\tv-serier\

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
Reply
#15
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 Eek)

It says

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

Code: 800C0005
Source: msxml3.dll

What's that about?

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!
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 8

Logout Mark Read Team Forum Stats Members Help
HOW-TO get uTorrent to tell XBMC to update its library1