So, I'm having a play about with writing a foobar plugin that updates tags.. I'm finding it pretty hard going because I'm a C# guy and the C++ ide is far less helpful, combined with my understanding of pointers/de/referencing being pretty ropey and the doxygen docs being a bit alien to me
When I use file_info_update_helper I get warnings about metadb_io being deprecated. I'm not entirely sure whether this is a problem; if there is a better method for me to use, I'd like to use it, but I can't figure out how to use metadb_io_v2::update_info_async_simple with lists/arrays of items (it's the other thing I want to do because right now, I just call it once per loop of all my items passing in pfc::list_single_ref_t - this means progress bars don't work and I just doesnt sit right with me as 'the right way to do it' )
If anyone could give me some guidance on using the recommended method, and how to pass a list of items I'd much apprecaite it.. Here's the crux of the code I've done for this:
CODE
void renumber_tracks(unsigned discnumber, metadb_handle_list items){
discnumber++;
file_info_impl finfo;
metadb_handle_ptr item;
int tmpint = 0;
int lowest = 9999;
int highest = -9999;
int numtrk = 0;
const char *tmpstrc;
//find the lowest track number here already
for(int i = 0; i < (int)items.get_count(); i++)
{
item = items.get_item(i);
item->get_info(finfo);
tmpstrc = finfo.meta_get("TRACKNUMBER", 0);
if(sscanf_s(tmpstrc, "%d", &tmpint) == EOF ) {
uMessageBox(NULL, "Cannot proceed: A track number is not numeric", "Problem", MB_OK | MB_ICONERROR);
return;
}
if(tmpint < lowest)
lowest = tmpint;
if(tmpint > highest)
highest = tmpint;
numtrk++;
}
char tmpstr[4];
for(int i = 0; i < (int)items.get_count(); i++)
{
item = items.get_item(i);
item->get_info(finfo);
tmpstrc = finfo.meta_get("TRACKNUMBER", 0);
if(sscanf_s(tmpstrc, "%d", &tmpint) == EOF ) {
uMessageBox(NULL, "Cannot proceed: A track number is not numeric", "Problem", MB_OK | MB_ICONERROR);
return;
}
tmpint -= lowest;
tmpint++;
sprintf_s(tmpstr, "%02d", tmpint);
finfo.meta_set("TRACKNUMBER", tmpstr);
//uMessageBox(NULL, tmpstr, "TRACKNUMBER", MB_OK);
sprintf_s(tmpstr, "%02d", discnumber);
finfo.meta_set("DISCNUMBER", tmpstr);
//uMessageBox(NULL, tmpstr, "DISCNUMBER", MB_OK);
sprintf_s(tmpstr, "%02d", numtrk);
finfo.meta_set("TOTALTRACKS", tmpstr);
//uMessageBox(NULL, tmpstr, "TOTALTRACKS", MB_OK);
static_api_ptr_t<metadb_io_v2>()->update_info_async_simple(
pfc::list_single_ref_t<metadb_handle_ptr>(item),
pfc::list_single_ref_t<const file_info*>(&finfo),
core_api::get_main_window(), NULL, NULL
);
}
}
discnumber++;
file_info_impl finfo;
metadb_handle_ptr item;
int tmpint = 0;
int lowest = 9999;
int highest = -9999;
int numtrk = 0;
const char *tmpstrc;
//find the lowest track number here already
for(int i = 0; i < (int)items.get_count(); i++)
{
item = items.get_item(i);
item->get_info(finfo);
tmpstrc = finfo.meta_get("TRACKNUMBER", 0);
if(sscanf_s(tmpstrc, "%d", &tmpint) == EOF ) {
uMessageBox(NULL, "Cannot proceed: A track number is not numeric", "Problem", MB_OK | MB_ICONERROR);
return;
}
if(tmpint < lowest)
lowest = tmpint;
if(tmpint > highest)
highest = tmpint;
numtrk++;
}
char tmpstr[4];
for(int i = 0; i < (int)items.get_count(); i++)
{
item = items.get_item(i);
item->get_info(finfo);
tmpstrc = finfo.meta_get("TRACKNUMBER", 0);
if(sscanf_s(tmpstrc, "%d", &tmpint) == EOF ) {
uMessageBox(NULL, "Cannot proceed: A track number is not numeric", "Problem", MB_OK | MB_ICONERROR);
return;
}
tmpint -= lowest;
tmpint++;
sprintf_s(tmpstr, "%02d", tmpint);
finfo.meta_set("TRACKNUMBER", tmpstr);
//uMessageBox(NULL, tmpstr, "TRACKNUMBER", MB_OK);
sprintf_s(tmpstr, "%02d", discnumber);
finfo.meta_set("DISCNUMBER", tmpstr);
//uMessageBox(NULL, tmpstr, "DISCNUMBER", MB_OK);
sprintf_s(tmpstr, "%02d", numtrk);
finfo.meta_set("TOTALTRACKS", tmpstr);
//uMessageBox(NULL, tmpstr, "TOTALTRACKS", MB_OK);
static_api_ptr_t<metadb_io_v2>()->update_info_async_simple(
pfc::list_single_ref_t<metadb_handle_ptr>(item),
pfc::list_single_ref_t<const file_info*>(&finfo),
core_api::get_main_window(), NULL, NULL
);
}
}
Comments/criticism welcome
Thanks!