* Fix issues with duplicate entries in UPnPSearch results.
* Send XBox360 bad bitrate information, since it requires it.
This commit is contained in:
parent
9a481196fc
commit
7372543da9
22
scanner.c
22
scanner.c
@ -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)
|
const char *artist, const char *genre, const char *album_art, const char *art_dlna_pn)
|
||||||
{
|
{
|
||||||
char **result;
|
char **result;
|
||||||
|
char **result2;
|
||||||
char *sql;
|
char *sql;
|
||||||
int cols, rows, ret;
|
int cols, rows, ret;
|
||||||
int parentID = 0, objectID = 0;
|
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);
|
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);
|
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
|
else
|
||||||
{
|
{
|
||||||
parentID = get_next_available_id("OBJECTS", rootParent);
|
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"
|
sql = sqlite3_mprintf( "INSERT into OBJECTS"
|
||||||
" (OBJECT_ID, PARENT_ID, REF_ID, DETAIL_ID, CLASS, NAME) "
|
" (OBJECT_ID, PARENT_ID, REF_ID, DETAIL_ID, CLASS, NAME) "
|
||||||
"VALUES"
|
"VALUES"
|
||||||
|
20
upnpsoap.c
20
upnpsoap.c
@ -298,7 +298,10 @@ static int callback(void *args, int argc, char **argv, char **azColName)
|
|||||||
strcat(passed_args->resp, str_buf);
|
strcat(passed_args->resp, str_buf);
|
||||||
}
|
}
|
||||||
if( bitrate && (!passed_args->filter || strstr(passed_args->filter, "res@bitrate")) ) {
|
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);
|
strcat(passed_args->resp, str_buf);
|
||||||
}
|
}
|
||||||
if( sampleFrequency && (!passed_args->filter || strstr(passed_args->filter, "res@sampleFrequency")) ) {
|
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.requested = RequestedCount;
|
||||||
args.resp = NULL;
|
args.resp = NULL;
|
||||||
args.filter = NULL;
|
args.filter = NULL;
|
||||||
|
args.client = h->req_client;
|
||||||
if( h->req_client == EXbox )
|
if( h->req_client == EXbox )
|
||||||
{
|
{
|
||||||
if( strcmp(ContainerID, "4") == 0 )
|
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);
|
DPRINTF(E_DEBUG, L_HTTP, "Translated SearchCriteria: %s\n", SearchCriteria);
|
||||||
|
|
||||||
args.resp = resp;
|
args.resp = resp;
|
||||||
sql = sqlite3_mprintf("SELECT * from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
|
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) "
|
" where OBJECT_ID glob '%s$*' and (%s) group by DETAIL_ID "
|
||||||
"%z"
|
"%z"
|
||||||
" order by d.TRACK, d.TITLE, o.NAME limit %d, -1;",
|
" order by d.TRACK, d.TITLE, o.NAME limit %d, -1;",
|
||||||
ContainerID, SearchCriteria,
|
ContainerID, SearchCriteria,
|
||||||
(*ContainerID == '*') ? NULL :
|
(*ContainerID == '*') ? NULL :
|
||||||
sqlite3_mprintf("UNION ALL SELECT * from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
|
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),
|
" where OBJECT_ID = '%s' and (%s) ", ContainerID, SearchCriteria),
|
||||||
StartingIndex);
|
StartingIndex);
|
||||||
DPRINTF(E_DEBUG, L_HTTP, "Search SQL: %s\n", sql);
|
DPRINTF(E_DEBUG, L_HTTP, "Search SQL: %s\n", sql);
|
||||||
ret = sqlite3_exec(db, sql, callback, (void *) &args, &zErrMsg);
|
ret = sqlite3_exec(db, sql, callback, (void *) &args, &zErrMsg);
|
||||||
if( ret != SQLITE_OK )
|
if( ret != SQLITE_OK )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user