From: kaliko Date: Mon, 1 Feb 2010 23:07:21 +0000 (+0000) Subject: * fixes some typo in mfade X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=8e106468de2f526a5d15ef8de885ad79dd553847;p=mpd-goodies.git * fixes some typo in mfade * some enhancements in mtopls --- diff --git a/mfade b/mfade index c55e11f..813ab5f 100755 --- a/mfade +++ b/mfade @@ -36,12 +36,12 @@ USAGE = """Usage: mfade [time [min|max]] * time in seconds - * min|max in percentag + * min|max in percentage of volume when MPD is: -- not palying: fade in from 0% to max over time +- not playing: fade in from 0% to max over time default 10 minutes / 50% -- playing: fade out from current volume to min over time +- playing: fade out from current volume to min over time default 10 minutes / 1/10 of current vol Manual or any external volume change will abort the script. diff --git a/mtopls b/mtopls index e1d5dac..169ff80 100755 --- a/mtopls +++ b/mtopls @@ -33,8 +33,15 @@ USAGE = """Usage: mtopls [] [--help | -h | help] - If no playlist is specifed a new one is created in /var/lib/mpd/playlist/ - named after genre of current playlist. + Add the current track to playlist. + + The default playlist, if none specified, is named after the current track's + genre within /var/lib/mpd/playlists/ (creating it if not existing). + + Obviously the script is meant to be executed on hosts where + /var/lib/mpd/playlists/ makes sense or where file entries in the playlist + make sense for you (cf. "man 5 mpd.conf" especially + save_absolute_paths_in_playlists option). """ @@ -55,8 +62,7 @@ class MtoPls(object): def _consume_sopt(self): """""" - if len(sys.argv) > 2 or \ - len(sys.argv) == 2 and \ + if len(sys.argv) >= 2 and \ sys.argv[1] in ['-h', '--help', 'help']: sys.stdout.write(USAGE) sys.exit(1) @@ -64,7 +70,7 @@ class MtoPls(object): self.pls_path = sys.argv[1] if not dirname(self.pls_path): self.pls_path = abspath(sys.argv[1]) - sys.stdout.write('Playlist set to "%s"\n' % self.pls_path) + print >> sys.stdout, ('Playlist set to "%s"' % self.pls_path) return if len(sys.argv) == 1: self._set_playlist() @@ -81,9 +87,9 @@ class MtoPls(object): sys.exit(1) genre = self.current.get('genre', None) if not genre: - sys.stderr.write('Error: No genre set in %s' % + sys.stderr.write('Error: No genre set in %s\n' % self.current.get('file')) - sys.stdout.write('Please provide a playlist.') + print >> sys.stdout, ('Please provide a playlist.') sys.exit(1) genre += '.m3u' self.pls_path = join('/var/lib/mpd/playlists/', genre) @@ -91,7 +97,7 @@ class MtoPls(object): def _create_playlist(self): if not isfile(self.pls_path): # TODO: add M3U header - sys.stdout.write('Create new playlist: %s\n' % self.pls_path) + print >> sys.stdout, ('Create new playlist: %s' % self.pls_path) open(self.pls_path, 'a').close() def _controls_perm(self): @@ -108,11 +114,12 @@ class MtoPls(object): def _run(self): """""" - # TODO: controls file is not already in playlist + # TODO: controls either file is already in playlist or not + print >> sys.stdout, ('Writing to %s' % self.pls_path) fd = open(self.pls_path, 'a') fd.write(self.current.get('file')) - fd.write('\n') fd.close() + pass # Script starts here if __name__ == '__main__':