def artists(self): """ the controller for the artists frame """ try: self.m = g.p.connect() except (NoMPDConnection, ConnectionClosed): return render('/null.html') c.artists = self.m.artists() return render('/artists.html')
def artists(self): """ the controller for the artists frame """ try: self.m = g.p.connect() except (NoMPDConnection, ConnectionClosed): return render('/null.html') c.artists = self.m.artists() return render('./artists.html')
def streams(self,use_htmlfill=True,**kwargs): c.error = request.GET.get('error','') c.streams = g.tc.streams if use_htmlfill: return formencode.htmlfill.render(render("/streams.html"),{'name':kwargs.get('name',''), 'url':kwargs.get('url','')}) else: return render("/streams.html") return render('/streams.html')
def artists(self): """ the controller for the artists frame """ try: m = g.p.connect() except ConnectionClosed: return render('/null.html') c.artists = m.artists() return render('/artists.html')
def streams(self, use_htmlfill=True, **kwargs): c.error = request.GET.get('error', '') c.streams = g.tc.streams if use_htmlfill: return formencode.htmlfill.render(render("/streams.html"), {'name':kwargs.get('name',''), 'url':kwargs.get('url', '')}) else: return render("/streams.html") return render('/streams.html')
def stats(self): """ controller for the stats widget """ try: self.m = g.p.connect() except (NoMPDConnection, ConnectionClosed): return render('/null.html') c.stats = self.m.stats() aa = AlbumArt() c.dir_size = aa.dir_size() return render('/stats.html')
def stats(self): """ controller for the stats widget """ try: m = g.p.connect() except ConnectionClosed: return render('/null.html') c.stats = m.stats() aa = AlbumArt() c.dir_size = aa.dir_size() return render('/stats.html')
def tracks(self): """ controller for the tracks frame """ c.artist = request.GET.get('artist', '').encode('utf-8') c.album = request.GET.get('album', '').encode('utf-8') try: self.m = g.p.connect() except (NoMPDConnection, ConnectionClosed): return render('/null.html') c.tracks = self.m.tracks(c.artist, c.album) c.artist_safe = h.html.url_escape(c.artist) c.album_safe = h.html.url_escape(c.album) return render('/tracks.html')
def fs_status(self): """ similar to status() but includes a forward-looking playlist for the fullscreen widget """ try: self.m = g.p.connect() except ConnectionClosed: return render('/null.html') status = self.m.status() current = self.m.currentsong() playlist = self.m.playlistinfo() track = 0 found_current = False remaining_playlist = [] for pl in playlist: if found_current: remaining_playlist.append(pl) if 'id' in current: if pl['id'] == current['id']: found_current = True track += 1 #m.close() return dict(status=status,current=current,playlist=remaining_playlist)
def fs_status(self): """ similar to status() but includes a forward-looking playlist for the fullscreen widget """ try: self.m = g.p.connect() except ConnectionClosed: return render('/null.html') status = self.m.status() current = self.m.currentsong() playlist = self.m.playlistinfo() track = 0 found_current = False remaining_playlist = [] for pl in playlist: if found_current: remaining_playlist.append(pl) if 'id' in current: if pl['id'] == current['id']: found_current = True track += 1 #m.close() return dict(status=status, current=current, playlist=remaining_playlist)
def albums(self): """ controller for the albums frame """ c.artist = request.GET.get('artist', '').encode('utf-8') c.album = request.GET.get('album', '').encode('utf-8') try: self.m = g.p.connect() except (NoMPDConnection, ConnectionClosed): return render('/null.html') c.albums = self.m.albums(c.artist) aa = AlbumArt() c.album_imgs = aa.artist_art(c.artist) random.shuffle(c.album_imgs) return render('/albums.html')
def index(self): """ controller for the playlist frame """ try: self.m = g.p.connect() except NoMPDConnection: return render('/null.html') status = self.m.status() c.playlistid = status['playlist'] c.playlist = self.m.playlistinfo() info = self.m.lsinfo() c.available_playlists = [playlist['playlist'] for playlist in info if 'playlist' in playlist] c.available_playlists.insert(0,'') c.g = g return render('/playlist.html')
def search(self): searchtype = request.GET.get('searchtype','Artist') q = request.GET.get('q').encode('utf-8') if q and len(q) > 2: m = g.p.connect() results = m.search(searchtype,q) c.artists = set() c.albums = set() c.tracks = set() search_string = q.lower() for r in results: if 'artist' in r.keys() and search_string in r['artist'].lower(): c.artists.add(r['artist']) if 'album' in r.keys() and search_string in r['album'].lower(): c.albums.add((r['artist'], r['album'])) if 'title' in r.keys() and search_string in r['title'].lower(): c.tracks.add((r['artist'], r['album'], r['title'], r['file'])) return render('/search.html')
def albums(self): """ controller for the albums frame """ c.artist = request.GET.get('artist','').encode('utf-8') c.album = request.GET.get('album','').encode('utf-8') try: m = g.p.connect() except ConnectionClosed: return render('/null.html') c.albums = m.albums(c.artist) aa = AlbumArt() c.album_imgs = aa.artist_art(c.artist) random.shuffle(c.album_imgs) return render('/albums.html')
def tracks(self): """ controller for the tracks frame """ c.artist = request.GET.get('artist','').encode('utf-8') c.album = request.GET.get('album','').encode('utf-8') try: m = g.p.connect() except ConnectionClosed: return render('/null.html') c.tracks = m.tracks(c.artist,c.album) c.artist_safe = h.html.url_escape(c.artist) c.album_safe = h.html.url_escape(c.album) return render('/tracks.html')
def search(self): searchtype = request.GET.get('searchtype', 'Artist') q = request.GET.get('q').encode('utf-8') if q and len(q) > 2: self.m = g.p.connect() results = self.m.search(searchtype, q) c.artists = set() c.albums = set() c.tracks = set() search_string = q.lower() for r in results: if 'artist' in r.keys() and search_string in r['artist'].lower(): c.artists.add(r['artist']) if 'album' in r.keys() and search_string in r['album'].lower(): c.albums.add((r['artist'], r['album'])) if 'title' in r.keys() and search_string in r['title'].lower(): c.tracks.add((r['artist'], r['album'], r['title'], r['file'])) return render('/search.html')
def albums(self): """ controller for the albums frame """ c.artist = request.GET.get('artist', u'') c.album = request.GET.get('album', u'') try: self.m = g.p.connect() except (NoMPDConnection, ConnectionClosed): return render('/null.html') c.albums = self.m.albums(c.artist) aa = AlbumArt() c.album_imgs = aa.artist_art(c.artist) random.shuffle(c.album_imgs) return render('/albums.html')
def add_random(self): m = g.p.connect() files = request.POST.getall('file') for f in files: m.add(f.encode('utf-8')) c.content = '<script language="javascript">window.parent.frames[\'frmplaylist\'].location.reload();</script>' return render('/null.html')
def filesystem(self): m = g.p.connect() c.path = request.GET.get('path','/').encode('utf-8') c.lsinfo = m.lsinfo(c.path) c.uppath = '/'.join(c.path.split('/')[:-1]) return render('/filesystem.html')
def filesystem(self): self.m = g.p.connect() c.path = request.GET.get('path', '/').encode('utf-8') c.lsinfo = self.m.lsinfo(c.path) c.uppath = '/'.join(c.path.split('/')[:-1]) return render('/filesystem.html')
def add_random(self): self.m = g.p.connect() files = request.POST.getall('file') for f in files: self.m.add(f.encode('utf-8')) c.content = '<script language="javascript">window.parent.frames[\'frmplaylist\'].location.reload();</script>' return render('/null.html')
def randomizer(self): action = request.GET.get('action', '') c.incex = request.GET.get('incex', 'exclude') c.selected_genres = request.GET.getall('genres') c.exclude_live = request.GET.get('excludelive', not bool(len(action))) c.quantity = int(request.GET.get('quantity', 50)) c.genres = sorted(g.genres) if action: self.m = g.p.connect() c.random_tracks = self.m.get_random_tracks(c.incex, c.selected_genres, c.exclude_live, c.quantity) return render('/randomizer.html')
def randomizer(self): action = request.GET.get('action','') c.incex = request.GET.get('incex','exclude') c.selected_genres = request.GET.getall('genres') c.exclude_live = request.GET.get('excludelive',not bool(len(action))) c.quantity = int(request.GET.get('quantity',50)) c.genres = sorted(g.genres) if action: m = g.p.connect() c.random_tracks = m.get_random_tracks(c.incex,c.selected_genres,c.exclude_live,c.quantity) return render('/randomizer.html')
def document(self): """Render the error document""" resp = request.environ.get('pylons.original_response') if resp.status_int == 404: return render('/404.html') content = literal(resp.body) or cgi.escape(request.GET.get('message')) page = error_document_template % \ dict(prefix=request.environ.get('SCRIPT_NAME', ''), code=cgi.escape(request.GET.get('code', str(resp.status_int))), message=content) return page
def config(self, use_htmlfill=True): """ controller for the configuration iframe """ c.firsttime = request.GET.get('firsttime', '0') c.noconnection = request.GET.get('noconnection') c.error = request.GET.get('error') c.type = request.GET.get('type') configured_outputs = [] if c.firsttime == '0': try: self.m = g.p.connect() c.outputs = self.m.outputs() for o in c.outputs: if o['outputenabled'] == '1': key = 'enabled' else: key = 'disabled' configured_outputs.append({key: o['outputid']}) except ConnectionClosed: return render('/null.html') if use_htmlfill: values = formencode.variabledecode.variable_encode({'firsttime': c.firsttime, 'server':g.tc.server, 'port':g.tc.port, 'password':g.tc.password,'webpassword':g.tc.webpassword, 'awskey':g.tc.awskey,'timeout':g.tc.timeout, 'aws_secret':g.tc.aws_secret, 'lastfmkey':g.tc.lastfmkey, 'default_search':g.tc.default_search, 'outputs': configured_outputs}) return formencode.htmlfill.render(render("/config.html"), values) else: return render("/config.html")
def config(self, use_htmlfill=True): """ controller for the configuration iframe """ c.firsttime = request.GET.get('firsttime', '0') c.noconnection = request.GET.get('noconnection') c.error = request.GET.get('error') c.type = request.GET.get('type') configured_outputs = [] if c.firsttime == '0': try: self.m = g.p.connect() c.outputs = self.m.outputs() for o in c.outputs: if o['outputenabled'] == '1': key = 'enabled' else: key = 'disabled' configured_outputs.append({key: o['outputid']}) except ConnectionClosed: return render('/null.html') if use_htmlfill: values = formencode.variabledecode.variable_encode({'firsttime': c.firsttime, 'server':g.tc.server, 'port':g.tc.port, 'password':g.tc.password,'webpassword':g.tc.webpassword, 'awskey':g.tc.awskey,'timeout':g.tc.timeout, 'aws_secret':g.tc.aws_secret, 'default_search':g.tc.default_search, 'outputs': configured_outputs}) return formencode.htmlfill.render(render("/config.html"), values) else: return render("/config.html")
def submit(self): """ Verify password """ form_password = str(request.params.get('password')) if form_password != g.tc.webpassword: c.err = 1 return render('/login.html') # Mark user as logged in session['user'] = '******' session.save() redirect(url(controller='main', action='index'))
def submit(self): """ Verify password """ form_password = str(request.params.get('password')) if form_password != g.tc.webpassword: c.err = 1 return render('/login.html') # Mark user as logged in session['user'] = '******' session.save() redirect_to(controller='main')
def index(self): """ the main page controller! """ c.debug = request.GET.get('debug',0) try: g.p.connect() except (ProtocolError,ConnectionClosed): if g.tc.server is None: g.tc = TConfig() if g.tc.server is None: c.config = '/config?firsttime=1' else: c.config = '/config?noconnection=1' pass except IncorrectPassword: abort(401) return render('/index.html')
def index(self): """ the main page controller! """ c.debug = request.GET.get('debug', 0) c.config = '' try: self.m = g.p.connect() except (ProtocolError, ConnectionClosed, NoMPDConnection): if g.tc.server is None: g.tc = TConfig() if g.tc.server is None: c.config = '/config?firsttime=1' else: c.config = '/config?noconnection=1' pass except IncorrectPassword: abort(401) return render('/index.html')
def login(self): """ Show login form. Submits to /login/submit """ return render('/login.html')
def fullscreen(self): """ controller for the fullscreen widget """ return render('/fullscreen.html')
def genre(self): c.genre = request.GET.get('genre','') self.m = g.p.connect() c.tracks = self.m.search('Genre', c.genre) return render('/genre.html')
def genres(self): c.genres = sorted(g.genres) return render('/genres.html')
def genre(self): c.genre = request.GET.get('genre','') m = g.p.connect() c.tracks = m.search('Genre', c.genre) return render('/genre.html')