Posts: 3
Joined: Sep 2006
Reputation:
0
I have a hard mod Xbox at home and a soft mod Xbox at work. All the scripts I've downloaded work fine at home. When I take them to work, all of the scripts that need to access the internet will fail one way or the other. We are behind a proxy at work and I have setup the proxy in XBMC correctly since the RSS and Weather work just fine. I'm guessing, from what little I've been able to piece together that most scripts access the internet directly through Python rather than through a built-in XBMC component, so how might I access the Proxy settings (or any XBMC settings) from script so I can use them?
If I am horribly off track please feel free to flame me.
Posts: 249
Joined: Feb 2005
Reputation:
0
EnderW
Skilled Python Coder
Posts: 249
Not really exactly what you are asking for, but just a piece of information. First, I have never tried this code myself as it was submitted by a guy and I have no proxy. Anyways:
import urllib2
proxy_handler = urllib2.ProxyHandler({'http': 'http://' + "192.168.1.0:8080"})
opener = ClientCookie.build_opener(proxy_handler)
ClientCookie.install_opener(opener)
The script in question used ClientCookie to open files, but as of Python 2.4 (which is included in xbmc) that is no longer necessary. So instead try replacing ClientCookie with urllib or urllib2 (depending on what the script uses):
import urllib2
proxy_handler = urllib2.ProxyHandler({'http': 'http://' + "192.168.1.0:8080"})
opener = urllib.build_opener(proxy_handler)
urllib.install_opener(opener)
if you put this code after importion of modules in a script it could work. Getting parameters and doing all this automagically would of course be way better than having to edit all scripts with potential problems that may cause (some scripts build their own openers). Remember to edit IP if you're gonna try this...
xbmcscripts.com administrator
Posts: 3
Joined: Sep 2006
Reputation:
0
In case anyone is curious. I managed to work around this for now by using the following:
url = 'http://www.rocketboom.com/vlog/index.xml'
filename = 'Z:\\temp.xml'
try:
os.remove(filename)
except:
pass
progress = xbmcgui.DialogProgress()
progress.create('Status','Retrieving Data from Internet\nPlease be patient.')
progress.update(0)
response = xbmc.executehttpapi('FileDownloadFromInternet(' + url + ';' + filename + ')')
progress.close()
This manages to use XBMC internal network access which respects the proxy settings. Kinda messy though.
Posts: 3
Joined: Sep 2006
Reputation:
0
Sorry for the above, apparently 'Post Quick Reply' _quickly_ removes tabs first. Please add necessary pythonic indenting to the above.