[SCM] morituri/master: * examples/readdisc.py: Write .m3u file.

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:08:59 UTC 2014


The following commit has been merged in the master branch:
commit be1780f6585726df136345f144c7d513987f357f
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Sat May 16 07:31:52 2009 +0000

    	* examples/readdisc.py:
    	  Write .m3u file.

diff --git a/ChangeLog b/ChangeLog
index 6c5a33c..04b372b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-16  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+	* examples/readdisc.py:
+	  Write .m3u file.
+
 2009-05-15  Thomas Vander Stichele  <thomas at apestaart dot org>
 
 	* examples/readdisc.py:
diff --git a/examples/readdisc.py b/examples/readdisc.py
index 058965e..d1c61ec 100644
--- a/examples/readdisc.py
+++ b/examples/readdisc.py
@@ -254,10 +254,11 @@ def main(argv):
         print 'Found Hidden Track One Audio from frame %d to %d' % (start, stop)
             
         # rip it
-        path = getPath(options.track_template, metadata, -1) + '.wav'
-        if not os.path.exists(path):
-            print 'Ripping track %d: %s' % (0, os.path.basename(path))
-            t = cdparanoia.ReadVerifyTrackTask(path, ittoc,
+        htoapath = getPath(options.track_template, metadata, -1) + '.wav'
+        htoalength = stop - start
+        if not os.path.exists(htoapath):
+            print 'Ripping track %d: %s' % (0, os.path.basename(htoapath))
+            t = cdparanoia.ReadVerifyTrackTask(htoapath, ittoc,
                 start, stop - 1,
                 offset=int(options.offset))
             function(runner, t)
@@ -266,7 +267,7 @@ def main(argv):
             else:
                 print 'ERROR: checksums did not match for track %d' % 0
             # overlay this rip onto the IndexTable
-        itable.setFile(1, 0, path, stop - start, 0)
+        itable.setFile(1, 0, htoapath, htoalength, 0)
 
 
     for i, track in enumerate(itable.tracks):
@@ -305,6 +306,24 @@ def main(argv):
     handle.write(itable.cue())
     handle.close()
 
+    # write .m3u file
+    m3uPath = '%s.m3u' % discName
+    handle = open(m3uPath, 'w')
+    handle.write('#EXTM3U\n')
+    if htoapath:
+        handle.write('#EXTINF:%d,%s\n' % (
+            htoalength / checksum.FRAMES_PER_SECOND,
+                os.path.basename(htoapath[:-4])))
+        handle.write('%s\n' % os.path.basename(htoapath))
+
+    for i, track in enumerate(itable.tracks):
+        path = getPath(options.track_template, metadata, i) + '.wav'
+        handle.write('#EXTINF:%d,%s\n' % (
+            itable.getTrackLength(i + 1) / checksum.FRAMES_PER_SECOND,
+            os.path.basename(path)))
+        handle.write('%s\n' % os.path.basename(path))
+    handle.close()
+
     # verify using accuraterip
     print "CDDB disc id", itable.getCDDBDiscId()
     print "MusicBrainz disc id", itable.getMusicBrainzDiscId()
@@ -343,24 +362,24 @@ def main(argv):
     response = None # track which response matches, for all tracks
 
     # loop over tracks
-    for i, checksum in enumerate(cuetask.checksums):
+    for i, sum in enumerate(cuetask.checksums):
         status = 'rip NOT accurate'
 
         confidence = None
-        archecksum = None
+        arsum = None
 
         # match against each response's checksum
         for j, r in enumerate(responses):
-            if "%08x" % checksum == r.checksums[i]:
+            if "%08x" % sum == r.checksums[i]:
                 if not response:
                     response = r
                 else:
                     assert r == response, \
                         "checksum %s for %d matches wrong response %d, "\
                         "checksum %s" % (
-                            checksum, i + 1, j + 1, response.checksums[i])
+                            sum, i + 1, j + 1, response.checksums[i])
                 status = 'rip accurate    '
-                archecksum = checksum
+                arsum = sum
                 confidence = response.confidences[i]
 
         c = "(not found)"
@@ -378,7 +397,7 @@ def main(argv):
 
                 ar = ", AR [%s]" % response.checksums[i]
         print "Track %2d: %s %s [%08x]%s" % (
-            i + 1, status, c, checksum, ar)
+            i + 1, status, c, sum, ar)
 
 
 

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list