changeset 802:1c2c92c7f222 trunk

[svn] Bug #423 - Add retrieval of first entry in case of multiple matches. Good enough to remove the FIXME?
author nemo
date Sun, 05 Mar 2006 12:46:31 -0800
parents ec9ba0ad38a8
children 93c749c9e794
files Plugins/Input/cdaudio/cddb.c
diffstat 1 files changed, 18 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Input/cdaudio/cddb.c	Sat Mar 04 14:34:04 2006 -0800
+++ b/Plugins/Input/cdaudio/cddb.c	Sun Mar 05 12:46:31 2006 -0800
@@ -207,7 +207,6 @@
         return FALSE;
     }
 
-    http_close_connection(sock);
     response = g_strsplit(buffer, " ", 4);
 
     cddb_log("Query response: %s", buffer);
@@ -224,10 +223,28 @@
         cddb_info->category = g_strdup(response[1]);
         cddb_info->discid = strtoul(response[2], NULL, 16);
         break;
+	case 211:
+		/* multiple matches - use first match */
+        g_strfreev(response);
+        if (http_read_first_line(sock, buffer, 256) < 0) {
+            http_close_connection(sock);
+            return FALSE;
+        }
+        response = g_strsplit(buffer, " ", 4);
+        for (i = 0; i < 4; i++) {
+            if (response[i] == NULL) {
+                g_strfreev(response);
+                return FALSE;
+            }
+        }
+        cddb_info->category = g_strdup(response[1]);
+        cddb_info->discid = strtoul(response[2], NULL, 16);
+        break;
     default:                   /* FIXME: Handle other 2xx */
         g_strfreev(response);
         return FALSE;
     }
+    http_close_connection(sock);
 
     g_strfreev(response);
     return TRUE;