#!/usr/bin/env python # The Ripoff command-line interface, implemented with Optik. from optik import Option, OptionParser import ripoff from ripoff import cdrom # Define all the options. The other way to do this is with # a bunch of calls to parser.add_option(), after the parser # has been created. option_list = [ # verbosity options Option("-v", action="count", dest="verbose", help="increase verbosity level"), Option("--verbose", type="int", metavar="V", help="set verbosity level to V"), Option("-q", "--quiet", action="store_const", const=0, dest="verbose", help="run silently (verbosity = 0)"), Option("-d", "--device", help="device file to open (default: %s on this platform)" % cdrom.get_default_device()), Option("-b", "--output-base", metavar="DIR", help="base output dir"), Option("-t", "--tracks", help="tracks to rip (default: all) (example: 1,2-5,8)"), Option("-p", "--use-pipes", "--synchronous", action="store_true", dest="use_pipes", help="use named pipes for intermediate output " "(uses less temporary disk space, works great " "if encoding is faster than ripping) [default]"), Option("-f", "--use-files", "--asynchronous", action="store_false", dest="use_pipes", help="use real files for intermediate output (uses more " "temporary disk space, but should be more reliable " "if ripping is faster than encoding, and will free " "up your CD-ROM drive sooner)"), Option("-k", "--keep-tmp", action="store_true", help="put temporary (.wav) files in output dir, and don't " "delete them when done with them (implies -f)"), Option("-R", "--rip-only", action="store_true", help="just do digital audio extraction -- no encoding " "(implies -k, -f)"), Option("-P", "--playback", action="store_true", help="play encoded audio files as encoding proceeds"), Option("-e", "--eject", action="store_true", help="eject CD when finished"), # tagging/naming options Option("-A", "--artist", help="use ARTIST for tagging and file naming " "(overrides CDDB/CDindex)"), Option("-L", "--album", help="use ALBUM for tagging and file naming"), Option("-D", "--disc", type="int", help="set disc number to DISC (for multi-disc sets)"), Option("-y", "--year", help="use YEAR for tagging"), Option("--offset", type="int", dest="track_offset", default=0, metavar="OFFSET", help="add OFFSET to track numbers for tagging and file naming"), ] # Create the option parser and parse the command line. parser = OptionParser(option_list=option_list, version="ripoff %s" % ripoff.__version__) (options, args) = parser.parse_args() if args: parser.error("too many arguments") # Print the option values. from pprint import pprint print "options:" pprint(vars(options))