def GET(self): filename = 'nowplaying.json' # return {'id': 10, 'length': 0, 'frequency': 48, 'bitrate': 128, # 'artist': 'Headstones', 'title': 'Absolutely'} if not os.path.isfile(filename): return {} nowplaying = jsonfile.load(filename) songid, info = nowplaying.popitem() try: artist, title = info['song'].split(' - ', 1) except ValueError: title = info['song'] artist = ' ' return { 'id': songid, 'length': info['length'], 'frequency': info['frequency'], 'bitrate': info['bitrate'], 'artist': artist, 'title': title }
def __init__(self): self.songdb = jsonfile.load('songs.json') self.cursong = os.path.join('nowplaying.json') size = len(self.songdb) self.last = size - 1 self.random = list(range(size)) random.shuffle(self.random) self.index = 0
def PUT(self): newdata = cherrypy.request.json data = jsonfile.load(self.config) if MIXER in newdata: data[MIXER] = newdata[MIXER] jsonfile.save(self.config, data)
def get_songs(config): data = jsonfile.load(config) songs = {} for path in data['directories']: recurse = data['directories'][path] songs[path] = find_mp3s(path, recurse) return songs
def PUT(self): newdata = cherrypy.request.json data = jsonfile.load(self.config) cherrypy.log(str(newdata)) # if os.path.exists(new): # data['directories'][new] = recurse data['directories'] = newdata jsonfile.save(self.config, data)
def GET(self, pattern=None): songs_file = 'songs.json' if not os.path.isfile(songs_file): return {} songs = jsonfile.load(songs_file) ordered = sorted(songs.items(), key=lambda s: s[1]['song']) songlist = {} for song in ordered: if pattern == None or \ re.compile(pattern, re.IGNORECASE).search(song[1]['song']): # cherrypy.log(str(song)) songlist[song[0]] = song[1] return songlist
def GET(self): data = jsonfile.load(self.config) dirs = data['directories'] if 'directories' in data else {} return dirs
def GET(self): data = jsonfile.load(self.config) mixer_path = data[MIXER] if MIXER in data else '' return {MIXER: mixer_path}
def __init__(self, config): self.data = jsonfile.load(config)