Skip to content

Commit

Permalink
Add tool to query the stream URL for (artist, track, album)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhochy committed Nov 7, 2014
1 parent 53a57ca commit a5bf3af
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tools/getstreamurl.js
@@ -0,0 +1,50 @@
var argv = require('minimist')(process.argv.slice(2));
var utils = require('../test/utils.js');

if (argv._.length < 1) {
console.error("Please specify a single resolver");
process.exit(1);
}

if (argv._.length < 3) {
console.error("You need to specify at least an artist and a track for resolving.");
process.exit(1);
}

// We use the string argument as the path to the resolver.
var resolverPath = argv._[0];
var artist = argv._[1];
var track = argv._[2];
var album = "";

if (argv._.length > 3) {
album = argv._[3];
}

// All -/-- arguments will be added to the config.
// If --config is specified, we will instead load them from the config file.
var resolverConfig = argv;
if (argv.hasOwnProperty("config")) {
// FIXME: Add support for absolute paths
resolverConfig = require("../" + argv.config);
} else {
delete resolverConfig._;
}

var resolver = {};

utils.loadAxe(resolverPath, resolver, function () {
// Use once instead of on here to only handle the first result.
resolver.context.once('track-result', function (qid, result) {
if (resolver.context.Tomahawk.hasCustomUrlHandler) {
resolver.context.getStreamUrl(2, result.url);
} else {
console.log(result.url);
}
});
resolver.context.once('stream-url', function (qid, url) {
console.log(url);
});
resolver.instance.resolve("qid", artist, album, track);
}, resolverConfig);

0 comments on commit a5bf3af

Please sign in to comment.