Hey Guys,
Hoping that people are still reading this thread. I've taken Watzen's method and modified it a little bit. I currently use the script to monitor state changes from uTorrent.
11 = finished (after seeding) and starts to run Therenamer to clean out my downloads folder and move tvshows & movies to the respective folders. After that, it sends a notification to XBMC and updates the library.
12 = Queued and sends a notification to XBMC similar to Watzen's.
Code:
Dim objSvrHTTP
Dim connectionString
Dim xbmcConnection
Dim message
Set objSvrHTTP = CreateObject("MSXML2.XMLHTTP")
'On Error Resume Next
xbmcConnection = "http://name:pass@localhost:8080"
'if the first argument is 11 (meaning utorrent state is finished) then it performs the update procedure and sends a notification to xbmc.
if WScript.Arguments.Item(0) = "11" Then
'Run therenamer to search for tv shows, *note:therenamer is set to look in downloads folder, rename tv shows and move to folder with same name*
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("""%ProgramFiles(x86)%\theRenamer\theRenamer.exe """ & "-fetch", 0, true)
Set wshshell = Nothing
'Run therenamer to search for movies *note:therenamer is set to look in downloads folder, rename movies and move to movie folder*
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("""%ProgramFiles(x86)%\theRenamer\theRenamer.exe """ & "-fetchmovie", 0, true)
Set wshshell = nothing
'Send a command to xbmc to display a notification when a torrent finishes
connectionString = xbmcConnection & "/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(Finished%20Downloading:," & Replace(WScript.Arguments.Item(1)," ","%20") & "))"
objSvrHTTP.open "GET", connectionString, False
objSvrHTTP.send
'Send a command to xbmc that tells it to update the supplied directory
connectionString = xbmcConnection & "/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video))"
WScript.Sleep 1000 * 10
objSvrHTTP.open "GET", connectionString, False
objSvrHTTP.send
'if the first argument is 12 (uTorrent state is queued) 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) = "12" then
'check if the status is Queued
message = Replace(WScript.Arguments.Item(1)," ","%20")
connectionString = xbmcConnection & "/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(Started%20Downloading:," & message & "))"
objSvrHTTP.open "GET", connectionString, False
objSvrHTTP.send
End If
My issue is that when the script executes Therenamer, I lose focus of XBMC (even in full screen) and it drops back to the desktop so i'm trying to figure out the correct code to have it run in the background and not affect XBMC.
I've got very weak coding skills but enough smarts to modify Watzen's with some copy and paste from other scripts I've found to come up with what I have so far.
I beleive that when I run WshShell the 0 after -fetch is supposed to tell it to stay hidden but obviously its not working.
Can someone help me out?
Thanks a lot,
-Tony