WIP, Remote Client/Server, cover art for tracks, TBT
This commit is contained in:
+26
-17
@@ -9,10 +9,32 @@
|
||||
namespace CoverArt {
|
||||
|
||||
std::vector<CoverArt>
|
||||
Grabber::getFromRelease(Release::pointer release)
|
||||
Grabber::getFromTrack(Track::pointer track)
|
||||
{
|
||||
std::vector<CoverArt> res;
|
||||
|
||||
try
|
||||
{
|
||||
Av::InputFormatContext input(track->getPath());
|
||||
|
||||
std::vector< std::vector<unsigned char> > pictures;
|
||||
input.getPictures(pictures);
|
||||
|
||||
BOOST_FOREACH(const std::vector<unsigned char>& picture, pictures)
|
||||
res.push_back( CoverArt("application/octet-stream", picture) );
|
||||
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
std::cerr << "Cannot get pictures: " << e.what();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<CoverArt>
|
||||
Grabber::getFromRelease(Release::pointer release)
|
||||
{
|
||||
// TODO
|
||||
// Check if there is an image file in the directory of the release
|
||||
// For now, just get the cover art from the first track of the release
|
||||
@@ -25,23 +47,10 @@ Grabber::getFromRelease(Release::pointer release)
|
||||
|
||||
if (firstTrack)
|
||||
{
|
||||
try
|
||||
{
|
||||
Av::InputFormatContext input(firstTrack->getPath());
|
||||
|
||||
std::vector< std::vector<unsigned char> > pictures;
|
||||
input.getPictures(pictures);
|
||||
|
||||
BOOST_FOREACH(const std::vector<unsigned char>& picture, pictures)
|
||||
res.push_back( CoverArt("application/octet-stream", picture) );
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
std::cerr << "Cannot get pictures: " << e.what();
|
||||
}
|
||||
return Grabber::getFromTrack(firstTrack);
|
||||
}
|
||||
|
||||
return res;
|
||||
else
|
||||
return std::vector<CoverArt>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user