Ejemplo n.º 1
0
def main(argv):
    # Parse the command line options
    usage = '%prog [options] DIR'
    parser = optparse.OptionParser(usage=usage)
    (options, args) = parser.parse_args(argv[1:])

    if not args:
        parser.print_help(sys.stderr)
        print >> sys.stderr, 'no directory specified'
        return 1
    elif len(args) > 1:
        parser.print_help(sys.stderr)
        print >> sys.stderr, 'trailing arguments: %s' % (args[1:],)
        return 1

    dir = archive.AlbumDir(args[0])

    # Load the file list
    flac_files = file_util.find_files_by_suffix(dir.layout.getFlacDir(),
                                                '.flac')
    flac_files.sort()

    wav_dir = dir.layout.getWavDir()
    try:
        os.makedirs(wav_dir)
    except OSError, ex:
        if ex.errno != errno.EEXIST:
            raise
Ejemplo n.º 2
0
def main(argv):
    # Parse the command line options
    usage = '%prog [options] DIR'
    parser = optparse.OptionParser(usage=usage)
    parser.add_option('--no-tag',
                      action='store_false', dest='tag', default=True,
                      help='Do not tag the flac files')
    (options, args) = parser.parse_args(argv[1:])

    if not args:
        parser.print_help(sys.stderr)
        print >> sys.stderr, 'no directory specified'
        return 1
    elif len(args) > 1:
        parser.print_help(sys.stderr)
        print >> sys.stderr, 'trailing arguments: %s' % (args[1:],)
        return 1

    dir = archive.AlbumDir(args[0])

    # Load the file list
    if options.tag:
        with open(dir.layout.getMetadataInfoPath(), 'r') as f:
            dir.album.readTracks(f)

        info_list = archive.util.find_track_files(dir.layout.getWavDir(),
                                                  '.wav', dir.album)
    else:
        wav_files = file_util.find_files_by_suffix(dir.layout.getWavDir(),
                                                   '.wav')
        info_list = [archive.util.FileInfo(path, None)
                     for path in sorted(wav_files)]

    flac_dir = dir.layout.getFlacDir()
    try:
        os.makedirs(flac_dir)
    except OSError, ex:
        if ex.errno != errno.EEXIST:
            raise