Exemplo n.º 1
0
Arquivo: tag.py Projeto: stassats/mm
def main():
    options, args = parse_opt()

    file_list = get_file_list(args)

    if not file_list:
        exit()

    tag_list = read_tags(file_list)

    if options.tracklist:
        for tag in tag_list:
            print str(tag.number) + ".", tag.title
        exit()

    if (len(sys.argv) - len(args) == 1):
        map(Tag.display_tag, tag_list)
        exit()

    if options.mb_id:
        mb_data = get_mb_data(options.mb_id)

    if options.cue_file:
        import cue
        cue_data = cue.parse_cue(options.cue_file)

    for tag in tag_list:
        if options.set_year:
            tag.set_year()

        if options.set_num:
            tag.set_number()

        if tag.number:
            tag.number = tag.number - int(options.shift)

        if options.rem_tag:
            remove_tag(tag.file)

        if options.mb_id:
            set_mb_data(tag, mb_data)

        if options.cue_file:
            set_from_cue(tag, cue_data)

        if options.set_tit:
            tag.set_title()

        if options.set_album:
            tag.set_album()
        elif options.Album:
            tag.album = unicode(options.Album, 'utf-8')

        if options.Title:
            tag.title = unicode(options.Title, 'utf-8')

        if options.Artist:
            tag.artist = unicode(options.Artist, 'utf-8')

        if options.Year:
            tag.year = unicode(options.Year, 'utf-8')

        if options.Number:
            tag.number = int(options.Number)

        if not options.mb_id and options.cap_tag:
            tag.lower_articles()

        if not options.mb_id and options.cap_all:
            tag.capitalize()

    if options.mb_guess:
        guess_mb_release(tag_list)

    if options.rename:
        rename_files(tag_list)

    for tag in tag_list:
        tag.write_tag()