mirror of
https://github.com/mpv-player/mpv
synced 2025-02-12 18:07:12 +00:00
- If CDDB fail, try CDDA
- Support for inexact matches list. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8747 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
0842caf6f0
commit
25abed26d4
@ -439,6 +439,42 @@ cddb_request_titles(cddb_data_t *cddb_data) {
|
||||
return cddb_http_request(command, cddb_read_parse, cddb_data);
|
||||
}
|
||||
|
||||
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];
|
||||
@ -480,33 +516,7 @@ cddb_query_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) {
|
||||
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 @@ blues c711930d Santana / Supernatural
|
||||
*/
|
||||
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 @@ cddb_open(char *dev, char *track) {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user