From e4f1f77101743187e18c7beda273b0a930deacab Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Fri, 28 Oct 2011 10:52:49 +0100
Subject: [PATCH] use cheap_dedup by default

---
 server/djrandom/fingerprint/cheap_dedup.py | 14 ++++++++++----
 server/djrandom/fingerprint/dedup.py       |  2 ++
 server/setup.py                            |  2 +-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/server/djrandom/fingerprint/cheap_dedup.py b/server/djrandom/fingerprint/cheap_dedup.py
index 296a349..b37ea4b 100644
--- a/server/djrandom/fingerprint/cheap_dedup.py
+++ b/server/djrandom/fingerprint/cheap_dedup.py
@@ -1,3 +1,5 @@
+"""Deduplicator that uses perfect fingerprint-matching (fast, cheap)."""
+
 import base64
 import os
 import optparse
@@ -57,7 +59,7 @@ class CheapDeDuper(object):
             if len(hashes) > 1:
                 self._dedup_songs([MP3.query.get(x) for x in hashes])
 
-    def dedupe(self, dry_run):
+    def dedupe(self):
         dupes = []
         last_mp3 = None
         mp3s = MP3.query.filter(
@@ -95,10 +97,13 @@ class CheapDeDuper(object):
         self._resolver.commit()
 
 
-def run_cheap_deduper(db_url, solr_url, dry_run):
+def run_cheap_deduper(db_url, solr_url, dry_run, use_fp):
     engine = init_db(db_url, solr_url)
     dup = CheapDeDuper()
-    dup.dedupe_fp(engine)
+    if use_fp:
+        dup.dedupe_fp(engine)
+    else:
+        dup.dedupe()
     if not dry_run:
         dup.commit()
 
@@ -108,6 +113,7 @@ def main():
     parser.add_option('--db_url')
     parser.add_option('--solr_url', default='http://localhost:8080/solr')
     parser.add_option('--apply', action='store_true')
+    parser.add_option('--use_meta', action='store_true')
     daemonize.add_standard_options(parser)
     utils.read_config_defaults(
         parser, os.getenv('DJRANDOM_CONF', '/etc/djrandom.conf'))
@@ -118,7 +124,7 @@ def main():
         parser.error('Too many arguments')
 
     daemonize.daemonize(opts, run_cheap_deduper,
-                        (opts.db_url, opts.solr_url, not opts.apply))
+                        (opts.db_url, opts.solr_url, not opts.apply, not opts.use_meta))
 
 
 if __name__ == '__main__':
diff --git a/server/djrandom/fingerprint/dedup.py b/server/djrandom/fingerprint/dedup.py
index 01aa1bc..daf8b89 100644
--- a/server/djrandom/fingerprint/dedup.py
+++ b/server/djrandom/fingerprint/dedup.py
@@ -1,3 +1,5 @@
+"""Deduplicator that uses a standalone Echoprint server instance."""
+
 import eyeD3
 import fp
 import os
diff --git a/server/setup.py b/server/setup.py
index 7cb08e7..55c3d5d 100644
--- a/server/setup.py
+++ b/server/setup.py
@@ -18,7 +18,7 @@ setup(
       "djrandom-receiver = djrandom.receiver.receiver:main",
       "djrandom-scanner = djrandom.scanner.scanner:main",
       "djrandom-fingerprinter = djrandom.fingerprint.fingerprint:main",
-      "djrandom-dedup = djrandom.fingerprint.dedup:main",
+      "djrandom-dedup = djrandom.fingerprint.cheap_dedup:main",
       "djrandom-streamer = djrandom.stream.stream:main",
       "djrandom-frontend = djrandom.frontend.frontend:main",
       "djrandom-update-markov = djrandom.model.markov:main",
-- 
GitLab