[Mplayer-cvslog] CVS: main/libmpdemux cddb.c,1.10,1.11

Bertrand Baudet bertrand at mplayerhq.hu
Fri Jan 3 21:50:29 CET 2003


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv31245

Modified Files:
	cddb.c 
Log Message:
- If CDDB fail, try CDDA
- Support for inexact matches list.


Index: cddb.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cddb.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- cddb.c	28 Dec 2002 14:04:54 -0000	1.10
+++ cddb.c	3 Jan 2003 20:50:26 -0000	1.11
@@ -440,6 +440,42 @@
 }
 
 int
+cddb_parse_matches_list(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
+	char album_title[100];
+	char *ptr = NULL;
+	int ret;
+	
+	ptr = strstr(http_hdr->body, "\n");
+	if( ptr==NULL ) {
+		printf("Unable to find end of line\n");
+		return -1;
+	}
+	ptr++;
+	// We have a list of exact/inexact matches, so which one do we use?
+	// So let's take the first one.
+	ret = sscanf(ptr, "%s %08lx %s", cddb_data->category, &(cddb_data->disc_id), album_title);
+	if( ret!=3 ) {
+		printf("Parse error\n");
+		return -1;
+	}
+	ptr = strstr(http_hdr->body, album_title);
+	if( ptr!=NULL ) {
+		char *ptr2;
+		int len;
+		ptr2 = strstr(ptr, "\n");
+		if( ptr2==NULL ) {
+			len = (http_hdr->body_size)-(ptr-(http_hdr->body));
+		} else {
+			len = ptr2-ptr+1;
+		}
+		strncpy(album_title, ptr, len);
+		album_title[len-2]='\0';
+	}
+	printf("Parse OK, found: %s\n", album_title);
+	return 0;
+}
+
+int
 cddb_query_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
 	char album_title[100];
 	char *ptr = NULL;
@@ -480,33 +516,7 @@
 			break;
 		case 210:
 			// Found exact matches, list follows
-			ptr = strstr(http_hdr->body, "\n");
-			if( ptr==NULL ) {
-				printf("Unable to find end of line\n");
-				return -1;
-			}
-			ptr++;
-			// We have a list of exact matches, so which one do
-			// we use? So let's take the first one.
-			ret = sscanf(ptr, "%s %08lx %s", cddb_data->category, &(cddb_data->disc_id), album_title);
-			if( ret!=3 ) {
-				printf("Parse error\n");
-				return -1;
-			}
-			ptr = strstr(http_hdr->body, album_title);
-			if( ptr!=NULL ) {
-				char *ptr2;
-				int len;
-				ptr2 = strstr(ptr, "\n");
-				if( ptr2==NULL ) {
-					len = (http_hdr->body_size)-(ptr-(http_hdr->body));
-				} else {
-					len = ptr2-ptr+1;
-				}
-				strncpy(album_title, ptr, len);
-				album_title[len-2]='\0';
-			}
-			printf("Parse OK, found: %s\n", album_title);
+			cddb_parse_matches_list(http_hdr, cddb_data);
 			return cddb_request_titles(cddb_data);
 /*
 body=[210 Found exact matches, list follows (until terminating `.')
@@ -517,8 +527,8 @@
 */	
 		case 211:
 			// Found inexact matches, list follows
-			printf("No exact matches found, list follows\n");
-			break;
+			cddb_parse_matches_list(http_hdr, cddb_data);
+			return cddb_request_titles(cddb_data);
 		default:
 			printf("Unhandled code\n");
 	}
@@ -815,9 +825,9 @@
 	int ret;
 	
 	ret = cddb_resolve(&xmcd_file);
-	if( ret<0 ) {
-		return NULL;
-	}
+//	if( ret<0 ) {
+//		return NULL;
+//	}
 	if( ret==0 ) {
 		cd_info = cddb_parse_xmcd(xmcd_file);
 		free(xmcd_file);



More information about the MPlayer-cvslog mailing list