def get_track(self, id): """ Get track meta-data given a track ID. Returns {} in case of failure """ try: track = Track.get(id) return track except sqlobject.main.SQLObjectNotFound: return None
def index(id): try: track = Track.get(id) stats = list(TrackStatistics.select(TrackStatistics.q.track == track.id)) if len(stats) > 0: stats = stats[0] else: stats = None url = request.environ['HTTP_HOST'] pos = url.rfind(':' + request.environ['SERVER_PORT']) if pos != -1: url = url[:pos] # otherwise the host is just the host without a port, # which is just what we want return render_master_page("track.html", title='Muzicast: Track', track=track, url=url, port=STREAM_PORT, stats=stats) except SQLObjectNotFound: abort(404)
def playlist_entries(): if 'playlist' not in session: return [] return (Track.get(id) for id in session['playlist'])