34
34
from coherence.upnp.core.utils import parse_xml, ReverseProxyResource
36
36
from coherence.upnp.core.DIDLLite import classChooser,Container,PhotoAlbum,Photo,ImageItem,Resource,DIDLElement
37
from coherence.upnp.core.DIDLLite import simple_dlna_tags
37
from coherence.upnp.core.DIDLLite import simple_dlna_tags, PlayContainerResource
38
38
from coherence.upnp.core.soap_proxy import SOAPProxy
39
39
from coherence.upnp.core.soap_service import errorCode
41
41
from coherence.upnp.core.utils import getPage
42
42
from coherence.backend import BackendItem, BackendStore
44
import coherence.extern.louie as louie
46
44
from coherence.extern.simple_plugin import Plugin
48
46
from coherence import log
230
225
def add_child(self, child, update=False):
231
226
self.children.append(child)
232
self.child_count += 1
233
if isinstance(self.item, Container):
234
self.item.childCount += 1
235
227
if update == True:
236
228
self.update_id += 1
239
230
def remove_child(self, child):
240
231
self.info("remove_from %d (%s) child %d (%s)" % (self.id, self.get_name(), child.id, child.get_name()))
241
232
if child in self.children:
242
self.child_count -= 1
243
if isinstance(self.item, Container):
244
self.item.childCount -= 1
245
233
self.children.remove(child)
246
234
self.update_id += 1
297
292
#print size.get('label'), size.get('source')
298
293
if size.get('label') == 'Original':
299
294
self.original_url = (size.get('source'),size.get('width')+'x'+size.get('height'))
300
self.url = self.original_url[0]
295
if self.store.proxy == False:
296
self.url = self.original_url[0]
298
self.location = ProxyImage(self.original_url[0])
301
299
elif size.get('label') == 'Large':
302
300
self.large_url = (size.get('source'),size.get('width')+'x'+size.get('height'))
303
self.url = self.large_url[0]
301
if self.store.proxy == False:
302
self.url = self.large_url[0]
304
self.location = ProxyImage(self.large_url[0])
304
305
elif size.get('label') == 'Medium':
305
306
self.medium_url = (size.get('source'),size.get('width')+'x'+size.get('height'))
306
307
elif size.get('label') == 'Small':
309
310
self.thumb_url = (size.get('source'),size.get('width')+'x'+size.get('height'))
311
312
self.item = Photo(self.id,self.parent.get_id(),self.get_name())
313
#print self.id, self.store.proxy, self.url
312
314
self.item.date = self.date
315
self.item.attachments = {}
313
316
dlna_tags = simple_dlna_tags[:]
314
317
dlna_tags[3] = 'DLNA.ORG_FLAGS=00f00000000000000000000000000000'
315
318
if hasattr(self,'original_url'):
316
319
dlna_pn = 'DLNA.ORG_PN=JPEG_LRG'
317
res = Resource(self.original_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
320
if self.store.proxy == False:
321
res = Resource(self.original_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
323
res = Resource(self.url+'?attachment=original', 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
324
self.item.attachments['original'] = ProxyImage(self.original_url[0])
318
325
res.resolution = self.original_url[1]
319
326
self.item.res.append(res)
320
327
elif hasattr(self,'large_url'):
321
328
dlna_pn = 'DLNA.ORG_PN=JPEG_LRG'
322
res = Resource(self.large_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
329
if self.store.proxy == False:
330
res = Resource(self.large_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
332
res = Resource(self.url+'?attachment=large', 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
333
self.item.attachments['large'] = ProxyImage(self.large_url[0])
323
334
res.resolution = self.large_url[1]
324
335
self.item.res.append(res)
325
336
if hasattr(self,'medium_url'):
326
337
dlna_pn = 'DLNA.ORG_PN=JPEG_MED'
327
res = Resource(self.medium_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
338
if self.store.proxy == False:
339
res = Resource(self.medium_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
341
res = Resource(self.url+'?attachment=medium', 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
342
self.item.attachments['medium'] = ProxyImage(self.medium_url[0])
328
343
res.resolution = self.medium_url[1]
329
344
self.item.res.append(res)
330
345
if hasattr(self,'small_url'):
331
346
dlna_pn = 'DLNA.ORG_PN=JPEG_SM'
332
res = Resource(self.small_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
347
if self.store.proxy == False:
348
res = Resource(self.small_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
350
res = Resource(self.url+'?attachment=small', 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
351
self.item.attachments['small'] = ProxyImage(self.small_url[0])
333
352
res.resolution = self.small_url[1]
334
353
self.item.res.append(res)
335
354
if hasattr(self,'thumb_url'):
336
355
dlna_pn = 'DLNA.ORG_PN=JPEG_TN'
337
res = Resource(self.thumb_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
356
if self.store.proxy == False:
357
res = Resource(self.thumb_url[0], 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
359
res = Resource(self.url+'?attachment=thumb', 'http-get:*:%s:%s' % (self.mimetype,';'.join([dlna_pn]+dlna_tags)))
360
self.item.attachments['thumb'] = ProxyImage(self.thumb_url[0])
338
361
res.resolution = self.thumb_url[1]
339
362
self.item.res.append(res)
751
775
def flickr_photos_getSizes(self, photo_id=None):
752
d = self.flickr_call('flickr.photos.getSizes', photo_id=photo_id)
776
if self.flickr_authtoken != None:
777
api_sig = self.flickr_create_api_signature(auth_token=self.flickr_authtoken,method='flickr.photos.getSizes', photo_id=photo_id)
778
d = self.flickr_call('flickr.photos.getSizes', auth_token=self.flickr_authtoken, photo_id=photo_id,api_sig=api_sig)
780
api_sig = self.flickr_create_api_signature(method='flickr.photos.getSizes', photo_id=photo_id)
781
d = self.flickr_call('flickr.photos.getSizes',photo_id=photo_id,api_sig=api_sig)
756
784
def flickr_interestingness(self, date=None, per_page=100):
758
786
date = time.strftime( "%Y-%m-%d", time.localtime(time.time()-86400))