def main_route(): from db import DBFeedItem, DBLogItem, DBConnection, LOG_LEVEL conn = DBConnection() feeditems = [] addonitems = [] if addons == None: print 'No addon loaded...' return for addon in addons: if hasattr(addon, 'get_feeds'): feeds = getattr(addon, 'get_feeds')() else: conn.insert_element( DBLogItem('The addon ' + str(addon) + ' is not supported. Please implement a "get_feeds()" function or contact the developer.', datetime.datetime.now(), LOG_LEVEL['warn'] ) ) feeds = None if feeds == None or len(feeds) == 0: continue addonitems.append(feeds[0].type) for feed in feeds: if isinstance(feed, Feeditem) or isinstance(feed, DBFeedItem): feeditems.append(feed) else: conn.insert_element( DBLogItem('The Element (' + str(feed) + ') could not be placed on the stream.', datetime.datetime.now(), LOG_LEVEL['warn'] ) ) feeditems.sort(key = lambda element: element.time, reverse = True) return render_template('dashboard.html', feeditems = feeditems, addonitems = addonitems, extended = False)
'description': element.origin.description, 'songurl': element.origin.permalink_url, 'artworkurl': element.origin.artwork_url.replace('large', 't300x300'), 'waveformurl': element.origin.waveform_url, 'genre': element.origin.genre, 'duration': element.origin.duration, }) source = source.format(element.origin.user['username']) elif _type == 'comment': pass elif _type == 'favoriting': pass else: print 'Not accepted!' continue except ConnectionError, e: return except Exception, e: return time = datetime.datetime.strptime(element.created_at, '%Y/%m/%d %H:%M:%S +%f') # e.g. 2016/02/17 15:03:31 +0000 conn.insert_element( DBFeedItem( content, # content TYPE, # element type (soundcloud) source, # source (the type of the element from soundcloud) time # time (as datetime) ) )