Skip to content
Snippets Groups Projects
Commit c1bd992f authored by ale's avatar ale
Browse files

Merge branch 'master' of https://git.autistici.org/djrandom

parents 8c0ebe4a 4d5112d5
No related branches found
No related tags found
No related merge requests found
......@@ -24,32 +24,22 @@ class DeDuper(object):
self._engine = engine
self._resolver = Resolver()
def _generate_code_json(self, jsondata, track_id):
def _generate_code_json(self, echoprint_fp, sha1):
"""Parse the JSON string output of echoprint-codegen, and return
a structure that fp.ingest() can deal with.
Taken from 'fastingest.py', with minor changes.
"""
c = json.loads(jsondata)
if "code" not in c:
return {}
code = c["code"]
m = c["metadata"]
length = m["duration"]
version = m["version"]
artist = m.get("artist", None)
title = m.get("title", None)
release = m.get("release", None)
decoded = fp.decode_code_string(code)
data = {"track_id": track_id,
"fp": decoded,
"length": length,
"codever": "%.2f" % version}
if artist: data["artist"] = artist
if release: data["release"] = release
if title: data["track"] = title
c = json.loads(echoprint_fp)
if 'code' not in c:
return None
decoded = fp.decode_code_string(c['code'])
m = c['metadata']
data = {'track_id': sha1,
'fp': decoded,
'length': m['duration'],
'codever': '%.2f' % m['version']}
return data
def dedupe(self, dry_run=True):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment