From cad1380737f7ffcfa82d46ab3066823435a48a5d Mon Sep 17 00:00:00 2001 From: Paul Arthur Date: Fri, 25 Jan 2013 20:49:16 -0500 Subject: Move duplicate searching from Catalog to Song Catalog::get_duplicate_songs() -> Song::find_duplicates() Catalog::get_duplicate_info() -> Song::get_duplicate_info() --- lib/class/catalog.class.php | 74 +++------------------------------------------ 1 file changed, 4 insertions(+), 70 deletions(-) (limited to 'lib/class/catalog.class.php') diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 9d38fdb9..0807a351 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -446,11 +446,11 @@ class Catalog extends database_object { /** * add_files - * Recurses through $this->path and pulls out all mp3s and returns the full - * path in an array. Passes gather_type to determin if we need to check id3 - * information against the db. + * Recurses through $this->path and pulls out all mp3s and returns the + * full path in an array. Passes gather_type to determine if we need to + * check id3 information against the db. */ - public function add_files($path,$options) { + public function add_files($path, $options) { // Profile the memory a bit debug_event('Memory', format_bytes(memory_get_usage(true)), 5); @@ -820,72 +820,6 @@ class Catalog extends database_object { } // get_disabled - /** - * get_duplicate_songs - * - * This function takes a search type and returns a list of likely - * duplicates. - */ - public static function get_duplicate_songs($search_type) { - $where_sql = $_REQUEST['search_disabled'] ? '' : "WHERE `enabled` != '0'"; - $sql = 'SELECT `id`, `artist`, `album`, `title`, ' . - 'COUNT(`title`) FROM `song` ' . $where_sql . - ' GROUP BY `title`'; - - if ($search_type == 'artist_title' || - $search_type == 'artist_album_title') { - $sql .= ',`artist`'; - } - if ($search_type == 'artist_album_title') { - $sql .= ',`album`'; - } - - $sql .= ' HAVING COUNT(`title`) > 1 ORDER BY `title`'; - - $db_results = Dba::read($sql); - - $results = array(); - - while ($item = Dba::fetch_assoc($db_results)) { - $results[] = $item; - } // end while - - return $results; - - } // get_duplicate_songs - - /** - * get_duplicate_info - * - * This takes a song id and search type and returns the - * duplicate songs in the correct order, sorted by length, bitrate, - * and filesize. - */ - public static function get_duplicate_info($item, $search_type) { - $sql = 'SELECT `id` FROM `song` ' . - "WHERE `title`='" . Dba::escape($item['title']) . "' "; - - if ($search_type == 'artist_title' || - $search_type == 'artist_album_title') { - $sql .= "AND `artist`='" . Dba::escape($item['artist']) . "' "; - } - if ($search_type == 'artist_album_title') { - $sql .= "AND `album` = '" . Dba::escape($item['album']) . "' "; - } - - $sql .= 'ORDER BY `time`,`bitrate`,`size`'; - $db_results = Dba::read($sql); - - $results = array(); - - while ($item = Dba::fetch_assoc($db_results)) { - $results[] = $item['id']; - } // end while - - return $results; - - } // get_duplicate_info - /** * dump_album_art * This runs through all of the albums and tries to dump the -- cgit