* Remove ALBUM_ART_PN from the database, since it's forced to be JPEG_TN now.
* Add a DISC entry to the database, so when the client sorts a multi-disc audio album by track, we can sort by disc first.
This commit is contained in:
		| @@ -160,7 +160,7 @@ update_if_album_art(const char * path) | ||||
| 		{ | ||||
| 			DPRINTF(E_DEBUG, L_METADATA, "New file %s looks like cover art for %s\n", path, dp->d_name); | ||||
| 			asprintf(&file, "%s/%s", dir, dp->d_name); | ||||
| 			art_id = find_album_art(file, NULL, NULL, 0); | ||||
| 			art_id = find_album_art(file, NULL, 0); | ||||
| 			sql = sqlite3_mprintf("UPDATE DETAILS set ALBUM_ART = %lld where PATH = '%q'", art_id, file); | ||||
| 			if( sql_exec(db, sql) != SQLITE_OK ) | ||||
| 				DPRINTF(E_WARN, L_METADATA, "Error setting %s as cover art for %s\n", match, dp->d_name); | ||||
| @@ -340,7 +340,7 @@ found_file: | ||||
| } | ||||
|  | ||||
| sqlite_int64 | ||||
| find_album_art(const char * path, char * dlna_pn, const char * image_data, int image_size) | ||||
| find_album_art(const char * path, const char * image_data, int image_size) | ||||
| { | ||||
| 	char * album_art = NULL; | ||||
| 	char * sql; | ||||
| @@ -352,8 +352,6 @@ find_album_art(const char * path, char * dlna_pn, const char * image_data, int i | ||||
| 	if( (image_size && (album_art = check_embedded_art(path, image_data, image_size))) || | ||||
| 	    (album_art = check_for_album_file(dirname(mypath), path)) ) | ||||
| 	{ | ||||
| 		if( dlna_pn ) | ||||
| 			strcpy(dlna_pn, "JPEG_TN"); | ||||
| 		sql = sqlite3_mprintf("SELECT ID from ALBUM_ART where PATH = '%q'", album_art ? album_art : path); | ||||
| 		if( (sql_get_table(db, sql, &result, &rows, &cols) == SQLITE_OK) && rows ) | ||||
| 		{ | ||||
|   | ||||
| @@ -14,6 +14,6 @@ void | ||||
| update_if_album_art(const char * path); | ||||
|  | ||||
| sqlite_int64 | ||||
| find_album_art(const char * path, char * dlna_pn, const char * image_data, int image_size); | ||||
| find_album_art(const char * path, const char * image_data, int image_size); | ||||
|  | ||||
| #endif | ||||
|   | ||||
							
								
								
									
										31
									
								
								metadata.c
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								metadata.c
									
									
									
									
									
								
							| @@ -118,18 +118,17 @@ get_fourcc(const char *s) | ||||
| } | ||||
|  | ||||
| sqlite_int64 | ||||
| GetFolderMetadata(const char * name, const char * path, const char * artist, const char * genre, const char * album_art, const char * art_dlna_pn) | ||||
| GetFolderMetadata(const char * name, const char * path, const char * artist, const char * genre, const char * album_art) | ||||
| { | ||||
| 	char * sql; | ||||
| 	int ret; | ||||
|  | ||||
| 	sql = sqlite3_mprintf( "INSERT into DETAILS" | ||||
|                                " (TITLE, PATH, CREATOR, ARTIST, GENRE, ALBUM_ART, ART_DLNA_PN) " | ||||
|                                " (TITLE, PATH, CREATOR, ARTIST, GENRE, ALBUM_ART) " | ||||
|                                "VALUES" | ||||
|                                " ('%q', %Q, %Q, %Q, %Q, %lld, %Q);", | ||||
|                                name, path, artist, artist, genre, | ||||
|                                album_art ? strtoll(album_art, NULL, 10) : 0, | ||||
|                                art_dlna_pn); | ||||
|                                album_art ? strtoll(album_art, NULL, 10) : 0); | ||||
| 	if( sql_exec(db, sql) != SQLITE_OK ) | ||||
| 		ret = 0; | ||||
| 	else | ||||
| @@ -151,7 +150,6 @@ GetAudioMetadata(const char * path, char * name) | ||||
| 	char *esc_tag; | ||||
| 	int i, free_flags = 0; | ||||
| 	sqlite_int64 album_art = 0; | ||||
| 	char art_dlna_pn[9]; | ||||
| 	struct song_metadata song; | ||||
| 	char *dlna_pn = NULL; | ||||
|  | ||||
| @@ -281,22 +279,16 @@ GetAudioMetadata(const char * path, char * name) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	album_art = find_album_art(path, art_dlna_pn, song.image, song.image_size); | ||||
| 	album_art = find_album_art(path, song.image, song.image_size); | ||||
|  | ||||
| 	sql = sqlite3_mprintf(	"INSERT into DETAILS" | ||||
| 				" (PATH, SIZE, DURATION, CHANNELS, BITRATE, SAMPLERATE, DATE," | ||||
| 				"  TITLE, CREATOR, ARTIST, ALBUM, GENRE, COMMENT, TRACK, DLNA_PN, MIME, ALBUM_ART, ART_DLNA_PN) " | ||||
| 				"  TITLE, CREATOR, ARTIST, ALBUM, GENRE, COMMENT, DISC, TRACK, DLNA_PN, MIME, ALBUM_ART) " | ||||
| 				"VALUES" | ||||
| 				" (%Q, %d, '%s', %d, %d, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, %Q, '%s', %lld, %Q);", | ||||
| 				" (%Q, %d, '%s', %d, %d, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, %d, %Q, '%s', %lld, %Q);", | ||||
| 				path, song.file_size, duration, song.channels, song.bitrate, song.samplerate, date, | ||||
| 				title, | ||||
| 				artist, artist, | ||||
| 				album, | ||||
| 				genre, | ||||
| 				comment, | ||||
| 				song.track, | ||||
| 				dlna_pn, song.mime?song.mime:mime, | ||||
| 				album_art, album_art?art_dlna_pn:NULL ); | ||||
| 				title, artist, artist, album, genre, comment, song.disc, song.track, | ||||
| 				dlna_pn, song.mime?song.mime:mime, album_art); | ||||
|         freetags(&song); | ||||
| 	if( dlna_pn ) | ||||
| 		free(dlna_pn); | ||||
| @@ -516,7 +508,6 @@ GetVideoMetadata(const char * path, char * name) | ||||
| 	int duration, hours, min, sec, ms; | ||||
| 	aac_object_type_t aac_type = AAC_INVALID; | ||||
| 	sqlite_int64 album_art = 0; | ||||
| 	char art_dlna_pn[9]; | ||||
| 	metadata_t m; | ||||
| 	memset(&m, '\0', sizeof(m)); | ||||
| 	date[0] = '\0'; | ||||
| @@ -906,18 +897,18 @@ GetVideoMetadata(const char * path, char * name) | ||||
| 		asprintf(&m.mime, "video/x-tivo-mpeg"); | ||||
| 	} | ||||
| #endif | ||||
| 	album_art = find_album_art(path, art_dlna_pn, NULL, 0); | ||||
| 	album_art = find_album_art(path, NULL, 0); | ||||
|  | ||||
| 	sql = sqlite3_mprintf( "INSERT into DETAILS" | ||||
| 	                       " (PATH, SIZE, DURATION, DATE, CHANNELS, BITRATE, SAMPLERATE, RESOLUTION," | ||||
| 	                       "  CREATOR, TITLE, DLNA_PN, MIME, ALBUM_ART, ART_DLNA_PN) " | ||||
| 	                       "  CREATOR, TITLE, DLNA_PN, MIME, ALBUM_ART) " | ||||
| 	                       "VALUES" | ||||
| 	                       " (%Q, %lld, %Q, %Q, %Q, %Q, %Q, %Q, %Q, '%q', %Q, '%q', %lld, %Q);", | ||||
| 	                       path, size, m.duration, | ||||
| 	                       strlen(date) ? date : NULL, | ||||
| 	                       m.channels, m.bitrate, m.frequency, m.resolution, | ||||
| 	                       m.artist, name, m.dlna_pn, m.mime, | ||||
| 	                       album_art, album_art?art_dlna_pn:NULL ); | ||||
| 	                       album_art); | ||||
| 	//DEBUG DPRINTF(E_DEBUG, L_METADATA, "SQL: %s\n", sql); | ||||
| 	if( sql_exec(db, sql) != SQLITE_OK ) | ||||
| 	{ | ||||
|   | ||||
| @@ -74,7 +74,7 @@ char * | ||||
| modifyString(char * string, const char * before, const char * after, short like); | ||||
|  | ||||
| sqlite_int64 | ||||
| GetFolderMetadata(const char * name, const char * path, const char * artist, const char * genre, const char * album_art, const char * art_dlna_pn); | ||||
| GetFolderMetadata(const char * name, const char * path, const char * artist, const char * genre, const char * album_art); | ||||
|  | ||||
| sqlite_int64 | ||||
| GetAudioMetadata(const char * path, char * name); | ||||
|   | ||||
							
								
								
									
										34
									
								
								scanner.c
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								scanner.c
									
									
									
									
									
								
							| @@ -67,7 +67,7 @@ get_next_available_id(const char * table, const char * parentID) | ||||
|  | ||||
| long long int | ||||
| insert_container(const char * item, const char * rootParent, const char * refID, const char *class, | ||||
|                  const char *artist, const char *genre, const char *album_art, const char *art_dlna_pn) | ||||
|                  const char *artist, const char *genre, const char *album_art) | ||||
| { | ||||
| 	char **result; | ||||
| 	char **result2; | ||||
| @@ -107,7 +107,7 @@ insert_container(const char * item, const char * rootParent, const char * refID, | ||||
| 		} | ||||
| 		if( !detailID ) | ||||
| 		{ | ||||
| 			detailID = GetFolderMetadata(item, NULL, artist, genre, album_art, art_dlna_pn); | ||||
| 			detailID = GetFolderMetadata(item, NULL, artist, genre, album_art); | ||||
| 		} | ||||
| 		sql = sqlite3_mprintf(	"INSERT into OBJECTS" | ||||
| 					" (OBJECT_ID, PARENT_ID, REF_ID, DETAIL_ID, CLASS, NAME) " | ||||
| @@ -165,7 +165,7 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			container = insert_container(date_taken, "3$12", NULL, "album.photoAlbum", NULL, NULL, NULL, NULL); | ||||
| 			container = insert_container(date_taken, "3$12", NULL, "album.photoAlbum", NULL, NULL, NULL); | ||||
| 			sprintf(last_date.parentID, "3$12$%llX", container>>32); | ||||
| 			last_date.objectID = (int)container; | ||||
| 			strcpy(last_date.name, date_taken); | ||||
| @@ -190,7 +190,7 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 		} | ||||
| 		if( !valid_cache || strcmp(camera, last_cam.name) != 0 ) | ||||
| 		{ | ||||
| 			container = insert_container(camera, "3$13", NULL, "storageFolder", NULL, NULL, NULL, NULL); | ||||
| 			container = insert_container(camera, "3$13", NULL, "storageFolder", NULL, NULL, NULL); | ||||
| 			sprintf(last_cam.parentID, "3$13$%llX", container>>32); | ||||
| 			strncpy(last_cam.name, camera, 255); | ||||
| 			last_camdate.name[0] = '\0'; | ||||
| @@ -202,7 +202,7 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			container = insert_container(date_taken, last_cam.parentID, NULL, "album.photoAlbum", NULL, NULL, NULL, NULL); | ||||
| 			container = insert_container(date_taken, last_cam.parentID, NULL, "album.photoAlbum", NULL, NULL, NULL); | ||||
| 			sprintf(last_camdate.parentID, "%s$%llX", last_cam.parentID, container>>32); | ||||
| 			last_camdate.objectID = (int)container; | ||||
| 			strcpy(last_camdate.name, date_taken); | ||||
| @@ -230,7 +230,7 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 	} | ||||
| 	else if( strstr(class, "audioItem") ) | ||||
| 	{ | ||||
| 		asprintf(&sql, "SELECT ARTIST, ALBUM, GENRE, ALBUM_ART, ART_DLNA_PN from DETAILS where ID = %lu", detailID); | ||||
| 		asprintf(&sql, "SELECT ARTIST, ALBUM, GENRE, ALBUM_ART from DETAILS where ID = %lu", detailID); | ||||
| 		ret = sql_get_table(db, sql, &result, &row, &cols); | ||||
| 		free(sql); | ||||
| 		if( ret != SQLITE_OK ) | ||||
| @@ -241,7 +241,7 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 			return; | ||||
| 		} | ||||
| 		char *artist = result[5], *album = result[6], *genre = result[7]; | ||||
| 		char *album_art = result[8], *art_dlna_pn = result[9]; | ||||
| 		char *album_art = result[8]; | ||||
| 		static struct virtual_item last_album; | ||||
| 		static struct virtual_item last_artist; | ||||
| 		static struct virtual_item last_artistAlbum; | ||||
| @@ -261,7 +261,7 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 			else | ||||
| 			{ | ||||
| 				strcpy(last_album.name, album); | ||||
| 				container = insert_container(album, "1$7", NULL, "album.musicAlbum", artist, genre, album_art, art_dlna_pn); | ||||
| 				container = insert_container(album, "1$7", NULL, "album.musicAlbum", artist, genre, album_art); | ||||
| 				sprintf(last_album.parentID, "1$7$%llX", container>>32); | ||||
| 				last_album.objectID = (int)container; | ||||
| 				//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached album item: %s/%s/%X\n", last_album.name, last_album.parentID, last_album.objectID); | ||||
| @@ -278,12 +278,12 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 		{ | ||||
| 			if( !valid_cache || strcmp(artist, last_artist.name) != 0 ) | ||||
| 			{ | ||||
| 				container = insert_container(artist, "1$6", NULL, "person.musicArtist", NULL, genre, NULL, NULL); | ||||
| 				container = insert_container(artist, "1$6", NULL, "person.musicArtist", NULL, genre, NULL); | ||||
| 				sprintf(last_artist.parentID, "1$6$%llX", container>>32); | ||||
| 				strcpy(last_artist.name, artist); | ||||
| 				last_artistAlbum.name[0] = '\0'; | ||||
| 				/* Add this file to the "- All Albums -" container as well */ | ||||
| 				container = insert_container("- All Albums -", last_artist.parentID, NULL, "storageFolder", artist, genre, NULL, NULL); | ||||
| 				container = insert_container("- All Albums -", last_artist.parentID, NULL, "storageFolder", artist, genre, NULL); | ||||
| 				sprintf(last_artistAlbumAll.parentID, "%s$%llX", last_artist.parentID, container>>32); | ||||
| 				last_artistAlbumAll.objectID = (int)container; | ||||
| 			} | ||||
| @@ -298,7 +298,7 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				container = insert_container(album?album:"Unknown Album", last_artist.parentID, album?last_album.parentID:NULL, "album.musicAlbum", artist, genre, album_art, art_dlna_pn); | ||||
| 				container = insert_container(album?album:"Unknown Album", last_artist.parentID, album?last_album.parentID:NULL, "album.musicAlbum", artist, genre, album_art); | ||||
| 				sprintf(last_artistAlbum.parentID, "%s$%llX", last_artist.parentID, container>>32); | ||||
| 				last_artistAlbum.objectID = (int)container; | ||||
| 				strcpy(last_artistAlbum.name, album?album:"Unknown Album"); | ||||
| @@ -323,12 +323,12 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 		{ | ||||
| 			if( !valid_cache || strcmp(genre, last_genre.name) != 0 ) | ||||
| 			{ | ||||
| 				container = insert_container(genre, "1$5", NULL, "genre.musicGenre", NULL, NULL, NULL, NULL); | ||||
| 				container = insert_container(genre, "1$5", NULL, "genre.musicGenre", NULL, NULL, NULL); | ||||
| 				sprintf(last_genre.parentID, "1$5$%llX", container>>32); | ||||
| 				strcpy(last_genre.name, genre); | ||||
| 				last_genreArtist.name[0] = '\0'; | ||||
| 				/* Add this file to the "- All Artists -" container as well */ | ||||
| 				container = insert_container("- All Artists -", last_genre.parentID, NULL, "storageFolder", NULL, genre, NULL, NULL); | ||||
| 				container = insert_container("- All Artists -", last_genre.parentID, NULL, "storageFolder", NULL, genre, NULL); | ||||
| 				sprintf(last_genreArtistAll.parentID, "%s$%llX", last_genre.parentID, container>>32); | ||||
| 				last_genreArtistAll.objectID = (int)container; | ||||
| 			} | ||||
| @@ -342,7 +342,7 @@ insert_containers(const char * name, const char *path, const char * refID, const | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				container = insert_container(artist?artist:"Unknown Artist", last_genre.parentID, artist?last_artist.parentID:NULL, "person.musicArtist", NULL, genre, NULL, NULL); | ||||
| 				container = insert_container(artist?artist:"Unknown Artist", last_genre.parentID, artist?last_artist.parentID:NULL, "person.musicArtist", NULL, genre, NULL); | ||||
| 				sprintf(last_genreArtist.parentID, "%s$%llX", last_genre.parentID, container>>32); | ||||
| 				last_genreArtist.objectID = (int)container; | ||||
| 				strcpy(last_genreArtist.name, artist?artist:"Unknown Artist"); | ||||
| @@ -469,7 +469,7 @@ insert_directory(const char * name, const char * path, const char * base, const | ||||
| 		return 1; | ||||
| 	} | ||||
|  | ||||
| 	detailID = GetFolderMetadata(name, path, NULL, NULL, NULL, NULL); | ||||
| 	detailID = GetFolderMetadata(name, path, NULL, NULL, NULL); | ||||
| 	sql = sqlite3_mprintf(	"INSERT into OBJECTS" | ||||
| 				" (OBJECT_ID, PARENT_ID, REF_ID, DETAIL_ID, CLASS, NAME) " | ||||
| 				"VALUES" | ||||
| @@ -628,7 +628,7 @@ CreateDatabase(void) | ||||
| 					"DLNA_PN TEXT, " | ||||
| 					"MIME TEXT, " | ||||
| 					"ALBUM_ART INTEGER DEFAULT 0, " | ||||
| 					"ART_DLNA_PN TEXT DEFAULT NULL" | ||||
| 					"DISC INTEGER" | ||||
| 					")"); | ||||
| 	if( ret != SQLITE_OK ) | ||||
| 		goto sql_failed; | ||||
| @@ -651,7 +651,7 @@ CreateDatabase(void) | ||||
| 		sprintf(sql_buf, "INSERT into OBJECTS (OBJECT_ID, PARENT_ID, DETAIL_ID, CLASS, NAME)" | ||||
| 				 " values " | ||||
| 				 "('%s', '%s', %lld, 'container.storageFolder', '%s')", | ||||
| 				 containers[i], containers[i+1], GetFolderMetadata(containers[i+2], NULL, NULL, NULL, NULL, NULL), containers[i+2]); | ||||
| 				 containers[i], containers[i+1], GetFolderMetadata(containers[i+2], NULL, NULL, NULL, NULL), containers[i+2]); | ||||
| 		ret = sql_exec(db, sql_buf); | ||||
| 		if( ret != SQLITE_OK ) | ||||
| 			goto sql_failed; | ||||
|   | ||||
| @@ -25,7 +25,7 @@ | ||||
|  | ||||
| #define CLIENT_CACHE_SLOTS 20 | ||||
| #define USE_FORK 1 | ||||
| #define DB_VERSION 1 | ||||
| #define DB_VERSION 2 | ||||
|  | ||||
| #if 0 // Add these once the newer ffmpeg libs that can detect WMAPRO are more widely used | ||||
| 	"http-get:*:video/x-ms-wmv:DLNA.ORG_PN=WMVHIGH_PRO;DLNA.ORG_OP=01;DLNA.ORG_CI=0," | ||||
|   | ||||
| @@ -453,7 +453,7 @@ parse_sort_criteria(char * sortCriteria, int * error) | ||||
| 		} | ||||
| 		else if( strcasecmp(item, "upnp:originalTrackNumber") == 0 ) | ||||
| 		{ | ||||
| 			strcat(order, "d.TRACK"); | ||||
| 			strcat(order, "d.DISC, d.TRACK"); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| @@ -519,7 +519,7 @@ static void add_resized_res(int srcw, int srch, int reqw, int reqh, char *dlna_p | ||||
| #define SELECT_COLUMNS "SELECT o.OBJECT_ID, o.PARENT_ID, o.REF_ID, o.DETAIL_ID, o.CLASS," \ | ||||
|                        " d.SIZE, d.TITLE, d.DURATION, d.BITRATE, d.SAMPLERATE, d.ARTIST," \ | ||||
|                        " d.ALBUM, d.GENRE, d.COMMENT, d.CHANNELS, d.TRACK, d.DATE, d.RESOLUTION," \ | ||||
|                        " d.THUMBNAIL, d.CREATOR, d.DLNA_PN, d.MIME, d.ALBUM_ART " | ||||
|                        " d.THUMBNAIL, d.CREATOR, d.DLNA_PN, d.MIME, d.ALBUM_ART, d.DISC " | ||||
|  | ||||
| static int | ||||
| callback(void *args, int argc, char **argv, char **azColName) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user