~berdario/mutagen/mutagen-py3

« back to all changes in this revision

Viewing changes to tools/mid3iconv

  • Committer: Dario Bertini
  • Date: 2012-09-04 15:10:33 UTC
  • Revision ID: berdario@gmail.com-20120904151033-6savz24cyq30bqb1
py3: updated the mutagen tools

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
    for filename in filenames:
49
49
        if verbose != "quiet":
50
 
            print "Updating", filename
 
50
            print("Updating", filename)
51
51
 
52
52
        if has_id3v1(filename) and not noupdate and force_v1:
53
53
            mutagen.id3.delete(filename, False, True)
55
55
        try: id3 = mutagen.id3.ID3(filename)
56
56
        except mutagen.id3.ID3NoHeaderError:
57
57
            if verbose != "quiet":
58
 
                print "No ID3 header found; skipping..."
 
58
                print("No ID3 header found; skipping...")
59
59
            continue
60
 
        except Exception, err:
61
 
            print >>sys.stderr, str(err)
 
60
        except Exception as err:
 
61
            print(str(err), file=sys.stderr)
62
62
            continue
63
63
 
64
 
        for tag in filter(lambda t: t.startswith("T"), id3):
 
64
        for tag in [t for t in id3 if t.startswith("T")]:
65
65
            frame = id3[tag]
66
66
            if isinstance(frame, mutagen.id3.TimeStampTextFrame):
67
67
                # non-unicode fields
71
71
            except AttributeError:
72
72
                continue
73
73
            try:
74
 
                text = map(conv, frame.text)
 
74
                text = list(map(conv, frame.text))
75
75
            except (UnicodeError, LookupError):
76
76
                continue
77
77
            else:
83
83
 
84
84
        enc = locale.getpreferredencoding()
85
85
        if verbose == "debug":
86
 
            print id3.pprint().encode(enc, "replace")
 
86
            print(id3.pprint().encode(enc, "replace"))
87
87
 
88
88
        if not noupdate:
89
89
            if remove_v1: id3.save(filename, v1=False)