Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tool to query the stream URL for (artist, track, album)
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|