Example #1
0
	def get(self):
		# Scale down all scores so more recently added tracks are more prominant
		for entry in PlaygrubChartEntry.all():
			if (entry.score > 0.1):
				entry.score *= 0.95
				entry.put()
			else:
				entry.delete()
		
		# List all tracks that haven't been processed for charts
		for track in PlaylistTrack.gql('where create_date > :1', datetime.datetime.now() - datetime.timedelta(3600)):
			entries = PlaygrubChartEntry.gql('where artist = :1 and track = :2',track.artist,track.track)
			if (entries.count() == 0):
				entry = PlaygrubChartEntry(artist = track.artist,track = track.track,score = 1.0)
			else:
				entry = entries.fetch(1)[0]
				entry.score += 1
			entry.put()
			try:
				print "Incremented \""+entry.track+"\" - "+entry.artist+" to "+str(entry.score)
			except:
				print "Some UTF-8 encoded track name, CBA to figure out how to echo them :P"
Example #2
0
  def get(self):
    q = PlaygrubChartEntry.all()
    q.order('-score')
    if q.count() == 0:
      return
    
    songs = q.fetch(50)
    class ChartHeader(object):
      title = "The Latest Tomahawklet Charts" # Include the local time maybe?
      url = pghost+"#xspf="+pghost+"charts"
    
    head = ChartHeader()
    
    template_values = {
      'header': head,
      'songs': songs,
    }

    path = os.path.join(os.path.dirname(__file__), 'html/xspf-template.xspf')
    self.response.headers['Content-Type'] = 'application/xspf+xml'
    self.response.out.write(template.render(path, template_values))