This is the documentation for libmusicbrainz5, a library for retrieving data from the MusicBrainz service. The main entry point to the library is the MusicBrainz5::CQuery object.
For details of the C interface, see the documentation for the file mb5_c.h.
Please report any issues with this library at http://tickets.musicbrainz.org/.
- Compiling and Linking
This package provides a pkg-config script that returns the necessary compiler and linker flags, as well as the version number. To build a small sample program one would use:
g++ -o test_app test_app.cpp pkg-config libmusicbrainz5 --cflags --libs
If you don't want/can't use pkg-config and you are using the C API, make sure you link in the C++ standard library:
gcc -o test_app test_app.c -lmusicbrainz5 -lm -lstdc++
- Example:
A brief example showing how to lookup a list of releases matching a disc id
try
{
{
std::cout <<
"Found " << ReleaseList->
NumItems() <<
" release(s)" << std::endl;
for (
int count=0;count<ReleaseList->
NumItems();count++)
{
std::cout << "Basic release: " << std::endl << *Release << std::endl;
Params["inc"]="artists labels recordings release-groups url-rels discids artist-credits";
Metadata=Query.Query(
"release",Release.
ID(),
"",Params);
{
std::cout << *FullRelease << std::endl;
}
}
}
}
{
std::cout <<
"Connection Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << Query.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << Query.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << Query.LastErrorMessage() << std::endl;
}
{
std::cout <<
"Timeout Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << Query.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << Query.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << Query.LastErrorMessage() << std::endl;
}
{
std::cout <<
"Authentication Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << Query.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << Query.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << Query.LastErrorMessage() << std::endl;
}
{
std::cout <<
"Fetch Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << Query.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << Query.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << Query.LastErrorMessage() << std::endl;
}
{
std::cout <<
"Request Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << Query.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << Query.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << Query.LastErrorMessage() << std::endl;
}
{
std::cout <<
"ResourceNotFound Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << Query.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << Query.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << Query.LastErrorMessage() << std::endl;
}