Package: jack / 3.1.1+cvs20050801-31

33_flac_mutagen.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From: Joe Wreschnig <piman@sacredchao.net>

Attached is a patch to jack_init.py and jack_tag.py to make them use
Mutagen rather than pyflac.  Mutagen exposes the stream info as
f.info.{sample_rate,total_samples}, similar to pyflac. [pyflac is no longer
maintained]


--- a/jack_init.py
+++ b/jack_init.py
@@ -62,7 +62,7 @@
     ogg = dummy_ogg()
 
 try:
-    import flac.metadata
+    import mutagen.flac as flac
 except ImportError:
     flac = None
 
--- a/jack_tag.py
+++ b/jack_tag.py
@@ -150,31 +150,20 @@
                         mp3file.close()
                 elif jack_helpers.helpers[cf['_encoder']]['target'] == "flac":
                     if flac:
-                        chain = flac.metadata.Chain()
-                        chain.read(mp3name)
-                        it = flac.metadata.Iterator()
-                        it.init(chain)
-                        while 1:
-                            if it.get_block_type() == flac.metadata.VORBIS_COMMENT:
-                                block = it.get_block()
-                                vc = flac.metadata.VorbisComment(block)
-                                break
-                            if not it.next():
-                                break
-                        if vc:
-                            vc.comments['ALBUM'] = a_title.encode("utf-8")
-                            vc.comments['TRACKNUMBER'] = `i[NUM]`
-                            vc.comments['TITLE'] = t_name.encode("utf-8")
-                            vc.comments['ARTIST'] = t_artist.encode("utf-8")
-                            if cf['_id3_genre'] != -1:
-                                vc.comments['GENRE'] = id3genres[cf['_id3_genre']]
-                            if cf['_id3_year'] != -1:
-                                vc.comments['DATE'] = `cf['_id3_year']`
-                            chain.write(True, True)
+                        f = flac.FLAC(mp3name)
+                        if f.vc is None: f.add_vorbiscomment()
+                        f.vc['ALBUM'] = a_title
+                        f.vc['TRACKNUMBER'] = str(i[NUM])
+                        f.vc['TITLE'] = t_name
+                        f.vc['ARTIST'] = t_artist
+                        if cf['_id3_genre'] != -1:
+                            f.vc['GENRE'] = id3genres[cf['_id3_genre']]
+                        if cf['_id3_year'] != -1:
+                            f.vc['DATE'] = str(cf['_id3_year'])
+                        f.save()
                     else:
                         print
-                        print "Please install the pyflac module available at"
-                        print "http://www.sacredchao.net/quodlibet/wiki/Download"
+                        print "Please install python-mutagen package."
                         print "Without it, you'll not be able to tag FLAC tracks."
                 elif jack_helpers.helpers[cf['_encoder']]['target'] == "ogg":
                     vf = ogg.vorbis.VorbisFile(mp3name)