I'm fairly new to both XBMC and Python and I have started working on Zenfolio (http://www.zenfolio.com) add-on. I have basic funcionality in place and I can browse galleries and view images
The problem I'm facing now is related to security. I can only browse public photos. Zenfolio has really nice JSON API which lets me login and browse through hierarchy and so on. But when I need to download original sized photo, request should have a custom http header or cookie. Here is a quote from Zenfolio docs...
[INDENT]
If access to a photo is restricted, the application needs to provide the authentication token or the keyring along with the GET request in a manner similar to the Zenfolio API calls. To specify the authentication token, the application should include an X-Zenfolio-Token header or a zf_token cookie. To specify the keyring, the application should include an X-Zenfolio-Keyring header or a zf_keyring cookie. See the Authentication and Using the Keyring chapters for more information.
http://www.zenfolio.com/zf/help/api/guide/download
[/INDENT]
Currently I'm accessing photos by adding a link to ListItem and marking it as isFolder = False. I don't see a way to add cookie/header. Should I download image and cache it and providing link to local image? I would rather not do that, if possible.
Any examples, links or suggestions for a solution are welcome!
Adding cookie or header to picture links?
vidmard
Junior Member Posts: 3 Joined: Jan 2011 Reputation: 0 |
|
| find quote |
anarchintosh
Fan Joined: Jul 2010 Reputation: 4 |
2011-01-04 18:15
Post: #2
here are some the methods you need, might be a little messy:
PHP Code: import cookielib,sys,os,urllib,urllib2then this is what you use when you want to load a page with a cookie. PHP Code: req = urllib2.Request(url)i've forgotten exactly how to save a cookie from a url with urllib, but heres the code i use to log into megaupload and save the cookie. it uses the mechanize module.... PHP Code: # Browserit's all mostly a google away, this page might help |
| find quote |
vidmard
Junior Member Posts: 3 Joined: Jan 2011 Reputation: 0 |
2011-01-05 01:28
Post: #3
Tnx, anarchintosh. But if I read your code snippets correctly, this solution is helpful when pulling stuff locally for pasing or storing. What I was asking if I couple somehow "inject" cookie or customer http header when XBMC is downloading JPG image when user clicks on listitem/folder/item created my my addon.
In meanwhile, support from Zenfolio did great job and told me how to URL encode authentication, so my problem is solved without cookies/header. |
| find quote |
Unbehagen
Skilled Python Coder Posts: 342 Joined: Jul 2007 Reputation: 3 Location: Bremen, Germany |
2011-02-26 09:09
Post: #4
This thing might help you out: http://forum.xbmc.org/showthread.php?tid=95369
|
| find quote |

Search
Help