Re: XBMC Library Updater
Posted: December 4th, 2008, 1:59 pm
Open up Terminal, navigate to the script, and type "chmod +x scriptname.sh" to allow execution.
Code: Select all
#!/bin/bash
echo "Updating Plex"
curl --get "http://192.168.0.20:3000/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)" > /dev/null 2>&1
Code: Select all
import urllib
urllib.urlopen("xbmcaddress/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)").close()
Ok, first bit of advise, ditch Windows and load Ubuntu. However, if you're unwilling to do that the first thing you're going to need to do is find a python interpeter for Windows. http://www.python.org/download/windows/ That is what you'll use to run the .py file. The next bit is in the options of XBMC, you're not looking for FTP you're looking for HTTP.tbird2340 wrote: Can anyone help me get this working for the XBMC Windows port? It doens't have the FTP option on the Windows version so I'm stuck on what to do.. I seen someone posted this:
Code: Select all
import urllib urllib.urlopen("xbmcaddress/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)").close()
And then said to call it from the cmd file but I'm not sure how to do that.. I'm totally new to XBMC.. So I put all that code above in a .py file but then what? What command do I put in the "updatelibrary.cmd" file? And where to I put the .py file?
Thanks much!
the Curl command does not seem to exist on AppleTV. Any one know how i might get this script to work on ATV?interfacelift wrote: bigdaddy, is your script attempting to update XBMC/Plex? If so, you'll have to make sure it's a true shell script.
This is what I use for Plex (Plex is running on my LAN at 192.168.0.20):Copy and paste that in to a text file and save it in your scripts folder, then chmod +x it, and set SAB to use it.Code: Select all
#!/bin/bash echo "Updating Plex" curl --get "http://192.168.0.20:3000/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)" > /dev/null 2>&1
Ok i figured this out. If you want to run this locally on your apple TV create this script save as .sh and put it into your scripts folder. Have SABnbzd call it when something is downloaded.peteo wrote: the Curl command does not seem to exist on AppleTV. Any one know how i might get this script to work on ATV?
Code: Select all
#!/bin/sh
wget "http://xbmc:[email protected]:8081/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)" >/dev/null 2>&1
Code: Select all
# Python 2.6.4 | http://www.python.org/download/releases/2.6.4/
import socket,sys,urllib2
from urllib2 import Request, URLError, urlopen
# timeout in seconds
socket.setdefaulttimeout(10)
# Get clean NZB name
job_name = sys.argv[3]
# Set Prowl API
API = "XXXXXX"
# Set Prowl priority
priority = "0"
# Set job title/event name
job_title = "Download%20Complete"
# Get current date/time and strip spaces
from time import gmtime, strftime
event_time = strftime("%d/%m/%y %H:%M")
event_time=event_time.replace(' ', '%20')
# Strip illegal/unwanted chars from NZB name
job_name=job_name.replace(' ', '%20')
job_name=job_name.replace('_', '%20')
job_name=job_name.replace('.', '%20')
# Send download complete notification to Prowl - swap 'job_title' for 'event_time' if time is required in message instead of 'download complete'
prowl=urllib2.Request("https://prowl.weks.net/publicapi/add?apikey=" + API + "&priority=" + priority + "&application=SABnzbd&event=" + job_title + "&description=" + job_name)
try: urllib2.urlopen(prowl)
except URLError, e:
print 'Prowl Failed'
# End Prowl
# Send notification to XBMC1 & Update Library
xbmc1=urllib2.Request("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(" + job_title + "," + job_name + ",20000,c:\sabnzbd.jpg))")
try: urllib2.urlopen(xbmc1)
except URLError, e:
print 'XBMC1 Failed'
else:
urllib2.urlopen("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)")
# End XBMC1
# Send notification to XBMC2 & Update Library
xbmc2=urllib2.Request("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(" + job_title + "," + job_name + ",20000,c:\sabnzbd.jpg))")
try: urllib2.urlopen(xbmc2)
except URLError, e:
print 'XBMC2 Failed'
else:
urllib2.urlopen("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)")
# End XBMC2
I've set up basically the same thing except my library update includes the folder as the second, optional parameter.JohnSCS wrote: My latest Pyhton script for updating the XBMC library, XBMC on screen notification & Prowl notification of completed downloads
SAB 0.4.12 (should work but untested on 0.5.0B1)
WinXp SP3
Python IDLE 2.6.4 (will not work with Python 3.0+)
Save the above code as update.py (or whatever you like) to the scripts directory, and save the SABNZBD image to the root of c: drive. Set your Prowl API key and IP address details of your XBMC's, and set this as your default script or as needed in your categories/RSS filters.Code: Select all
# Python 2.6.4 | http://www.python.org/download/releases/2.6.4/ import socket,sys,urllib2 from urllib2 import Request, URLError, urlopen # timeout in seconds socket.setdefaulttimeout(10) # Get clean NZB name job_name = sys.argv[3] # Set Prowl API API = "XXXXXX" # Set Prowl priority priority = "0" # Set job title/event name job_title = "Download%20Complete" # Get current date/time and strip spaces from time import gmtime, strftime event_time = strftime("%d/%m/%y %H:%M") event_time=event_time.replace(' ', '%20') # Strip illegal/unwanted chars from NZB name job_name=job_name.replace(' ', '%20') job_name=job_name.replace('_', '%20') job_name=job_name.replace('.', '%20') # Send download complete notification to Prowl - swap 'job_title' for 'event_time' if time is required in message instead of 'download complete' prowl=urllib2.Request("https://prowl.weks.net/publicapi/add?apikey=" + API + "&priority=" + priority + "&application=SABnzbd&event=" + job_title + "&description=" + job_name) try: urllib2.urlopen(prowl) except URLError, e: print 'Prowl Failed' # End Prowl # Send notification to XBMC1 & Update Library xbmc1=urllib2.Request("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(" + job_title + "," + job_name + ",20000,c:\sabnzbd.jpg))") try: urllib2.urlopen(xbmc1) except URLError, e: print 'XBMC1 Failed' else: urllib2.urlopen("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)") # End XBMC1 # Send notification to XBMC2 & Update Library xbmc2=urllib2.Request("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(" + job_title + "," + job_name + ",20000,c:\sabnzbd.jpg))") try: urllib2.urlopen(xbmc2) except URLError, e: print 'XBMC2 Failed' else: urllib2.urlopen("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)") # End XBMC2
When this script runs, firstly the Prowl notification is sent, then XBMC1 on screen notification is sent - if this is successful, then the library update command is sent. Then, same again for XBMC2.
Because of the need to install Python 2.6, this script therefore can be run from the command line or other files aswell, but only reads variable #3 that is passed to it.
Also looking for the same thing. Looks like the perfect script for my needskulprit wrote: Can you give some more info on how to edit JohnSCS script to only update the show that has been added. Also thanks for the original JohnSCS, works great so far.
Code: Select all
# Get final folder name
folder_name = sys.argv[1]
# Uncomment the following line to change from a drive letter to a SMB share !!Note - I have not tested this!!
# folder_name=folder_name.replace('Y:\', '\\Servername\Sharename\')
folder_name=folder_name.replace(' ', '%20')
Code: Select all
# Python 2.6.4 | http://www.python.org/download/releases/2.6.4/
import socket,sys,urllib2
from urllib2 import Request, URLError, urlopen
Code: Select all
urllib2.urlopen("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video)")
Code: Select all
urllib2.urlopen("http://[IP Address:Port]/xbmcCmds/xbmcHttp?command=ExecBuiltIn¶meter=XBMC.updatelibrary(video," + folder_name + "\)")