Skip to content

Commit

Permalink
command/accurip: use new accurip module
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursiveForest committed Sep 7, 2017
1 parent a124047 commit 4126ec5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
18 changes: 8 additions & 10 deletions whipper/command/accurip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import sys

from whipper.command.basecommand import BaseCommand
from whipper.common import accurip
from whipper.common.accurip import get_db_entry, ACCURATERIP_URL

import logging
logger = logging.getLogger(__name__)
Expand All @@ -38,32 +38,30 @@ def add_arguments(self):
help="accuraterip URL to load data from")

def do(self):
url = self.options.url
cache = accurip.AccuCache()
responses = cache.retrieve(url)
responses = get_db_entry(self.options.url.lstrip(ACCURATERIP_URL))

count = responses[0].trackCount
count = responses[0].num_tracks

sys.stdout.write("Found %d responses for %d tracks\n\n" % (
len(responses), count))

for (i, r) in enumerate(responses):
if r.trackCount != count:
if r.num_tracks != count:
sys.stdout.write(
"Warning: response %d has %d tracks instead of %d\n" % (
i, r.trackCount, count))
i, r.num_tracks, count))

# checksum and confidence by track
for track in range(count):
sys.stdout.write("Track %d:\n" % (track + 1))
checksums = {}

for (i, r) in enumerate(responses):
if r.trackCount != count:
if r.num_tracks != count:
continue

assert len(r.checksums) == r.trackCount
assert len(r.confidences) == r.trackCount
assert len(r.checksums) == r.num_tracks
assert len(r.confidences) == r.num_tracks

entry = {}
entry["confidence"] = r.confidences[track]
Expand Down
3 changes: 2 additions & 1 deletion whipper/common/accurip.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
logger = logging.getLogger(__name__)


ACCURATERIP_URL = "http://www.accuraterip.com/accuraterip/"
_CACHE_DIR = join(directory.cache_path(), 'accurip')


Expand Down Expand Up @@ -131,7 +132,7 @@ def calculate_checksums(track_paths):


def _download_entry(path):
url = "http://www.accuraterip.com/accuraterip/" + path
url = ACCURATERIP_URL + path
logger.debug('downloading AccurateRip entry from %s', url)
try:
resp = requests.get(url)
Expand Down

0 comments on commit 4126ec5

Please sign in to comment.