summaryrefslogtreecommitdiff
path: root/debian/patches/33_flac_mutagen.patch
blob: 58897d16f0b135b3d8337443edf133baa732bec5 (plain)
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
66
67
68
69
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]


diff -urN jack-3.1.1+cvs20050801~/jack_init.py jack-3.1.1+cvs20050801/jack_init.py
--- jack-3.1.1+cvs20050801~/jack_init.py	2006-02-05 15:09:07.000000000 +0100
+++ jack-3.1.1+cvs20050801/jack_init.py	2006-04-04 22:49:42.000000000 +0200
@@ -62,7 +62,7 @@
     ogg = dummy_ogg()
 
 try:
-    import flac.metadata
+    import mutagen.flac as flac
 except ImportError:
     flac = None
 
diff -urN jack-3.1.1+cvs20050801~/jack_tag.py jack-3.1.1+cvs20050801/jack_tag.py
--- jack-3.1.1+cvs20050801~/jack_tag.py	2006-04-04 22:59:44.000000000 +0200
+++ jack-3.1.1+cvs20050801/jack_tag.py	2006-04-04 22:59:10.000000000 +0200
@@ -153,31 +153,21 @@
                         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 the Mutagen module available at"
+                        print "http://www.sacredchao.net/quodlibet/wiki/Development/Mutagen"
                         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)