Mercurial > code > home > repos > light9
changeset 423:2b2f5da47c5d
config file now lists paths in the same form you'd give to mpd. New cmdline on ascoltami to specify the song list from config.n3
author | drewp@bigasterisk.com |
---|---|
date | Mon, 09 Jun 2008 07:07:10 +0000 |
parents | c7766729921a |
children | 295e803f6a5e |
files | bin/ascoltami light9/showconfig.py |
diffstat | 2 files changed, 25 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/ascoltami Mon Jun 09 07:06:31 2008 +0000 +++ b/bin/ascoltami Mon Jun 09 07:07:10 2008 +0000 @@ -36,10 +36,11 @@ from optparse import OptionParser import os,math,time +from rdflib import URIRef import Tkinter as tk -#import logging -#log = logging.getLogger() -#log.setLevel(logging.DEBUG) +import logging +log = logging.getLogger() +log.setLevel(logging.DEBUG) from twisted.internet import reactor,tksupport from twisted.internet.error import CannotListenError @@ -109,7 +110,9 @@ def __init__(self): self.mpd = Mpd() - reactor.connectTCP(*(networking.mpdServer()+(self.mpd,))) + args = (networking.mpdServer()+(self.mpd,)) + log.info("connecting to %r", args) + reactor.connectTCP(*args) self.state = tk.StringVar() self.state.set("stop") # 'stop' 'pause' 'play' @@ -261,10 +264,10 @@ class GoButton: - def __init__(self, player, statusLabel, songPaths): + def __init__(self, player, statusLabel, songURIs): self.player = player self.statusLabel = statusLabel - self.songPaths = songPaths + self.songURIs = songURIs self.player.current_time.trace("w", self.updateStatus) @@ -273,12 +276,11 @@ if state == 'stop': currentPath = self.player.song_uri try: - i = self.songPaths.index(currentPath) + 1 + i = self.songURIs.index(currentPath) + 1 except ValueError: i = 0 - nextPath = self.songPaths[i] - return ("next song %s" % shortSongPath(nextPath, - self.songPaths), + nextPath = self.songURIs[i] + return ("next song %s" % shortSongPath(nextPath, self.songURIs), lambda: self.player.play(nextPath)) if state == 'pause': @@ -493,12 +495,14 @@ def main(): global graph parser = OptionParser() + parser.add_option('--show', + help='show URI, like http://light9.bigasterisk.com/show/dance2008') graph = showconfig.getGraph() (options, songfiles) = parser.parse_args() if len(songfiles)<1: graph = showconfig.getGraph() - playList = graph.value(L9['show/dance2007'], L9['playList']) + playList = graph.value(URIRef(options.show), L9['playList']) songs = list(graph.items(playList)) else: raise NotImplementedError("don't know how to make rdf song nodes from cmdline song paths")
--- a/light9/showconfig.py Mon Jun 09 07:06:31 2008 +0000 +++ b/light9/showconfig.py Mon Jun 09 07:07:10 2008 +0000 @@ -54,10 +54,11 @@ raise ValueError("can't find music_directory in any mpd config file") +def songInMpd(song): + """ + get the mpd path (with correct encoding) from the song URI -def songInMpd(song): - - """mpd only works off its own musicroot, which for me is + mpd only works off its own musicroot, which for me is /my/music. song is a file in musicDir; this function returns a version starting with the mpd path, but minus the mpd root itself. the mpc ~/.mpdconf @@ -67,20 +68,15 @@ assert isinstance(song, URIRef), "songInMpd now takes URIRefs" - mpdHome = findMpdHome() - - songFullPath = songOnDisk(song) - if not songFullPath.startswith(mpdHome): - raise ValueError("the song path %r is not under your MPD music_directory (%r)" % (songFullPath, mpdHome)) - - mpdRelativePath = songFullPath[len(mpdHome):] - if path.join(mpdHome, mpdRelativePath) != songFullPath: - raise ValueError("%r + %r doesn't make the songpath %r" % (mpdHome, mpdRelativePath, songFullPath)) - return mpdRelativePath.encode('ascii') + mpdPath = getGraph().value(song, L9['showPath']) + if mpdPath is None: + raise ValueError("no mpd path found for subject=%r" % song) + return mpdPath.encode('ascii') def songOnDisk(song): + """given a song URI, where's the on-disk file that mpd would read?""" graph = getGraph() - songFullPath = path.join(root(), graph.value(song, L9['showPath'])) + songFullPath = path.join(findMpdHome(), graph.value(song, L9['showPath'])) return songFullPath def songFilenameFromURI(uri):