Windows - HOW-TO get uTorrent to tell XBMC to update its library

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
JamesUK Offline
Junior Member
Posts: 4
Joined: Mar 2011
Reputation: 0
Post: #61
watzen Wrote:The first line though, I only use the replace function because I have to urlencode it when sent to xbmc. ie "This Movie" becomes "This%20Movie"
You probably won't need that

Good point! But it seems to be breaking later than that - I suspect the path syntax is wrong, somewhere. It's a frustratingly easy batch file, but I want to keep the trick of only processing files with a particular label, which pushes me back to VBS...
find quote
JamesUK Offline
Junior Member
Posts: 4
Joined: Mar 2011
Reputation: 0
Post: #62
Ok - fixed now, after finding rather too late that text.txt.txt was breaking my trial script... Source and destination could be coded elsewhere, but if anyone else splits their torrent drive from an unstressed playback drive, this should do the trick and allow you to keep on seeding.

Code:
Dim Dest
Dim Source
Source = "C:\Torrents\Complete\" & WScript.Arguments.Item(2) & "\" & WScript.Arguments.Item(1)

Dest = "F:\TV Shows\" & WScript.Arguments.Item(2) & "\" & WScript.Arguments.Item(1)

Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile Source, Dest, OverwriteExisting
find quote
watzen Offline
Fan
Posts: 457
Joined: Jan 2007
Reputation: 10
Location: Sweden
Post: #63
JamesUK Wrote:Ok - fixed now, after finding rather too late that text.txt.txt was breaking my trial script... Source and destination could be coded elsewhere, but if anyone else splits their torrent drive from an unstressed playback drive, this should do the trick and allow you to keep on seeding.

Code:
Dim Dest
Dim Source
Source = "C:\Torrents\Complete\" & WScript.Arguments.Item(2) & "\" & WScript.Arguments.Item(1)

Dest = "F:\TV Shows\" & WScript.Arguments.Item(2) & "\" & WScript.Arguments.Item(1)

Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile Source, Dest, OverwriteExisting

I dont understand... I download the torrents to my c-drive and then i have set utorrent to move completed files to my d-drive. why don't you use the built in feature for it? is it that you dont want to seed from your d-drive?

  • 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
find quote
JamesUK Offline
Junior Member
Posts: 4
Joined: Mar 2011
Reputation: 0
Post: #64
watzen Wrote:I dont understand... I download the torrents to my c-drive and then i have set utorrent to move completed files to my d-drive. why don't you use the built in feature for it? is it that you dont want to seed from your d-drive?
Yup - I'd rather not split torrent activity across two drives - waste of electricity, and it lets me keep the main TV show drive as unstressed as possible with a couple of hours' activity a day, compared to the main drive that's running 24/7.
find quote
samzstein Offline
Senior Member
Posts: 112
Joined: Mar 2011
Reputation: 0
Post: #65
i have this working almost perfect, however when uTorrent saves a given file it places said file within its own directory within the show directory (ex. Entourage.S08E03.avi saves to h:\tv\entourage\entourage.s08E03\entourage.S08E03.avi) this stops xbmc from recognizing the episode automatically. i just want the individual file to save to the show directory. any help?
find quote
watzen Offline
Fan
Posts: 457
Joined: Jan 2007
Reputation: 10
Location: Sweden
Post: #66
XBMC should not have a problem looking for episodes in subdirectories from the show folder. In my setup they're saved in the same way as you describe and they get picked up by XBMC.

  • 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
find quote
Hybred Offline
Junior Member
Posts: 37
Joined: Apr 2011
Reputation: 0
Post: #67
So I'm not entirely sure how this works. Does it only add the single episode when the VBScript launches? I guess I don't really understand the point of labeling each episode. Ideally I'd just like XBMC to update everytime one of my torrents finish, this seems to be going a bit above that?
find quote
watzen Offline
Fan
Posts: 457
Joined: Jan 2007
Reputation: 10
Location: Sweden
Post: #68
The point of labeling each episode is so that they will get saved in their own show-folder. And furthermore what this vba-script does is that it tells xbmc to just look for new episodes in the folder that the episode was placed in. Which saves quite some time since a full scan of all movie/tv-show-folders takes quite a while.

  • 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
