def itemAttrs(entry): attrs = dict() if entry.published is not None: attrs['creation_date'] = strToDatetime(entry.published.text) else: attrs['creation_date'] = strToDatetime(entry.updated.text) group = entry.FindExtensions('group')[0] attrs['title'] = entry.title.text attrs['description'] = entry.summary.text attrs['author'] = group.FindChildren('credit')[0].text attrs['external_url'] = getId(entry) attrs['url'] = group.FindChildren( 'content')[0].attributes['url'] + '?imgmax=512' # Get thumbnail of 108x144 attrs['thumbnail_url'] = findFirst( lambda t: t.attributes['height'] == '144' or t.attributes['width'] == '144', group.FindChildren('thumbnail')).attributes['url'] keywords = group.FindChildren('keywords')[0].text attrs['user_tags'] = keywords.split(' ') if keywords else [] return attrs
def getGroupsToCheck(username, lastUpdate): """ Given the lastUpdate date, it returns a tuple with the new groups and the changed groups for the username """ newGroups = [] changedGroups = [] if lastUpdate is not None: # we don't know if default groups have updates, # so we check them for e in iUserGroupsEntries(username): if lastUpdate < strToDatetime(e.published.text): newGroups.append(entry2group(e)) elif lastUpdate < strToDatetime(e.updated.text): changedGroups.append(entry2group(e)[0]) else: newGroups = [entry2group(e) for e in iUserGroupsEntries(username)] return newGroups, changedGroups
def itemAttrs(entry): attrs = dict() if entry.published is not None: attrs['creation_date'] = strToDatetime(entry.published.text) else: attrs['creation_date'] = strToDatetime(entry.updated.text) group = entry.FindExtensions('group')[0] attrs['title'] = group.FindChildren('title')[0].text attrs['description'] = group.FindChildren('description')[0].text attrs['author'] = entry.author[0].name.text attrs['externalURL'] = \ group.FindChildren('player')[0].attributes['url'] isFlash = lambda c: (c.attributes['type'] == \ 'application/x-shockwave-flash') flvContent = filter(isFlash, group.FindChildren('content')) assert len(flvContent) == 1 attrs['embedURL'] = flvContent[0].attributes['url'] # thumbnails thumbs = filter(lambda t: int(t.attributes['width']) == 130, group.FindChildren('thumbnail')) attrs['thumbnails'] = [] for th in thumbs: vth = dict() vth['width'] = int(th.attributes['width']) vth['height'] = int(th.attributes['height']) vth['time'] = th.attributes['time'] vth['url'] = th.attributes['url'] attrs['thumbnails'].append(vth) attrs['item_tags'] = [ c.term for c in entry.category if c.scheme == TAG_SCHEME ] return attrs
def itemAttrs(entry): attrs = dict() attrs['title'] = entry.h4.a.string attrs['url'] = entry.h4.a.get('href') dateStr = entry.find('span','date').get('title') attrs['creation_date'] = strToDatetime(dateStr) itemAnchor = entry.find('a','pop') if itemAnchor is not None: id = itemAnchor.get('href')[5:] attrs['popularity'] = int(POPULARITY_RG.search(itemAnchor.string).group(1)) attrs['serviceUrl'] = 'http://del.icio.us/url/%s' % id else: external_id = md5.new(attrs['url']).hexdigest() attrs['popularity'] = 1 attrs['serviceUrl'] = 'http://del.icio.us/url/%s' % external_id attrs['user_tags'] = [anchor.string.strip() for anchor in entry.findAll('a','tag')] return attrs