3. Add Feed
4. Add Keywords to the autodownloader in uTorrent
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:myownpass@192.168.1.101: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