[SCM] morituri/master: based on code by: Loïc Minier <lool at dooz.org> * morituri/rip/Makefile.am: * morituri/rip/main.py: * morituri/rip/accurip.py (added): Add a rip accurip show command to show the accuraterip information for a given URL. See #5.

js at users.alioth.debian.org js at users.alioth.debian.org
Sun Oct 19 20:09:25 UTC 2014


The following commit has been merged in the master branch:
commit ac66d71e6b5c66016ddafc8da8da293fe28f52ba
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date:   Sun May 22 18:06:57 2011 +0000

    	based on code by: Loïc Minier <lool at dooz.org>
    	* morituri/rip/Makefile.am:
    	* morituri/rip/main.py:
    	* morituri/rip/accurip.py (added):
    	  Add a rip accurip show command to show the accuraterip information
    	  for a given URL.  See #5.

diff --git a/ChangeLog b/ChangeLog
index aa152fa..a7f41a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2011-05-22  Thomas Vander Stichele  <thomas at apestaart dot org>
 
+	based on code by: Loïc Minier <lool at dooz.org>
+
+	* morituri/rip/Makefile.am:
+	* morituri/rip/main.py:
+	* morituri/rip/accurip.py (added):
+	  Add a rip accurip show command to show the accuraterip information
+	  for a given URL.  See #5.
+
+2011-05-22  Thomas Vander Stichele  <thomas at apestaart dot org>
+
 	* morituri/image/table.py:
 	  Extract one function to write a FILE line.
 
diff --git a/morituri/rip/Makefile.am b/morituri/rip/Makefile.am
index 7ed18ca..82f6dcb 100644
--- a/morituri/rip/Makefile.am
+++ b/morituri/rip/Makefile.am
@@ -4,6 +4,7 @@ morituridir = $(PYTHONLIBDIR)/morituri/rip
 
 morituri_PYTHON = \
 	__init__.py \
+	accurip.py \
 	cd.py \
 	drive.py \
 	image.py \
diff --git a/morituri/rip/accurip.py b/morituri/rip/accurip.py
new file mode 100644
index 0000000..a9d3be7
--- /dev/null
+++ b/morituri/rip/accurip.py
@@ -0,0 +1,93 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+# Morituri - for those about to RIP
+
+# Copyright (C) 2009 Thomas Vander Stichele
+
+# This file is part of morituri.
+# 
+# morituri is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# morituri is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with morituri.  If not, see <http://www.gnu.org/licenses/>.
+
+from morituri.common import logcommand, accurip
+
+class Show(logcommand.LogCommand):
+    summary = "show accuraterip data"
+
+    def do(self, args):
+
+        try:
+            url = args[0]
+        except IndexError:
+            self.stdout.write('Please specify an accuraterip URL.\n')
+            return 3
+
+        cache = accurip.AccuCache()
+        responses = cache.retrieve(url)
+
+        count = responses[0].trackCount
+
+        self.stdout.write("Found %d responses for %d tracks\n\n" % (
+            len(responses), count))
+
+        for (i, r) in enumerate(responses):
+            if r.trackCount != count:
+                self.stdout.write(
+                    "Warning: response %d has %d tracks instead of %d\n" % (
+                        i, r.trackCount, count))
+
+
+        # checksum and confidence by track
+        tracks = []
+        for track in range(count):
+            self.stdout.write("Track %d:\n" % (track + 1))
+            checksums = {}
+
+            for (i, r) in enumerate(responses):
+                if r.trackCount != count:
+                    continue
+
+                assert len(r.checksums) == r.trackCount
+                assert len(r.confidences) == r.trackCount
+
+                entry = {}
+                entry["confidence"] = r.confidences[track]
+                entry["response"] = i + 1
+                checksum = r.checksums[track]
+                if checksum in checksums:
+                    checksums[checksum].append(entry)
+                else:
+                    checksums[checksum] = [entry, ]
+
+            # now sort track results in checksum by highest confidence
+            sortedChecksums = []
+            for checksum, entries in checksums.items():
+                highest = max(d['confidence'] for d in entries)
+                sortedChecksums.append((highest, checksum))
+
+            sortedChecksums.sort()
+            sortedChecksums.reverse()
+
+            for highest, checksum in sortedChecksums:
+                self.stdout.write("  %d result(s) for checksum %s: %s\n" % (
+                    len(checksums[checksum]), checksum,
+                    str(checksums[checksum])))
+
+
+class AccuRip(logcommand.LogCommand):
+    summary = "handle AccurateRip information"
+
+    subCommandClasses = [Show, ]
+
+
diff --git a/morituri/rip/main.py b/morituri/rip/main.py
index 464d148..69bae1e 100644
--- a/morituri/rip/main.py
+++ b/morituri/rip/main.py
@@ -4,7 +4,7 @@
 import sys
 
 from morituri.common import log, logcommand, common, task
-from morituri.rip import cd, offset, drive, image
+from morituri.rip import cd, offset, drive, image, accurip
 
 def main(argv):
     c = Rip()
@@ -46,7 +46,8 @@ Rip gives you a tree of subcommands to work with.
 You can get help on subcommands by using the -h option to the subcommand.
 """
 
-    subCommandClasses = [cd.CD, drive.Drive, offset.Offset, image.Image, ]
+    subCommandClasses = [accurip.AccuRip,
+        cd.CD, drive.Drive, offset.Offset, image.Image, ]
 
     def addOptions(self):
         # FIXME: is this the right place ?

-- 
morituri packaging



More information about the pkg-multimedia-commits mailing list