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
achaw Offline
Junior Member
Posts: 41
Joined: Mar 2012
Reputation: 0
Post: #101
Someone else are losing xbmc focus when the script es executed?

PS: I response myself, is a utorrent problem....when a toorrent is added xbmc lose focus...
(This post was last modified: 2012-08-10 04:06 by achaw.)
find quote
crimsonfury Offline
Fan
Posts: 462
Joined: Mar 2012
Reputation: 1
Location: Arizona, U.S.
Post: #102
How do I auto unpack my rar TV files so I can get this to work? I like to have all of video files unpacked...

[Image: all-clearlogo.jpg]
find quote
crimsonfury Offline
Fan
Posts: 462
Joined: Mar 2012
Reputation: 1
Location: Arizona, U.S.
Post: #103
Bump?

[Image: all-clearlogo.jpg]
find quote
achaw Offline
Junior Member
Posts: 41
Joined: Mar 2012
Reputation: 0
Post: #104
(2012-08-09 05:52)crimsonfury Wrote:  How do I auto unpack my rar TV files so I can get this to work? I like to have all of video files unpacked...

Probably you just modify this script to use some command line rar application...
If you search in this post ther is an user who modifi this script to use tvrenamer....you should use a similar concept
find quote
Hack_kid Offline
Fan
Posts: 567
Joined: Jan 2007
Reputation: 2
Post: #105
(2011-11-26 14:55)Hack_kid Wrote:  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

EDIT: REMOVED OLD CODE TO COMPLY WITH CHARICTAR LIMIT

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

Updated my script to work with Linux. it Also can parse the Source path rom the command line so if your app suports it you can dynamicly pass/load Source paths to be send to XBMC.

Code:
#!/bin/bash
#! --------------------------------------------------------------------------
#! XBMC Library Auto-Update Commander v3.0
#! --------------------------------------------------------------------------
#! Info: Replacement for watzens's old .vbs script
#! based on wget for use in Linux :)
#!
#! Switched my fileserver to Linux so i needed a new (old)
#! way of sending the update library command along with
#! the source path, and i came up with this. Now with an
#! added option of parsing source path and update msg
#! from command line.
#!
#! Significance of this is that you can now dynamicly set
#! the source path. if the porgram you use to launch this
#! supports wildcards for source path (SCRU, uTorrent)
#! you can have the calling app parse the filepath of the
#! media in question to the script. mimimizing errors and
#! making it much easier to use with multiple source paths.
#!
#! Usage: Pretty similar to the old script minus the Queued
#! torrent functions. Simply fill out at least one client and
#! your path to the source. if you want it to parse from
#! command line no need to change from default.
#! SOURCE is the first arg ($1) and MSG is the 2nd arg ($2)
#!
#! Example: ./update-xbmc.sh "/Media/Movies/DVDRips/" "New DVDRips"
#! or:            ./update-xbmc.sh /Media/TVs/Weeds Weeds
#!
#! Albinoman887
#!

#! Runtime Options. Set Clients and path below
#! ==================================================
#!
#! Set your clients.

CLIENT1="http://192.168.1.40:8080"
CLIENT2="http://192.168.1.25:8080"
CLIENT3="http://192.168.1.139:8080"

#! Set static Source Path (or $! to call from command line)

SOURCE="$1"

#! Set a message to display to the user (or $2 to call from command line)

MSG="$2"

#! ===================================================
#! ---------------DO NOT EDIT BELOW THIS LINE---------

#! Set Variables
NOTIFYSTRING="/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(Auto+Media+Updater,$MSG+being+added))"
UPDATESTRING="/xbmcCmds/xbmcHttp?command=ExecBuiltIn(UpdateLibrary(video,$SOURCE))"

#! Begin Script
echo ----------------------------------------------------------------------------
echo      XBMC Library Update Commander Invoked....
echo ----------------------------------------------------------------------------
sleep 5

#! Client 1
echo ----------------------------------------------------------------------------
echo     Sending NotifyString $MSG to $CLIENT1
echo ----------------------------------------------------------------------------
wget -O - "$CLIENT1$NOTIFYSTRING"
echo ----------------------------------------------------------------------------
echo                  Sleep 3 secs...
echo ----------------------------------------------------------------------------
sleep 3
echo ----------------------------------------------------------------------------
echo     Sending UpdateString $SOURCE to $CLIENT1
echo ----------------------------------------------------------------------------
wget -O - "$CLIENT1$UPDATESTRING"
echo ----------------------------------------------------------------------------
echo                 Sleep 10 secs...
echo ----------------------------------------------------------------------------
sleep 10
echo ----------------------------------------------------------------------------
echo                    Done
echo ----------------------------------------------------------------------------

