示例#1
0
文件: groups.py 项目: Dinir/rainwave
 def post(self):
     s = Song.load_from_id(self.get_argument("song_id"))
     s.remove_group_id(self.get_argument("group_id"))
     self.append(self.return_name, {
         "success": "true",
         "tl_key": "Group removed from song ID."
     })
示例#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"))
示例#3
0
文件: groups.py 项目: Dinir/rainwave
 def post(self):
     s = Song.load_from_id(self.get_argument("song_id"))
     #If comma-separated values, will do each individually
     for group in self.get_argument("group").split(","):
         s.add_group(group.strip())
     self.append(self.return_name, {
         "success": "true",
         "text": "Group added to song."
     })
示例#4
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"))
示例#5
0
#!/usr/bin/env python

import argparse

from libs import config
from libs import db
from libs import log
from rainwave.playlist import Song

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Recalculates all song global ratings.  Can take a while."
    )
    parser.add_argument("--config", default=None)
    args = parser.parse_args()
    config.load(args.config)
    log.init()
    db.connect()

    songs = db.c.fetch_list("SELECT song_id FROM r4_songs")
    i = 0
    for song_id in songs:
        txt = "Song %s / %s" % (i, len(songs))
        txt += " " * (80 - len(txt))
        print("\r" + txt, end="")
        i += 1

        s = Song.load_from_id(song_id)
        s.update_rating(skip_album_update=True)
示例#6
0
文件: groups.py 项目: Dinir/rainwave
	def post(self):
		s = Song.load_from_id(self.get_argument("song_id"))
		s.remove_group_id(self.get_argument("group_id"))
		self.append(self.return_name, { "success": "true", "tl_key": "Group removed from song ID." })
示例#7
0
文件: groups.py 项目: Dinir/rainwave
	def post(self):
		s = Song.load_from_id(self.get_argument("song_id"))
		#If comma-separated values, will do each individually
		for group in self.get_argument("group").split(","):
			s.add_group(group.strip())
		self.append(self.return_name, { "success": "true", "text": "Group added to song." })
示例#8
0
#!/usr/bin/python

import argparse

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

if __name__ == "__main__":
	parser = argparse.ArgumentParser(description="Recalculates all song global ratings.  Can take a while.")
	parser.add_argument("--config", default=None)
	args = parser.parse_args()
	config.load(args.config)
	db.connect()

	songs = db.c.fetch_list("SELECT song_id FROM r4_songs")
	i = 0
	for song_id in songs:
		txt = "Song %s / %s" % (i, len(songs))
		txt += " " * (80 - len(txt))
		print "\r" + txt,
		i += 1

		s = Song.load_from_id(song_id)
		s.update_rating(skip_album_update=True)