Adding cookie or header to picture links? - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: Adding cookie or header to picture links? (/showthread.php?tid=89383) |
Adding cookie or header to picture links? - vidmard - 2011-01-03 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...
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 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! - anarchintosh - 2011-01-04 here are some the methods you need, might be a little messy: PHP Code: import cookielib,sys,os,urllib,urllib2 then 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: # Browser it's all mostly a google away, this page might help - vidmard - 2011-01-05 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. - Unbehagen - 2011-02-26 This thing might help you out: http://forum.xbmc.org/showthread.php?tid=95369 |