Exemplo n.º 1
0
void metadb_handle_list_helper::sort_by_relative_path_partial(pfc::list_base_t<metadb_handle_ptr> & p_list,t_size base,t_size count)
{
	assert(base+count<=p_list.get_count());
	pfc::array_t<t_size> order; order.set_size(count);
	sort_by_relative_path_get_order_partial(p_list,base,count,order.get_ptr());
	p_list.reorder_partial(base,order.get_ptr(),count);
}
Exemplo n.º 2
0
void metadb_handle_list_helper::sort_by_pointer_remove_duplicates(pfc::list_base_t<metadb_handle_ptr> & p_list)
{
	t_size count = p_list.get_count();
	if (count>0)
	{
		sort_by_pointer(p_list);
		bool b_found = false;
		t_size n;
		for(n=0;n<count-1;n++)
		{
			if (p_list.get_item(n)==p_list.get_item(n+1))
			{
				b_found = true;
				break;
			}
		}

		if (b_found)
		{
			bit_array_bittable mask(count);
			t_size n;
			for(n=0;n<count-1;n++)
			{
				if (p_list.get_item(n)==p_list.get_item(n+1))
					mask.set(n+1,true);
			}
			p_list.remove_mask(mask);
		}
	}
}
Exemplo n.º 3
0
t_size file_move_helper::g_filter_dead_files_sorted(pfc::list_base_t<metadb_handle_ptr> & p_data,const pfc::list_base_const_t<const char*> & p_dead)
{
	bit_array_bittable mask(p_data.get_count());
	t_size found = g_filter_dead_files_sorted_make_mask(p_data,p_dead,mask);
	if (found > 0) p_data.remove_mask(mask);
	return found;
}
Exemplo n.º 4
0
void metadb_handle_list_helper::remove_duplicates(pfc::list_base_t<metadb_handle_ptr> & p_list)
{
	t_size count = p_list.get_count();
	if (count>0)
	{
		bit_array_bittable mask(count);
		pfc::array_t<t_size> order; order.set_size(count);
		order_helper::g_fill(order);

		p_list.sort_get_permutation_t(pfc::compare_t<metadb_handle_ptr,metadb_handle_ptr>,order.get_ptr());
		
		t_size n;
		bool found = false;
		for(n=0;n<count-1;n++)
		{
			if (p_list.get_item(order[n])==p_list.get_item(order[n+1]))
			{
				found = true;
				mask.set(order[n+1],true);
			}
		}
		
		if (found) p_list.remove_mask(mask);
	}
}
Exemplo n.º 5
0
void filterTracksByCloseTitle(const std::string& title, pfc::list_base_t<metadb_handle_ptr>& tracks)
{
	const t_size n = tracks.get_count();
	bit_array_bittable deleteMask(n);

	for(t_size i = 0; i < n; i++)
	{
		deleteMask.set(i, !doesTrackHaveSimilarTitle(title, tracks[i]));
	}

	tracks.remove_mask(deleteMask);
}
Exemplo n.º 6
0
void filterTracksByArtist(const std::string& artist, pfc::list_base_t<metadb_handle_ptr>& tracks)
{
	const t_size n = tracks.get_count();
	bit_array_bittable deleteMask(n);

	for(t_size i = 0; i < n; i++)
	{
		deleteMask.set(i, !isTrackByArtist(artist, tracks[i]));
	}

	tracks.remove_mask(deleteMask);
}
Exemplo n.º 7
0
t_size file_move_helper::g_filter_dead_files_sorted_make_mask(pfc::list_base_t<metadb_handle_ptr> & p_data,const pfc::list_base_const_t<const char*> & p_dead,bit_array_var & p_mask)
{
	t_size n, m = p_data.get_count();
	t_size found = 0;
	for(n=0;n<m;n++)
	{
		t_size dummy;
		bool dead = p_dead.bsearch_t(metadb::path_compare,p_data.get_item(n)->get_path(),dummy);
		if (dead) found++;
		p_mask.set(n,dead);
	}
	return found;
}
Exemplo n.º 8
0
// all tracks will be analysed; try to cut the size of the list down before calling.
metadb_handle_ptr getBestTrackByTitle(const std::string& title, const pfc::list_base_t<metadb_handle_ptr>& tracks)
{
	if(tracks.get_count() == 1)
	{
		console::info(("Only one version of " + title + " exists in library").c_str());
		return tracks[0];
	}

	console::info(("Finding best version of " + title + ". " + to_string(tracks.get_count()) + " candidates").c_str());

	metadb_handle_ptr bestTrack = 0;
	float bestTrackRating = std::numeric_limits<float>::min();

	for(t_size index = 0; index < tracks.get_count(); index++)
	{
		const float trackRating = calculateTrackRating(title, tracks[index]);

		console::info(("Rating: " + to_string(trackRating, 2) + ": " + tracks[index]->get_path()).c_str());

		if(trackRating >= 0.0f && trackRating > bestTrackRating)
		{
			bestTrackRating = trackRating;
			bestTrack = tracks[index];
		}
	}

	if(bestTrack == 0)
	{
		console::info(("Couldn't find a match for " + title).c_str());
	}
	else
	{
		console::info(("Picked track with rating: " + to_string(bestTrackRating, 2) + ": " + bestTrack->get_path()).c_str());
	}

	return bestTrack;
}
Exemplo n.º 9
0
static bool grab_items_by_path(pfc::list_base_t<metadb_handle_ptr> & p_out,const char * p_path,abort_callback & p_abort)
{
	try {
		pfc::string8 path;
		filesystem::g_get_canonical_path(p_path,path);
		p_out.remove_all();
		service_ptr_t<input_info_reader> reader;
		input_entry::g_open_for_info_read(reader,0,path,p_abort);

		static_api_ptr_t<metadb> l_metadb;
		
		const t_uint32 count = reader->get_subsong_count();
		for(t_uint32 n=0;n<count;n++) {
			p_abort.check_e();
			metadb_handle_ptr ptr;
			l_metadb->handle_create(ptr,make_playable_location(path,reader->get_subsong(n)));
			p_out.add_item(ptr);
		}

		return p_out.get_count() > 0;
	} catch(std::exception const &) {return false;}
}
Exemplo n.º 10
0
void metadb_handle_list_helper::sort_by_path(pfc::list_base_t<metadb_handle_ptr> & p_list)
{
	sort_by_format_partial(p_list,0,p_list.get_count(),"%path_sort%",0);
}