Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support ingesting tracks from /debug endpoint

  • Loading branch information...
commit 1325107e333af72a9ffceca708826da3b6dc80d4 1 parent 6ea272b
@jhurliman authored
View
16 controllers/debug.js
@@ -12,9 +12,9 @@ exports.debugQuery = function(req, res) {
if (!req.body || !req.body.json)
return server.renderView(req, res, 200, 'debug.jade', {});
- var code, codeVer;
+ var json, code, codeVer;
try {
- var json = JSON.parse(req.body.json)[0];
+ json = JSON.parse(req.body.json)[0];
code = json.code;
codeVer = json.metadata.version.toString();
} catch (err) {
@@ -25,7 +25,17 @@ exports.debugQuery = function(req, res) {
return server.renderView(req, res, 500, 'debug.jade',
{ err: 'Unrecognized input' });
}
-
+
+ if (req.body.Ingest) {
+ delete req.body.json;
+ req.body.code = code;
+ req.body.version = codeVer;
+ req.body.track = json.metadata.title;
+ req.body.length = json.metadata.duration;
+ req.body.artist = json.metadata.artist;
+ return require('./api').ingest(req, res);
+ }
+
fingerprinter.decodeCodeString(code, function(err, fp) {
if (err) {
log.error('Failed to decode codes for debug query: ' + err);
View
2  controllers/fingerprinter.js
@@ -308,7 +308,7 @@ function ingest(fp, callback) {
'", ' + fp.length + ' seconds, ' + fp.codes.length + ' codes (v' +
fp.codever + ')');
- if (!fp.codes.length || !fp.length || !fp.codever)
+ if (!fp.codes.length || typeof fp.length !== 'number' || !fp.codever)
return callback('Missing required track fields', null);
fp = cutFPLength(fp, MAX_DURATION);
View
1  views/debug.jade
@@ -37,6 +37,7 @@ html(lang="en")
| !{input}
br
input(type='submit', name='Lookup', value='Lookup')
+ input(type='submit', name='Ingest', value='Ingest')
h2#status
table#matches(border=1)
Please sign in to comment.
Something went wrong with that request. Please try again.