Beispiel #1
0
 def get(self):
     self.write(
         self.render_string("bare_header.html", title="Adding Groups"))
     self.write("<h2>Associating Groups</h2>")
     self.write("<h3>These Songs:</h3><ul>")
     songs = cache.get_user(self.user, "admin_associate_groups_songs") or []
     for song_id in songs:
         song = Song.load_from_id(song_id)
         self.write("<li>%s</li>" % song.data['title'])
     self.write("</ul><h3>Songs In These Albums:</h3><ul>")
     albums = cache.get_user(self.user,
                             "admin_associate_groups_albums") or []
     for album_set in albums:
         album = Album.load_from_id(album_set[0])
         self.write(
             "<li>%s (%s)</li>" %
             (album.data['name'], config.station_id_friendly[album_set[1]]))
     self.write("</ul><select id='associate_group_id'>")
     for row in db.c.fetch_all(
             "SELECT group_id, group_name FROM r4_groups ORDER BY group_name"
     ):
         self.write("<option value='%s'>%s</option>" %
                    (row['group_id'], row['group_name']))
     self.write("</select><br />")
     self.write(
         "<button onclick=\"window.location.href='/admin/tools/associate_groups_finish/' + document.getElementById('associate_group_id').value\">Associate</button>"
     )
     self.write(
         "<br /><br /><a href='/admin/tools/associate_groups_cache_reset'>Reset the list above.</a>"
     )
     self.write(self.render_string("basic_footer.html"))
Beispiel #2
0
	def get(self):
		self.write(self.render_string("bare_header.html", title="Adding Groups"))
		self.write("<h2>Associating Groups</h2>")
		self.write("<h3>These Songs:</h3><ul>")
		songs = cache.get_user(self.user, "admin_associate_groups_songs") or []
		for song_id in songs:
			song = Song.load_from_id(song_id)
			self.write("<li>%s</li>" % song.data['title'])
		self.write("</ul><h3>Songs In These Albums:</h3><ul>")
		albums = cache.get_user(self.user, "admin_associate_groups_albums") or []
		for album_set in albums:
			album = Album.load_from_id(album_set[0])
			self.write("<li>%s (%s)</li>" % (album.data['name'], config.station_id_friendly[album_set[1]]))
		self.write("</ul><select id='associate_group_id'>")
		for row in db.c.fetch_all("SELECT group_id, group_name FROM r4_groups ORDER BY group_name"):
			self.write("<option value='%s'>%s</option>" % (row['group_id'], row['group_name']))
		self.write("</select><br />")
		self.write("<button onclick=\"window.location.href='/admin/tools/associate_groups_finish/' + document.getElementById('associate_group_id').value\">Associate</button>")
		self.write("<br /><br /><a href='/admin/tools/associate_groups_cache_reset'>Reset the list above.</a>")
		self.write(self.render_string("basic_footer.html"))
Beispiel #3
0
import argparse

from libs import config
from libs import db
from rainwave.playlist import Album

if __name__ == "__main__":
	parser = argparse.ArgumentParser(description="Rainwave API server.")
	parser.add_argument("--config", default=None)
	args = parser.parse_args()
	config.load(args.config)
	db.connect()

	albums = db.c.fetch_list("SELECT album_id FROM r4_albums")
	i = 0
	for album_id in albums:
		txt = "Album %s / %s" % (i, len(albums))
		txt += " " * (80 - len(txt))
		print "\r" + txt,
		i += 1
		
		a = Album.load_from_id(album_id)
		a.reconcile_sids()
		a.update_all_user_ratings()
		a.update_rating()
Beispiel #4
0
#!/usr/bin/env python

import argparse

from libs import config
from libs import db
from rainwave.playlist import Album

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Recalculates all album ratings, both global ratings and for every user.  Takes a while."
    )
    parser.add_argument("--config", default=None)
    args = parser.parse_args()
    config.load(args.config)
    db.connect()

    albums = db.c.fetch_list("SELECT album_id FROM r4_albums")
    i = 0
    for album_id in albums:
        txt = "Album %s / %s" % (i, len(albums))
        txt += " " * (80 - len(txt))
        print("\r" + txt, end="")
        i += 1

        a = Album.load_from_id(album_id)
        a.reconcile_sids()
        a.update_all_user_ratings()
        a.update_rating()