Implementation of the JS plugins API from Tomahawk as a library for NodeJS and io.js.
It also features an executable
tomahawkjs which can be used to execute resolver functionality from the commandline without the need to write any code.
(This implementation is not fully feature complete compared to the desktop client but hubot-tomahk is an exmple usage of parts of it)
This utility supports calling the typical functionalities of a single resolver. While its main purpose is to support developing resolvers, you can use it also standalone. For example given the soundcloud resolver, you can build your own commandline (headless) soundcloud player with just this single commandline:
tomahawkjs resolve soundcloud.axe <artist> <title> | jq -r .url | xargs cvlc
Resolving a song using a given resolver can either be done with a bundled
.axe or a directory containing all the files as in a developemnt setting.
tomahawkjs resolve <path-to-resolver> <artist> <title> [<album>]
Search works similarily to resolving but you can specify an arbitrary number of commandline arfuments which will be joined together to form a single search query.
tomahawkjs search <path-to-resolver> <query-part1> [<query-part2> [..]]
To load a single resolver, we simply use the following code if we know the path to the .axe file:
var TomahawkJS = ;TomahawkJS;
As the time of writing, Tomahawk resolvers were all implicitly able to resolve from a combination of Artist and Title (and Albumname) to a stream URL if their feeding service provided this tune. Furthermore there are some other capabilities that can be implemented:
browsable: Resolver exposes a music collection that can be browsed.
playlistsync: Can sync playlists
urllookup: Can resolve from an URL to a combination of Artist+Title/Album/Playlist
Checking for one of these can be done via:
The main functionality of a Tomahawk resolver is to find a stremable URL for a combination of artist and song title and optionally an album. The requests for resolving should be indentified with a unqiue id for each query. Alternatively we can search a given string without specifying explicitly artist or title.
context;// Search for a streambale URL for song title by artist on album.instance;// Search for a streamable URL for a song similar to searchqueryinstance;
As an inverse for the lookup of (Artist, Title) -> stream-URL, many resolvers have the
urllookup capability to resolve from a URL pointing to a music service to artist/album/playlist/.. that is encoded in the URL.
// Define a handler for found URL mappingscontext;// Check if resolver has URLLookup capabilityif context// Can we handle this URL?if instanceinstance;
Resolver that have the
browsable capability export the whole collection of music material that can be streamed from them.
The browsing of the collection is done by pulling the relevant information on demand.
// Handler for the list of artists (string)context;// Handler for a list of albums (string)context;// Handler for a list of tracks for an albumcontent;if context// Get basic information about the collectionvar info = instance;// Not all collections support the retrieval of the total number of tracksif infotrackcount == nullconsole;elseconsole;// Query for the list of all artistsinstance;