def main(argv=None):
    argv = argv or sys.argv[1:]
    pargs = docopt(__doc__, argv, version=metadata.version_description)
    if pargs['--verbose']:
        logger.setLevel(logging.DEBUG)
    logger.debug(pargs)
    return extract_playcounts(pargs['<itunes_file>'])
Exemple #2
0
def main(argv=None):
    argv = argv or sys.argv[1:]
    pargs = docopt(__doc__, argv, version=metadata.version_description)
    if pargs['--verbose']:
        logger.setLevel(logging.DEBUG)
    logger.debug(pargs)
    filename_fields = [
        f.strip().lower() for f in pargs['--filename-fields'].split(",")]
    unmatched_fields = [f for f in filename_fields if f not in FIELDS]
    if len(unmatched_fields) > 0:
        logger.error("Unknown field: {0}".format(", ".join(unmatched_fields)))
        return 1
    with open(pargs['<csv_file>'], 'rU') as csv_in:
        reader = csv.DictReader(csv_in, delimiter=str(pargs['--csv-delim']))
        return multiplex_mp3s(
            pargs['<mp3_file>'],
            reader,
            filename_fields,
            pargs['--filename-delim'],
            pargs['<out_base>'],
            (not pargs['--dry-run'])
        )