#! Client 2
echo ----------------------------------------------------------------------------
echo     Sending NotifyString $MSG to $CLIENT2
echo ----------------------------------------------------------------------------
wget -O - "$CLIENT2$NOTIFYSTRING"
echo ----------------------------------------------------------------------------
echo                  Sleep 3 secs...
echo ----------------------------------------------------------------------------
sleep 3
echo ----------------------------------------------------------------------------
echo     Sending UpdateString $SOURCE to $CLIENT2
echo ----------------------------------------------------------------------------
wget -O - "$CLIENT2$UPDATESTRING"
echo ----------------------------------------------------------------------------
echo                 Sleep 10 secs...
echo ----------------------------------------------------------------------------
sleep 10
echo ----------------------------------------------------------------------------
echo                   Complete.
echo ----------------------------------------------------------------------------
I use this with ubuntu sever 12.04 along with utserver, and SCRU running inside wine1.5 with dotnet installed via winetricks and scru monitors my Finished folder for utorrent unrars my media to folders based on media type (DVDRip R5 TVShows) then SCRU launches the script (yes you can launch a linux script with a windows app in wine) and parses the destination of the unrared media and the profile name wich in this case is the name of the media type to the command line while launching this script thus telling xbmc to check just that path for updated media speeding up the update process and keeping it clean as well as display a message to the xbmc user about the new media being added.

Let me know what you guys think
find quote
crimsonfury Offline
Fan
Posts: 462
Joined: Mar 2012
Reputation: 1
Location: Arizona, U.S.
Post: #106
(2012-08-05 03:33)achaw Wrote:  Someone else are losing xbmc focus when the script es executed?

PS: I response myself, is a utorrent problem....when a toorrent is added xbmc lose focus...

What is the fix for this?

I have utorrent use the commands to open winrar and unrar all of my tv shows in their folders and then Sickbeard scans the download folder and grabs all shows and info and renames and sorts to the correct show folder elsewhere. It all works great, except....

Every time utorrent uses winrar it automatically minimizes XBMC.... How do I make XBMC full control with no minimizing or what cmd can I add to utorrent?

[Image: all-clearlogo.jpg]
find quote
bboo Offline
Member
Posts: 97
Joined: Dec 2011
Reputation: 1
Post: #107
Can i use this without using all those labels and "move completed to" options? Can i just tell XBMC to update itself once a torrent finishes downloading?
find quote
watzen Offline
Fan
Posts: 459
Joined: Jan 2007
Reputation: 10
Location: Sweden
Post: #108
(2012-11-02 21:18)bboo Wrote:  Can i use this without using all those labels and "move completed to" options? Can i just tell XBMC to update itself once a torrent finishes downloading?

Yes, but you need to edit out the parts that refer to updating a specific directory, the script gets a lot simpler that way:

Haven't tried this, but it should work. Just add the file in run on completed torrent. No parameters needed
Code:
Dim objSvrHTTP
Dim connectionString
Dim JSONstring
Dim xbmcConnection
Set objSvrHTTP = CreateObject("MSXML2.XMLHTTP")

On Error Resume Next
'edit this line to work with your setup
xbmcConnection = "http://xbmc:xbmc@localhost/jsonrpc?request="

'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 that tells it to update
    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    
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

As some may notice in the above post is that I've replaced the HTTP-API code that is now depreciated in the latest nightly builds of xbmc. I have replaced it with JSON requests instead. The original post has been updated with a new version.

  • 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
(This post was last modified: 2012-11-03 11:40 by watzen.)
find quote
bboo Offline
Member
Posts: 97
Joined: Dec 2011
Reputation: 1
Post: #109
Thanks for that! I'm really new to all this so i would appreciate some more assistance. Which lines exactly do i need to change and how?
find quote
Calleja Offline
Junior Member
Posts: 25
Joined: Aug 2012
Reputation: 0
Post: #110
The script stopped working for Frodo, it seems Sad

Any updates we could apply?
find quote
Post Reply