This is the documentation for libcoverart, a library for retrieving coverart from the Covert Art Archive. The main entry point to the library is the CoverArtArchive::CCoverArt object.
For details of the C interface, see the documentation for the file caa_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 libcoverart --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 -lcoverart -lm -lstdc++
- Compiling and Linking
A brief example showing how to retrieve the 'front' artwork for a release
try
{
std::vector<unsigned char> ImageData=CoverArt.FetchFront(ReleaseID);
if (ImageData.size())
{
std::stringstream FileName;
FileName << ReleaseID << "-front.jpg";
std::cout << "Saving front to '" << FileName.str() << "'" << std::endl;
std::ofstream Front(FileName.str().c_str());
Front.write((const char *)&ImageData[0],ImageData.size());
Front.close();
}
}
{
std::cout <<
"Connection Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << CoverArt.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << CoverArt.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << CoverArt.LastErrorMessage() << std::endl;
}
{
std::cout <<
"Timeout Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << CoverArt.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << CoverArt.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << CoverArt.LastErrorMessage() << std::endl;
}
{
std::cout <<
"Authentication Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << CoverArt.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << CoverArt.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << CoverArt.LastErrorMessage() << std::endl;
}
{
std::cout <<
"Fetch Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << CoverArt.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << CoverArt.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << CoverArt.LastErrorMessage() << std::endl;
}
{
std::cout <<
"Request Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << CoverArt.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << CoverArt.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << CoverArt.LastErrorMessage() << std::endl;
}
{
std::cout <<
"ResourceNotFound Exception: '" << Error.
what() <<
"'" << std::endl;
std::cout << "LastResult: " << CoverArt.LastResult() << std::endl;
std::cout << "LastHTTPCode: " << CoverArt.LastHTTPCode() << std::endl;
std::cout << "LastErrorMessage: " << CoverArt.LastErrorMessage() << std::endl;
}