示例#1
0
void embeddedcue_metadata_manager::get_tag(file_info & p_info) const {
	if (!have_cuesheet()) {
		m_content.query_ptr((unsigned)0)->m_info.to_info(p_info);
		p_info.meta_remove_field("cuesheet");
	} else {
		cue_creator::t_entry_list entries;
		m_content.enumerate(__get_tag_cue_track_list_builder(entries));
		pfc::string_formatter cuesheet;
		cue_creator::create(cuesheet,entries);
		entries.remove_all();
		//parse it back to see what info got stored in the cuesheet and what needs to be stored outside cuesheet in the tags
		cue_parser::parse_full(cuesheet,entries);
		file_info_record output;

		
		

		{
			file_info_record::t_meta_map globals;
			//1. find global infos and forward them
			{
				field_name_list fields;
				m_content.enumerate(__get_tag__enum_fields_enumerator(fields));
				fields.enumerate(__get_tag__filter_globals(m_content,globals));
			}
			
			output.overwrite_meta(globals);

			//2. find local infos
			m_content.enumerate(__get_tag__local_field_filter(globals,output.m_meta));
		}
		

		//strip redundant titles and tracknumbers that the cuesheet already contains
		for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ++iter) {
			strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"tracknumber");
			strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"title");
		}


		//add tech infos etc

		{
			const track_record * rec = m_content.query_ptr((unsigned)0);
			if (rec != NULL) {
				output.set_length(rec->m_info.get_length());
				output.set_replaygain(rec->m_info.get_replaygain());
				output.overwrite_info(rec->m_info.m_info);
			}
		}
		output.meta_set("cuesheet",cuesheet);
		output.to_info(p_info);
	}
}
示例#2
0
bool TagWriter::apply_filter(metadb_handle_ptr p_location, t_filestats p_stats, file_info & p_info) {
	try {
		auto tags = files[p_location];
		for (auto tag = tags.first(); tag.is_valid(); tag++) {
			// TODO: return false if all info is identical
			p_info.meta_remove_field(tag->m_key);
			// TODO: text multivalues
			tag->m_value.for_each([&](pfc::string8 &value) {
				if (!value.is_empty()) {
					p_info.meta_add(tag->m_key, value);
				}
			});
		}
		return true;
	} catch (pfc::exception_map_entry_not_found) {
		return false;
	}
}