find quote
Hybred Offline
Junior Member
Posts: 37
Joined: Apr 2011
Reputation: 0
Post: #69
Allright that's what I felt like it was going for. Yeah I mean ideally it updating the whole library would be fine for what I need. My shows are already automatically sorted so I just need a complete library refresh. What would I need to edit out to make a working VBS that I could run to update the entire library everytime a torrent was completed?
find quote
funkytone Offline
Junior Member
Posts: 1
Joined: Nov 2011
Reputation: 0
Location: Vancouver
Post: #70
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
find quote
one800higgins Offline
Member
Posts: 95
Joined: Jan 2010
Reputation: 0
Post: #71
Does this method no longer work in the nightly builds?

I upgraded my HTPC recently and it involved moving uTorrent and hard drives to the HTPC instead of remotely connecting. I was on nightly builds before, but now that I've done a fresh install of XBMC and utorrent, this script no longer works.

What's odd is that I can log into the HTTP access and manually send an update through my browser, but when I try to do it from a VBS script I have no luck. I've even dumbed the file down to the following:

Code:
Dim objSvrHTTP
Dim connectionString
Dim xbmcConnection
Set objSvrHTTP = CreateObject("MSXML2.XMLHTTP")

'On Error Resume Next

xbmcConnection = "http://xbmc:xbmc@localhost:8080"

connectionString =  xbmcConnection & "/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video))"
WScript.Sleep 1000 * 10
objSvrHTTP.open "GET", connectionString, False
objSvrHTTP.send

Still nothing. It won't execute from VBS. Not even when double clicking the file and launching it without uTorrent.

Any ideas?
find quote
watzen Offline
Fan
Posts: 457
Joined: Jan 2007
Reputation: 10
Location: Sweden
Post: #72
one800higgins Wrote:Does this method no longer work in the nightly builds?

I upgraded my HTPC recently and it involved moving uTorrent and hard drives to the HTPC instead of remotely connecting. I was on nightly builds before, but now that I've done a fresh install of XBMC and utorrent, this script no longer works.

What's odd is that I can log into the HTTP access and manually send an update through my browser, but when I try to do it from a VBS script I have no luck. I've even dumbed the file down to the following:

Code:
Dim objSvrHTTP
Dim connectionString
Dim xbmcConnection
Set objSvrHTTP = CreateObject("MSXML2.XMLHTTP")

'On Error Resume Next

xbmcConnection = "http://xbmc:xbmc@localhost:8080"

connectionString =  xbmcConnection & "/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video))"
WScript.Sleep 1000 * 10
objSvrHTTP.open "GET", connectionString, False
objSvrHTTP.send

Still nothing. It won't execute from VBS. Not even when double clicking the file and launching it without uTorrent.

Any ideas?

try to insert a "msgbox connectionString" before the sleep so you'll get a notification of exactly what's going to be sent. Have a look at that and check if that string is correct.

  • 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
find quote
Roman_V_M Offline
Fan
Posts: 550
Joined: Jun 2011
Reputation: 14
Location: Kyiv, Ukraine
Post: #73
There is *nix wget CLI http download utility compiled for Windows. I think the following line
Code:
path_to\wget.exe -spider "http://localhost:port/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary(video)"
should do the trick. You can use a simple .cmd file. The -spider option tells wget not to download anything but just check the specified URL.

PS. I've checked this - it works.
(This post was last modified: 2011-11-25 21:40 by Roman_V_M.)
find quote
Hack_kid Offline
Fan
Posts: 646
Joined: Jan 2007
Reputation: 4
Post: #74
Hey as per the suggestion in the above post i checked out wget for windows. for some reason i couldnt get the --spider command to work i think there is a bug so i used a workaround by telling it to only download .pdf and there are none so it effectively does the same thing. just a workaround. but anyways i got it all set up here after installing wget to its default directory and using this batch script i made

