Created
March 11, 2010 20:31
-
-
Save RJ/329612 to your computer and use it in GitHub Desktop.
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
Music library, search engine and scanner. | |
Implements the JSON-RPC musiclibrary protocol as outlined below. | |
NB: "id" field would be unique to each call (increment int, or use guid) | |
ADDING/REMOVING TRACKS FROM THE INDEX | |
------------------------------------- | |
>>> (no "id", thus no response sent) | |
{ | |
"jsonrpc" : "2.0", "method" : "add-tracks", | |
"params" : | |
[ | |
{ | |
"artist" : "Metallica", | |
"album" : "Metallica", | |
"track" : "The Unforgiven", | |
"path" : "/path/to/unforgiven.mp3", | |
"size" : 5301297, | |
"duration" : 420, | |
etc.. | |
}, | |
etc.. | |
] | |
} | |
>>> (no "id", thus no response sent) | |
{ | |
"jsonrpc" : "2.0", "method" : "remove-tracks", | |
"params" : [ "/path/to/unforgiven.mp3" ] | |
} | |
SEARCHING FOR A SPECIFIC TRACK | |
------------------------------ | |
NB: this is in RPC mode. Equally we could pass the QID, not specify an "id" and | |
require the recipient to respond by calling a void method we implement, which | |
allows async reporting of results multiple times (like current protocol) | |
>>> | |
{ | |
"jsonrpc" : "2.0", "id" : "1", "method" : "search-tracks", | |
"params" : { "artist" : "metallica", "album" : "", "track" : "unforgiven" } | |
} | |
<<< | |
{ "jsonrpc" : "2.0", "id" : "1", | |
"result" : [ | |
{ | |
"score" : 1.0, | |
"artist" : "Metallica", | |
"album" : "Metallica", | |
"track" : "The Unforgiven", | |
"path" : "/path/to/unforgiven.mp3", | |
"size" : 5301297, | |
"duration" : 420, | |
etc.. | |
}, | |
{ | |
"score" : 0.89, | |
"artist" : "Metallica", | |
"album" : "Metallica", | |
"track" : "The Unforgiven II", | |
"path" : "/path/to/unforgiven2.mp3", | |
etc.. | |
} | |
] | |
} | |
ENUMERATING THE LIBRARY | |
----------------------- | |
>>> | |
{ | |
"jsonrpc" : "2.0", "id" : "1", "method" : "stats" | |
} | |
<<< | |
{ "jsonrpc" : "2.0", "id" : "1", | |
"result" : | |
{ | |
"numtracks" : 123, | |
"lastmodified" : 1268338212, | |
etc.. | |
} | |
} | |
>>> | |
{ | |
"jsonrpc" : "2.0", "id" : "1", "method" : "list-artists" | |
} | |
<<< | |
{ "jsonrpc" : "2.0", "id" : "1", | |
"result" : | |
[ | |
"Abba", "Beethoven", "Eminem", "Metallica", etc.. | |
] | |
} | |
>>> | |
{ | |
"jsonrpc" : "2.0", "id" : "1", "method" : "list-works-by-artist", | |
"params" : "Metallica" | |
} | |
<<< | |
{ "jsonrpc" : "2.0", "id" : "1", | |
"result" : | |
{ | |
"albums" : [ "Metallica", "Load", "Reload" ], | |
"tracks" : | |
[ | |
{ | |
"artist" : "Metallica", | |
"album" : "Metallica", | |
"track" : "The Unforgiven", | |
"path" : "/path/to/unforgiven.mp3", | |
"size" : 5301297, | |
"duration" : 420, | |
etc.. | |
}, | |
{ | |
"artist" : "Metallica", | |
"album" : "Metallica", | |
"track" : "The Unforgiven II", | |
"path" : "/path/to/unforgiven2.mp3", | |
etc.. | |
}, | |
etc.. | |
] | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment