from been.core import SiteFeedSource, source_registry class Delicious(SiteFeedSource): url_format = 'http://feeds.delicious.com/v2/rss/{username}?count=50' kind = 'delicious' def process_event(self, event): event['author'] = self.config['username'] event['summary'] = 'bookmarked ' + event['data']['title'] return event source_registry.add(Delicious)
from been.core import SiteFeedSource, source_registry class Flickr(SiteFeedSource): url_format = 'http://api.flickr.com/services/feeds/photos_public.gne?id={username}&lang=en-us&format=rss_200' kind = 'flickr' def process_event(self, event): event['summary'] = 'posted photo ' + event['data']['title'] return event source_registry.add(Flickr)
import re import unicodedata import time import markdown # slugify from Django source (BSD license) def slugify(value): value = unicodedata.normalize('NFKD', unicode(value)).encode('ascii', 'ignore') value = unicode(re.sub('[^\w\s-]', '', value).strip().lower()) return re.sub('[-\s]+', '-', value) class MarkdownDirectory(DirectorySource): kind = 'markdown' def process_event(self, event): md = markdown.Markdown(extensions=['meta', 'tables', 'fenced_code', 'headerid']) event['content'] = md.convert(event['raw']) event['title'] = ' '.join(md.Meta.get('title', [event['filename']])) event['author'] = ' '.join(md.Meta.get('author', [''])) event['slug'] = '-'.join(md.Meta.get('slug', [slugify(event['title'])])) event['summary'] = 'posted ' + event['title'] event['meta'] = md.Meta if md.Meta.get('published'): # Parse time, then convert struct_time (local) -> epoch (GMT) -> struct_time (GMT) event['timestamp'] = time.gmtime(time.mktime(time.strptime(' '.join(md.Meta.get('published')), '%Y-%m-%d %H:%M:%S'))) event['_id'] = sha1(event['full_path'].encode('utf-8')).hexdigest() if time.gmtime() < event['timestamp']: return None else: return event source_registry.add(MarkdownDirectory)
from been.core import SiteFeedSource, source_registry class Twitter(SiteFeedSource): url_format = 'http://api.twitter.com/1/statuses/user_timeline.atom?screen_name={username}' kind = 'twitter' def process_event(self, event): event['content'] = event['data']['content'][0]['value'].partition(': ')[2] event['summary'] = 'tweeted "'+event['content']+'"' return event source_registry.add(Twitter)
from been.core import SiteFeedSource, source_registry class FanFiction(SiteFeedSource): url_format = 'http://b.fanfiction.net/atom/u/{username}/' kind = 'fanfiction' def process_event(self, event): event['summary'] = 'wrote a chapter in ' + event['data']['title'] return event source_registry.add(FanFiction)
from been.core import SiteFeedSource, source_registry class Grooveshark(SiteFeedSource): url_format = 'http://api.grooveshark.com/feeds/1.0/users/{username}/recent_favorite_songs.rss' kind = 'grooveshark' def process_event(self, event): event['author'] = self.config['username'] event['summary'] = 'favorited ' + event['data']['title'] return event source_registry.add(Grooveshark)
from been.core import SiteFeedSource, source_registry class LastFM(SiteFeedSource): url_format = 'http://ws.audioscrobbler.com/2.0/user/{username}/recenttracks.rss?limit=50' kind = 'lastfm' def process_event(self, event): event['summary'] = 'listened to ' + event['data']['title'] event['artist'], event['track'] = event['data']['title'].split(u' \u2013 ') return event source_registry.add(LastFM)
from been.core import SiteFeedSource, source_registry class Reddit(SiteFeedSource): url_format = 'http://www.reddit.com/user/{username}/submitted/.rss' kind = 'reddit' def process_event(self, event): event['summary'] = 'submitted ' + event['data']['title'] return event source_registry.add(Reddit)