uTorrent update XBMC on completion
#16
Fantastic! It works great now. This script is back working again, and I just got my new Harmony remote in the mail to replace the one that my daughter dropped in a glass of water. Things are really getting back to the way they should be with my HTPC.

Pilzbury, you have been a huge help.
Reply
#17
Hi,

For the greater part of this week I've been pulling the hair out of my head trying to get this to work. I can't figure out how to set it up correctly.

My setup is 2 XBMC instances with shared library via MySQL. 192.168.0.10 is the computer that's hosting the MySQL server (however, I figure it shouldn't really matter with instance actually initiates the update, since the library is synced between the 2 instances...?). The same computer is also running uTorrent. The other one is 192.168.0.11. The library sync via MySQL works fine in itself.

I don't get notification of torrents changing states or notification that they have completed and XBMC does not update.

See pastebin for how I have altered the vbs-file, http://pastebin.com/6hUwQunF

What I'm really looking for is just to update the XBMC-library when a torrent finishes regardless of labels etc... I also tried using the modified script that you made for moeman, but I couldn't get that to work either. I feel I have missed something fundamental...

I would be very grateful if you could take the time to help me out.
Reply
#18
Solved for lebaguette. Edited original post to reflect issue.
Reply
#19
Big up to Pillzbury for helping me out! Excellent support.
Reply
#20
I am not sure if it affects anyone else, but there was a missing end if command that kepting hanging up running the script.

Also, it gives status just fine,("Downloaded: American Dad") but does not update the library when doing so. However when I run the script without utorrent providing any information, is reads "Downloading: " Then updates the library. I think it has something about the labels not matching up. I will ahve to dig up a log to see. Any quick fixes?

Got it to work. I made the following changes to get it to work:
JSONstring = URLEncode(Replace("{''jsonrpc'':''2.0'',''method'':''VideoLibrary.Scan'',''id'':1}","''",Chr(34)))
Theater: The PS4/XBONE killer running Kodi 17.3 3D Movie Box: Raspberry Pi running LibreElec 8.0 Alpha BROKEN Family Room: "A6-Pack" running Kodi 17.3 Whole House: FireTV running Kodi 17.3
Reply
#21
Anyone have this working on Gotham 13.1? I had it working without Labels after some tinkering with the code on Frodo 12.3 but I lost my code due a HDD dying on me.

I don't know whether the web API has changed since Gotham or whether my new adapted code is completely wrong.

EDIT: My problem was with uTorrent 3.4.2 rather than XBMC and when I changed it and changed the code using the above fix from ragedogg69.


PHP Code:
'xbmc.vbs
'
Script for updating xbmc library upon torrent completion, and showing notification on download.
'Largly stolen and adapted from http://forum.xbmc.org/showthread.php?t=87472
'
'In uTorrent, Options > Preferences > Advanced > Run Program : Add the following
'
When a Torrent Finishes:  "C:\path\to\xbmc.vbs" -"%N" "%D"
'When a Torrent Changes State: "C:\path\to\xbmc.vbs" -S "%M" "%N"
'
'===============================================================================?==
'
Declaration section
Dim objSvrHTTP
Dim connectionString 
'string to send to xbmc
Dim xbmcConnection    '
xbmc connection detailsdefined in Settings Section
Dim message    
' contains name of torrent when sending status message to xbmc
Dim myPath ' 
path of download in utorrent as provided via %D.

Set objSvrHTTP CreateObject("MSXML2.XMLHTTP")

On Error Resume Next
'===============================================================================?==
'
Settings Section
'edit these lines to work with your setup
xbmcConnection = "http://xbmc:[email protected]:80/jsonrpc?request=" ' 
This connection is the one that will perform library updates.
'===============================================================================?===
'
Implementation Section

'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    
    myPath 
WScript.Arguments.Item(2)
    if 
Left(myPath,2) = "\\" then
            myPath 
Replace(myPath,"\\","smb://"'This line makes network paths friendly for xbmc
            myPath = Replace(myPath,"\","/") '
This line also makes network paths friendly for xbmc
        
ElseIf Mid(myPath,2,2) = ":\" then
            myPath = Replace(myPath,"
\","\\")
    End If
    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'',''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 "
Downloading". 
    '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 Downloading
        if WScript.Arguments.Item(1) = "
Downloading" then
               message = WScript.Arguments.Item(2)
               JSONstring = URLEncode(Replace("
{''jsonrpc'':''2.0'',''method'':''GUI.ShowNotification'',''params'':{''title'':''uTorrent'',''message'':''Downloading" & message & "''},''id'':1}","''",Chr(34)))
            connectionString = xbmcConnection & JSONstring
               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 
[/quote]
Reply

Logout Mark Read Team Forum Stats Members Help
uTorrent update XBMC on completion0