#!/usr/bin/python # vim:syntax=python # This file is maintained at http://git.mdcc.cx/draai # draai - Joost van Baal-Ilić's music playing stuff # copyright: COPYRIGHT='Copyright (C) 2005 Joost van Baal' # This program is freely distributable per the following license: LICENSE="""\ This file is part of draai. Draai is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, as published by the Free Software Foundation on http://www.gnu.org/licenses/gpl.html . You should have received a copy of the GNU General Public License along with this file. There is NO warranty.""" VERSION='@VERSION@' import os import sys from optparse import OptionParser drDefaultPLDir = os.environ['HOME'] + "/.draai/playlist" drDefaultPLFile = drDefaultPLDir + "/default" drDefaultNextPLFile = drDefaultPLDir + "/next" drDefaultNumber = 20 # FIXME "import *" from draai import drDefault, drNext, drNice, drRadio, drDraai version='%prog ' + VERSION parser = OptionParser(usage="%prog [options] [next|nice|radio] [audiofile [audiofile...]]", version=version) # -h and --help work automagically # parser.add_option("-f", "--file", dest="filename", # help="write report to FILE", metavar="FILE") parser.add_option("-q", "--quiet", action="store_false", dest="verbose", default=True, help="don't print status messages to stdout") parser.add_option("-S", "--noshuffle", action="store_false", dest="shuffle", default=True, help="don't shuffle tracks") parser.add_option("-p", "--playlistfile", action="append", dest="playlists", help="playlist file, -p can be supplied more than once") parser.add_option("-n", "--number", type="int", dest="n", default=drDefaultNumber, help="number of tracks") parser.add_option("-l", "--license", action="store_true", help="show license and exit") (options, args) = parser.parse_args() if options.license: parser.print_version() print '\n' + COPYRIGHT + '\n\n' + LICENSE sys.exit() elif options.verbose: # print "reading \%s..." \% options.filename # FIXME pass if not options.playlists: options.playlists = [drDefaultPLFile] if not args: # draai (no action, no args) ( muziekje ) drDefault(plfiles=options.playlists, n=options.n, shuffle=options.shuffle) elif args[0] == "next": # next ( muziekjes_next_of_all ) drNext(plfile=drDefaultNextPLFile, n=options.n) elif args[0] == "nice": # nice ( muziekjes_nice ) # takes nicevalue and audiofiles as args FIXME drNice(args[1:], plfiles=options.playlists, n=options.n, shuffle=options.shuffle) elif args[0] == "radio": # radio ( muziekje_van_de_radio ) drRadio() else: # no action specified, interpret args as list of audiofiles drDraai(args, n=options.n, shuffle=options.shuffle) sys.exit # to be implemented actions # # ( muziekje_ma ) # ( muziekje_ma2 ) # draai -n ( muziekjes ) (plays from default playlist) # # echo foo.ogg bar.mp3 | draai # draai < songlist # pick ( muziekjes_pick_from ) # takes nof tracks and audiofiles as args FIXME : just use default