Code:
@echo off
rem --------------------------------------------------
rem XBMC Auto Library Updater - uTorrent v2.0
rem --------------------------------------------------
rem Info: Replacement for watzens's old .vbs script
rem which stop working for god knows what reason, i
rem blame MS lol even though i have no evidence to do
rem so.
rem
rem Usage: Pretty similar to the old script minus a few
rem functions. Simply fill out at least one client and
rem your path to the source. you dont need to set MSG
rem if you do want to.
rem
rem Runtime Options. Set Clients and path below
rem ==================================================
rem
rem Set your clients.
SET CLIENT1="http://192.168.1.109:8080"
SET CLIENT2="http://192.168.1.130:8080"
SET CLIENT3="http://192.168.1.139:8080"
rem
rem Set your Source Path
SET SOURCE="/NFS_Share/750G_NewMovieShare/BluRay.x264/"
rem
rem Optional: Set a message to display to the user
rem Note: You have to represent spaces with a +
SET MSG="New+BluRay+Movies"
rem ===================================================
rem ---------------DO NOT EDIT BELOW THIS LINE---------
SET NOTIFYSTRING="/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(Auto+Media+Updater,%MSG%+being+added))​"
SET UPDATESTRING="/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video,%SOURCE%))"
echo -------------------------------------------
echo Begin Script.
echo -------------------------------------------
echo -------------------------------------------
echo Sending NotifyString to Client 1
echo -------------------------------------------
wget.exe -r -A.pdf "%CLIENT1%%NOTIFYSTRING%"
echo -------------------------------------------
echo Sleep 5 secs...
echo -------------------------------------------
sleep 5
echo -------------------------------------------
echo Sending UpdateString to Client 1
echo -------------------------------------------
wget.exe -r -A.pdf "%CLIENT1%%UPDATESTRING%"
echo -------------------------------------------
echo Sleep 10 secs...
echo -------------------------------------------
sleep 10
echo -------------------------------------------
echo Sending NotifyString to Client 2
echo -------------------------------------------
wget.exe -r -A.pdf "%CLIENT2%%NOTIFYSTRING%"
echo -------------------------------------------
echo Sleep 5 secs...
echo -------------------------------------------
sleep 5
echo -------------------------------------------
echo Sending UpdateString to Client 2
echo -------------------------------------------
wget.exe -r -A.pdf "%CLIENT2%%UPDATESTRING%"
echo -------------------------------------------
echo Sleep 10 secs...
echo -------------------------------------------
sleep 10
echo -------------------------------------------
echo Sending NotifyString to Client 3
echo -------------------------------------------
wget.exe -r -A.pdf "%CLIENT3%%NOTIFYSTRING%"
echo -------------------------------------------
echo Sleep 5 secs...
echo -------------------------------------------
sleep 5
echo -------------------------------------------
echo Sneding UpdateString to Client 3
echo -------------------------------------------
wget.exe -r -A.pdf "%CLIENT3%%UPDATESTRING%"
echo -------------------------------------------
echo Done!
echo -------------------------------------------
Primitive, but it works. YOU NEED wget for windows for this to work. I have posted a link at the botton of the page to a zip with this .bat, wget, and the sleep.exe needed for the sleep commands all ready to go. or you can find wget for windows on google

The script is set up for 3 clients to add more simply add
Code:
SET CLIENTX="http://localhost:port"
and then copy and paste these lines to the bottom of the script
Code:
echo -------------------------------------------
echo Sending NotifyString to Client 1
echo -------------------------------------------
wget.exe -r -A.pdf "%CLIENT1%%NOTIFYSTRING%"
echo -------------------------------------------
echo Sleep 5 secs...
echo -------------------------------------------
sleep 5
echo -------------------------------------------
echo Sending UpdateString to Client 1
echo -------------------------------------------
wget.exe -r -A.pdf "%CLIENT1%%UPDATESTRING%"
echo -------------------------------------------
echo Sleep 10 secs...
echo -------------------------------------------
sleep 10
Repeat as many times as you like. I'm not gonna explain the script in great detail here because i did in the comments but basically you need to define at least one client at the SET CLIENT1= line and define the path at SET SOURCE= line. If you want you can change what the Notification in xbmc says by editng SET MSG= just remember you have to use + to represent a space. if you dont it breaks the script.

This has been tested on:

Host Machine: Windows XP
HTPC:ubuntu 11.04 and ubuntu 10.10 with latest xbmc git (11.25.11)

Hope this helps!

heres the link to the download: http://www.multiupload.com/QDA7SKNZ1V
(This post was last modified: 2011-11-26 15:09 by Hack_kid.)
find quote
Roman_V_M Offline
Fan
Posts: 550
Joined: Jun 2011
Reputation: 14
Location: Kyiv, Ukraine
Post: #75
2 Hack_kid
Quote:for some reason i couldnt get the --spider command to work i think there is a bug

If you had paid attention you'd have noticed that there is one dash in my string. Smile Yes, in Windows wget double dash options do not work, you need to use a single dash instead.
find quote
Post Reply