* Fix issues with duplicate entries in UPnPSearch results.

* Send XBox360 bad bitrate information, since it requires it.
This commit is contained in:
Justin Maggard 2009-03-27 07:32:41 +00:00
parent 9a481196fc
commit 7372543da9
2 changed files with 32 additions and 10 deletions

View File

@ -95,10 +95,11 @@ insert_container(const char * item, const char * rootParent, const char * refID,
const char *artist, const char *genre, const char *album_art, const char *art_dlna_pn)
{
char **result;
char **result2;
char *sql;
int cols, rows, ret;
int parentID = 0, objectID = 0;
sqlite_int64 detailID;
sqlite_int64 detailID = 0;
sql = sqlite3_mprintf("SELECT OBJECT_ID from OBJECTS where OBJECT_ID glob '%s$*' and NAME = '%q'", rootParent, item);
ret = sql_get_table(db, sql, &result, &rows, &cols);
@ -111,7 +112,24 @@ insert_container(const char * item, const char * rootParent, const char * refID,
else
{
parentID = get_next_available_id("OBJECTS", rootParent);
detailID = GetFolderMetadata(item, NULL, artist, genre, album_art, art_dlna_pn);
if( refID )
{
sql = sqlite3_mprintf("SELECT DETAIL_ID from OBJECTS where OBJECT_ID = %Q", refID);
ret = sql_get_table(db, sql, &result2, &rows, NULL);
if( ret == SQLITE_OK )
{
if( rows )
{
detailID = strtoll(result2[1], NULL, 10);
}
sqlite3_free_table(result2);
}
sqlite3_free(sql);
}
if( !detailID )
{
detailID = GetFolderMetadata(item, NULL, artist, genre, album_art, art_dlna_pn);
}
sql = sqlite3_mprintf( "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, DETAIL_ID, CLASS, NAME) "
"VALUES"

View File

@ -298,7 +298,10 @@ static int callback(void *args, int argc, char **argv, char **azColName)
strcat(passed_args->resp, str_buf);
}
if( bitrate && (!passed_args->filter || strstr(passed_args->filter, "res@bitrate")) ) {
sprintf(str_buf, "bitrate=\"%s\" ", bitrate);
if( passed_args->client == EXbox )
sprintf(str_buf, "bitrate=\"%d\" ", atoi(bitrate)/1024);
else
sprintf(str_buf, "bitrate=\"%s\" ", bitrate);
strcat(passed_args->resp, str_buf);
}
if( sampleFrequency && (!passed_args->filter || strstr(passed_args->filter, "res@sampleFrequency")) ) {
@ -536,6 +539,7 @@ SearchContentDirectory(struct upnphttp * h, const char * action)
args.requested = RequestedCount;
args.resp = NULL;
args.filter = NULL;
args.client = h->req_client;
if( h->req_client == EXbox )
{
if( strcmp(ContainerID, "4") == 0 )
@ -600,15 +604,15 @@ SearchContentDirectory(struct upnphttp * h, const char * action)
DPRINTF(E_DEBUG, L_HTTP, "Translated SearchCriteria: %s\n", SearchCriteria);
args.resp = resp;
sql = sqlite3_mprintf("SELECT * from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
" where OBJECT_ID glob '%s$*' and (%s) "
sql = sqlite3_mprintf("SELECT distinct * from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
" where OBJECT_ID glob '%s$*' and (%s) group by DETAIL_ID "
"%z"
" order by d.TRACK, d.TITLE, o.NAME limit %d, -1;",
ContainerID, SearchCriteria,
(*ContainerID == '*') ? NULL :
sqlite3_mprintf("UNION ALL SELECT * from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
" where OBJECT_ID = '%s' and (%s) ", ContainerID, SearchCriteria),
StartingIndex);
ContainerID, SearchCriteria,
(*ContainerID == '*') ? NULL :
sqlite3_mprintf("UNION ALL SELECT * from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
" where OBJECT_ID = '%s' and (%s) ", ContainerID, SearchCriteria),
StartingIndex);
DPRINTF(E_DEBUG, L_HTTP, "Search SQL: %s\n", sql);
ret = sqlite3_exec(db, sql, callback, (void *) &args, &zErrMsg);
if( ret != SQLITE_OK )