-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: extract album image from ncm file
- Loading branch information
pnck
committed
Mar 4, 2021
1 parent
174c66b
commit 2fc4089
Showing
11 changed files
with
210 additions
and
107 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "stdafx.h" | ||
#include "album_art_extractor.h" | ||
#include "ncm_file.h" | ||
|
||
using namespace fb2k_ncm; | ||
|
||
bool ncm_album_art_extractor::is_our_path(const char *p_path, const char *p_extension) { | ||
return stricmp_utf8(p_extension, "ncm") == 0; | ||
} | ||
|
||
album_art_extractor_instance_ptr ncm_album_art_extractor::open(file_ptr p_filehint, const char *p_path, | ||
abort_callback &p_abort) { | ||
if (p_filehint.is_empty()) { | ||
if (is_our_path(p_path, pfc::string_extension(p_path).toString())) { | ||
filesystem::g_open_read(p_filehint, p_path, p_abort); | ||
} | ||
} | ||
auto _ncm_file = fb2k::service_new<ncm_file>(p_filehint, p_path); | ||
_ncm_file->parse(ncm_file::parse_contents::NCM_PARSE_ALBUM); | ||
auto album_arts = fb2k::service_new<album_art_extractor_instance_simple>(); | ||
auto image = album_art_data_impl::g_create(_ncm_file->image_data.data(), _ncm_file->image_data.size()); | ||
album_arts->set(album_art_ids::cover_front, image); | ||
// album_arts->set(album_art_ids::disc, image); | ||
return album_arts; | ||
} | ||
|
||
static service_factory_single_t<ncm_album_art_extractor> g_ncm_album_art_extractor; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include "stdafx.h" | ||
#include "ncm_file.h" | ||
#include "common/define.h" | ||
|
||
namespace fb2k_ncm | ||
{ | ||
|
||
class ncm_album_art_extractor : public album_art_extractor { | ||
public: | ||
// GUID get_guid() override; | ||
bool is_our_path(const char *p_path, const char *p_extension) override; | ||
album_art_extractor_instance_ptr open(file_ptr p_filehint, const char *p_path, | ||
abort_callback &p_abort) override; | ||
}; | ||
|
||
} // namespace fb2k_ncm |
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
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
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
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
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
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
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
Oops, something went wrong.