[26f6e1]: / plugin.image.flickr / share.py  Maximize  Restore  History

Download this file

44 lines (35 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import default
reload(default)
from default import FlickrSession,LOG,photoURL
import ShareSocial #@UnresolvedImport
def doShareSocial():
return FlickrTargetFunctions()
class FlickrTargetFunctions(ShareSocial.TargetFunctions):
def provide(self,getObj,ID=None):
fsession = FlickrSession()
if not fsession.username: return getObj.error('NOUSERS')
if not fsession.authenticate(): return
flickr = fsession.flickr
if getObj.type == 'feed':
LOG('Providing feed to ShareSocial')
photos = flickr.activity_userPhotos(timeframe='365d')
try:
g = photos.find('items').find('item').attrib.get
except:
LOG('sharing: provide(): No items in photostream')
return getObj.error('EMPTYFEED')
clientid = g('owner','')
clientname = g('ownername','')
clienticon = photoURL(g('iconfarm',''),g('iconserver',''),g('owner',''),buddy=True)
client = {'id':clientid,'name':clientname,'photo':clienticon}
#print client
for i in photos.find('items').findall('item'):
g = i.attrib.get
pic = photoURL(g('farm',''),g('server',''),g('id',''),g('secret',''))
event = i.find('activity').find('event','')
g = event.attrib.get
userimage = photoURL(g('iconfarm',''),g('iconserver',''),g('user',''),buddy=True)
msg = event.text
if not msg: msg = g('type','').title()
getObj.addItem(g('username','?'),userimage,msg,g('dateadded',''),pic,client_user=client)
return getObj