Lines 813-819
Link Here
|
813 |
|
813 |
|
814 |
*bytes_read_total += bytes_read; |
814 |
*bytes_read_total += bytes_read; |
815 |
|
815 |
|
816 |
//g_print("\nLine : %lu : %s\n",bytes_read,cddb_out); |
816 |
//g_print("\nLine : %lu : %s\n",bytes_read,cddb_out); // Debugging |
817 |
|
817 |
|
818 |
// Display message |
818 |
// Display message |
819 |
size_str = g_format_size (*bytes_read_total); |
819 |
size_str = g_format_size (*bytes_read_total); |
Lines 852-858
Link Here
|
852 |
} |
852 |
} |
853 |
|
853 |
|
854 |
/* |
854 |
/* |
855 |
* Look up a specific album in freedb, and save to a CddbAlbum structure |
855 |
* Look up a specific album in gnudb, and save to a CddbAlbum structure |
856 |
*/ |
856 |
*/ |
857 |
static gboolean |
857 |
static gboolean |
858 |
Cddb_Get_Album_Tracks_List (EtCDDBDialog *self, GtkTreeSelection* selection) |
858 |
Cddb_Get_Album_Tracks_List (EtCDDBDialog *self, GtkTreeSelection* selection) |
Lines 923-973
Link Here
|
923 |
if ( strstr(cddb_server_name,"gnudb") != NULL ) |
923 |
if ( strstr(cddb_server_name,"gnudb") != NULL ) |
924 |
{ |
924 |
{ |
925 |
// For gnudb |
925 |
// For gnudb |
926 |
// New version of gnudb doesn't use a cddb request, but a http request |
926 |
cddb_in = g_strdup_printf("GET %s%s%s?cmd=cddb+read+" |
927 |
/* HTTP/1.0 to avoid the server returning chunked results. |
927 |
"%s+%s" |
928 |
* https://bugzilla.gnome.org/show_bug.cgi?id=743812 */ |
928 |
"&hello=noname+localhost+%s+%s" |
929 |
cddb_in = g_strdup_printf("GET %s%s/gnudb/" |
929 |
"&proto=6 HTTP/1.1\r\n" |
930 |
"%s/%s" |
930 |
"Host: %s:%u\r\n" |
931 |
" HTTP/1.0\r\n" |
931 |
"%s" |
932 |
"Host: %s:%u\r\n" |
932 |
"Connection: close\r\n\r\n", |
933 |
"User-Agent: %s %s\r\n" |
933 |
proxy_enabled ? "http://" : "", |
934 |
"%s" |
934 |
proxy_enabled ? cddb_server_name : "", |
935 |
"Connection: close\r\n" |
935 |
cddb_server_cgi_path, |
936 |
"\r\n", |
936 |
cddbalbum->category,cddbalbum->id, |
937 |
proxy_enabled ? "http://" : "", |
937 |
PACKAGE_NAME, PACKAGE_VERSION, |
938 |
proxy_enabled ? cddb_server_name : "", |
938 |
cddb_server_name,cddb_server_port, |
939 |
cddbalbum->category,cddbalbum->id, |
939 |
(proxy_auth=Cddb_Format_Proxy_Authentification()) |
940 |
cddb_server_name,cddb_server_port, |
940 |
); |
941 |
PACKAGE_NAME, PACKAGE_VERSION, |
941 |
}else |
942 |
(proxy_auth=Cddb_Format_Proxy_Authentification()) |
|
|
943 |
); |
944 |
}else |
945 |
{ |
942 |
{ |
946 |
// CDDB Request (ex: GET /~cddb/cddb.cgi?cmd=cddb+read+jazz+0200a401&hello=noname+localhost+EasyTAG+0.31&proto=1 HTTP/1.1\r\nHost: freedb.freedb.org:80\r\nConnection: close) |
943 |
// No freedb anymore |
947 |
// Without proxy : "GET /~cddb/cddb.cgi?…" but doesn't work with a proxy. |
944 |
return FALSE; |
948 |
// With proxy : "GET http://freedb.freedb.org/~cddb/cddb.cgi?…" |
|
|
949 |
/* HTTP/1.0 to avoid the server returning chunked results. |
950 |
* https://bugzilla.gnome.org/show_bug.cgi?id=743812 */ |
951 |
cddb_in = g_strdup_printf("GET %s%s%s?cmd=cddb+read+" |
952 |
"%s+%s" |
953 |
"&hello=noname+localhost+%s+%s" |
954 |
"&proto=6 HTTP/1.0\r\n" |
955 |
"Host: %s:%u\r\n" |
956 |
"%s" |
957 |
"Connection: close\r\n\r\n", |
958 |
proxy_enabled ? "http://" : "", |
959 |
proxy_enabled ? cddb_server_name : "", |
960 |
cddb_server_cgi_path, |
961 |
cddbalbum->category,cddbalbum->id, |
962 |
PACKAGE_NAME, PACKAGE_VERSION, |
963 |
cddb_server_name,cddb_server_port, |
964 |
(proxy_auth=Cddb_Format_Proxy_Authentification()) |
965 |
); |
966 |
} |
945 |
} |
967 |
|
946 |
|
968 |
|
947 |
|
969 |
g_free(proxy_auth); |
948 |
g_free(proxy_auth); |
970 |
//g_print("Request Cddb_Get_Album_Tracks_List : '%s'\n", cddb_in); |
949 |
//g_print("Request Cddb_Get_Album_Tracks_List : '%s'\n", cddb_in); // Debugging: Printing the request |
971 |
|
950 |
|
972 |
// Send the request |
951 |
// Send the request |
973 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,_("Sending request…")); |
952 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,_("Sending request…")); |
Lines 1002-1028
Link Here
|
1002 |
} |
981 |
} |
1003 |
|
982 |
|
1004 |
|
983 |
|
1005 |
// Parse server answer : Check HTTP Header (freedb or gnudb) and CDDB Header (freedb only) |
984 |
// Parse server answer : Check HTTP Header and CDDB Header |
1006 |
file = NULL; |
985 |
file = NULL; |
1007 |
if ( strstr(cddb_server_name,"gnudb") != NULL ) |
986 |
|
1008 |
{ |
987 |
if (Cddb_Read_Http_Header (&file, &cddb_out) <= 0) |
1009 |
// For gnudb (don't check CDDB header) |
|
|
1010 |
if ( Cddb_Read_Http_Header(&file,&cddb_out) <= 0 ) |
1011 |
{ |
1012 |
msg = g_strdup_printf (_("The server returned a bad response ‘%s’"), |
1013 |
cddb_out); |
1014 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,msg); |
1015 |
Log_Print(LOG_ERROR,"%s",msg); |
1016 |
g_free(msg); |
1017 |
g_free(cddb_out); |
1018 |
if (file) |
1019 |
fclose(file); |
1020 |
return FALSE; |
1021 |
} |
1022 |
}else |
1023 |
{ |
1024 |
/* For freedb. */ |
1025 |
if (Cddb_Read_Http_Header (&file, &cddb_out) <= 0) |
1026 |
{ |
988 |
{ |
1027 |
msg = g_strdup_printf (_("The server returned a bad response ‘%s’"), |
989 |
msg = g_strdup_printf (_("The server returned a bad response ‘%s’"), |
1028 |
cddb_out); |
990 |
cddb_out); |
Lines 1060-1068
Link Here
|
1060 |
} |
1022 |
} |
1061 |
|
1023 |
|
1062 |
return FALSE; |
1024 |
return FALSE; |
1063 |
} |
1025 |
} |
1064 |
} |
1026 |
|
1065 |
g_free(cddb_out); |
1027 |
g_free(cddb_out); |
1066 |
|
1028 |
|
1067 |
} |
1029 |
} |
1068 |
|
1030 |
|
Lines 1070-1076
Link Here
|
1070 |
{ |
1032 |
{ |
1071 |
if (!cddb_out) // Empty line? |
1033 |
if (!cddb_out) // Empty line? |
1072 |
continue; |
1034 |
continue; |
1073 |
//g_print("%s\n",cddb_out); |
1035 |
//g_print("%s\n",cddb_out); // Debugging |
1074 |
|
1036 |
|
1075 |
// To avoid the cddb lookups to hang (Patch from Paul Giordano) |
1037 |
// To avoid the cddb lookups to hang (Patch from Paul Giordano) |
1076 |
/* It appears that on some systems that cddb lookups continue to attempt |
1038 |
/* It appears that on some systems that cddb lookups continue to attempt |
Lines 1396-1832
Link Here
|
1396 |
} |
1358 |
} |
1397 |
|
1359 |
|
1398 |
/* |
1360 |
/* |
1399 |
* Fields : artist, title, track, rest |
|
|
1400 |
* CDDB Categories : blues, classical, country, data, folk, jazz, misc, newage, reggae, rock, soundtrack |
1401 |
*/ |
1402 |
static gchar * |
1403 |
Cddb_Generate_Request_String_With_Fields_And_Categories_Options (EtCDDBDialog *self) |
1404 |
{ |
1405 |
GString *string; |
1406 |
guint search_fields; |
1407 |
guint search_categories; |
1408 |
|
1409 |
/* Init. */ |
1410 |
string = g_string_sized_new (256); |
1411 |
|
1412 |
/* Fields. */ |
1413 |
/* FIXME: Fetch cddb-search-fields "all-set" mask. */ |
1414 |
#if 0 |
1415 |
if (search_all_fields) |
1416 |
{ |
1417 |
g_string_append (string, "&allfields=YES"); |
1418 |
} |
1419 |
else |
1420 |
{ |
1421 |
g_string_append (string, "&allfields=NO"); |
1422 |
} |
1423 |
#endif |
1424 |
|
1425 |
search_fields = g_settings_get_flags (MainSettings, "cddb-search-fields"); |
1426 |
|
1427 |
if (search_fields & ET_CDDB_SEARCH_FIELD_ARTIST) |
1428 |
{ |
1429 |
g_string_append (string, "&fields=artist"); |
1430 |
} |
1431 |
if (search_fields & ET_CDDB_SEARCH_FIELD_TITLE) |
1432 |
{ |
1433 |
g_string_append (string, "&fields=title"); |
1434 |
} |
1435 |
if (search_fields & ET_CDDB_SEARCH_FIELD_TRACK) |
1436 |
{ |
1437 |
g_string_append (string, "&fields=track"); |
1438 |
} |
1439 |
if (search_fields & ET_CDDB_SEARCH_FIELD_OTHER) |
1440 |
{ |
1441 |
g_string_append (string, "&fields=rest"); |
1442 |
} |
1443 |
|
1444 |
/* Categories (warning: there is one other CDDB category that is not used |
1445 |
* here ("data")) */ |
1446 |
search_categories = g_settings_get_flags (MainSettings, |
1447 |
"cddb-search-categories"); |
1448 |
g_string_append (string, "&allcats=NO"); |
1449 |
|
1450 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_BLUES) |
1451 |
{ |
1452 |
g_string_append (string, "&cats=blues"); |
1453 |
} |
1454 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_CLASSICAL) |
1455 |
{ |
1456 |
g_string_append (string, "&cats=classical"); |
1457 |
} |
1458 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_COUNTRY) |
1459 |
{ |
1460 |
g_string_append (string, "&cats=country"); |
1461 |
} |
1462 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_FOLK) |
1463 |
{ |
1464 |
g_string_append (string, "&cats=folk"); |
1465 |
} |
1466 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_JAZZ) |
1467 |
{ |
1468 |
g_string_append (string, "&cats=jazz"); |
1469 |
} |
1470 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_MISC) |
1471 |
{ |
1472 |
g_string_append (string, "&cats=misc"); |
1473 |
} |
1474 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_NEWAGE) |
1475 |
{ |
1476 |
g_string_append (string, "&cats=newage"); |
1477 |
} |
1478 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_REGGAE) |
1479 |
{ |
1480 |
g_string_append (string, "&cats=reggae"); |
1481 |
} |
1482 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_ROCK) |
1483 |
{ |
1484 |
g_string_append (string, "&cats=rock"); |
1485 |
} |
1486 |
if (search_categories & ET_CDDB_SEARCH_CATEGORY_SOUNDTRACK) |
1487 |
{ |
1488 |
g_string_append (string, "&cats=soundtrack"); |
1489 |
} |
1490 |
|
1491 |
return g_string_free (string, FALSE); |
1492 |
} |
1493 |
|
1494 |
|
1495 |
/* |
1496 |
* Site FREEDB.ORG - Manual Search |
1497 |
* Send request (using the HTML search page in freedb.org site) to the CD database |
1498 |
* to get the list of albums matching to a string. |
1499 |
*/ |
1500 |
static gboolean |
1501 |
Cddb_Search_Album_List_From_String_Freedb (EtCDDBDialog *self) |
1502 |
{ |
1503 |
EtCDDBDialogPrivate *priv; |
1504 |
gint socket_id; |
1505 |
gchar *string = NULL; |
1506 |
gchar *tmp, *tmp1; |
1507 |
gchar *cddb_in; // For the request to send |
1508 |
gchar *cddb_out = NULL; // Answer received |
1509 |
gchar *cddb_out_tmp; |
1510 |
gchar *msg; |
1511 |
gchar *proxy_auth = NULL; |
1512 |
gchar *cddb_server_name; |
1513 |
guint cddb_server_port; |
1514 |
gchar *cddb_server_cgi_path; |
1515 |
gboolean proxy_enabled; |
1516 |
gchar *proxy_hostname; |
1517 |
guint proxy_port; |
1518 |
|
1519 |
gchar *ptr_cat, *cat_str, *id_str, *art_alb_str; |
1520 |
gchar *art_alb_tmp = NULL; |
1521 |
gboolean use_art_alb = FALSE; |
1522 |
gchar *end_str; |
1523 |
gchar *html_end_str; |
1524 |
gchar buffer[MAX_STRING_LEN+1]; |
1525 |
gint bytes_written; |
1526 |
gulong bytes_read_total = 0; |
1527 |
FILE *file = NULL; |
1528 |
gboolean web_search_disabled = FALSE; |
1529 |
|
1530 |
priv = et_cddb_dialog_get_instance_private (self); |
1531 |
|
1532 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,""); |
1533 |
|
1534 |
/* Get words to search... */ |
1535 |
string = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->search_entry))); |
1536 |
if (et_str_empty (string)) |
1537 |
{ |
1538 |
return FALSE; |
1539 |
} |
1540 |
|
1541 |
/* Format the string of words */ |
1542 |
g_strstrip (string); |
1543 |
/* Remove the duplicated spaces */ |
1544 |
while ((tmp=strstr(string," "))!=NULL) // Search 2 spaces |
1545 |
{ |
1546 |
tmp1 = tmp + 1; |
1547 |
while (*tmp1) |
1548 |
*(tmp++) = *(tmp1++); |
1549 |
*tmp = '\0'; |
1550 |
} |
1551 |
|
1552 |
/* Convert spaces to '+' */ |
1553 |
while ( (tmp=strchr(string,' '))!=NULL ) |
1554 |
*tmp = '+'; |
1555 |
|
1556 |
cddb_server_name = g_settings_get_string (MainSettings, |
1557 |
"cddb-manual-search-hostname"); |
1558 |
cddb_server_port = g_settings_get_uint (MainSettings, |
1559 |
"cddb-manual-search-port"); |
1560 |
cddb_server_cgi_path = g_settings_get_string (MainSettings, |
1561 |
"cddb-manual-search-path"); |
1562 |
|
1563 |
/* Connection to the server */ |
1564 |
proxy_enabled = g_settings_get_boolean (MainSettings, |
1565 |
"cddb-proxy-enabled"); |
1566 |
proxy_hostname = g_settings_get_string (MainSettings, |
1567 |
"cddb-proxy-hostname"); |
1568 |
proxy_port = g_settings_get_uint (MainSettings, "cddb-proxy-port"); |
1569 |
if ((socket_id = Cddb_Open_Connection (self, |
1570 |
proxy_enabled |
1571 |
? proxy_hostname |
1572 |
: cddb_server_name, |
1573 |
proxy_enabled |
1574 |
? proxy_port |
1575 |
: cddb_server_port)) <= 0) |
1576 |
{ |
1577 |
g_free (string); |
1578 |
g_free (cddb_server_name); |
1579 |
g_free (cddb_server_cgi_path); |
1580 |
g_free (proxy_hostname); |
1581 |
return FALSE; |
1582 |
} |
1583 |
|
1584 |
/* Build request */ |
1585 |
//cddb_in = g_strdup_printf("GET http://www.freedb.org/freedb_search.php?" // In this case, problem with squid cache... |
1586 |
cddb_in = g_strdup_printf("GET %s%s/freedb_search.php?" |
1587 |
"words=%s" |
1588 |
"%s" |
1589 |
"&grouping=none" |
1590 |
" HTTP/1.1\r\n" |
1591 |
"Host: %s:%u\r\n" |
1592 |
"User-Agent: %s %s\r\n" |
1593 |
"%s" |
1594 |
"Connection: close\r\n" |
1595 |
"\r\n", |
1596 |
proxy_enabled ? "http://" : "", |
1597 |
proxy_enabled ? cddb_server_name : "", |
1598 |
string, |
1599 |
(tmp = Cddb_Generate_Request_String_With_Fields_And_Categories_Options (self)), |
1600 |
cddb_server_name,cddb_server_port, |
1601 |
PACKAGE_NAME, PACKAGE_VERSION, |
1602 |
(proxy_auth=Cddb_Format_Proxy_Authentification()) |
1603 |
); |
1604 |
|
1605 |
g_free(string); |
1606 |
g_free(tmp); |
1607 |
g_free(proxy_auth); |
1608 |
//g_print("Request Cddb_Search_Album_List_From_String_Freedb : '%s'\n", cddb_in); |
1609 |
|
1610 |
// Send the request |
1611 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,_("Sending request…")); |
1612 |
while (gtk_events_pending()) gtk_main_iteration(); |
1613 |
if ( (bytes_written=send(socket_id,cddb_in,strlen(cddb_in)+1,0)) < 0) |
1614 |
{ |
1615 |
Log_Print (LOG_ERROR, _("Cannot send the request ‘%s’"), |
1616 |
g_strerror (errno)); |
1617 |
Cddb_Close_Connection (self, socket_id); |
1618 |
g_free(cddb_in); |
1619 |
g_free(string); |
1620 |
g_free(cddb_server_name); |
1621 |
g_free(cddb_server_cgi_path); |
1622 |
g_free (proxy_hostname); |
1623 |
return FALSE; |
1624 |
} |
1625 |
g_free(cddb_in); |
1626 |
|
1627 |
|
1628 |
/* Delete previous album list. */ |
1629 |
cddb_album_model_clear (self); |
1630 |
cddb_track_model_clear (self); |
1631 |
|
1632 |
if (priv->album_list) |
1633 |
{ |
1634 |
Cddb_Free_Album_List (self); |
1635 |
} |
1636 |
gtk_widget_set_sensitive (GTK_WIDGET (priv->stop_search_button), TRUE); |
1637 |
|
1638 |
|
1639 |
/* |
1640 |
* Read the answer |
1641 |
*/ |
1642 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,_("Receiving data…")); |
1643 |
while (gtk_events_pending()) |
1644 |
gtk_main_iteration(); |
1645 |
|
1646 |
/* Write result in a file. */ |
1647 |
if (Cddb_Write_Result_To_File (self, socket_id, &bytes_read_total) < 0) |
1648 |
{ |
1649 |
msg = g_strdup(_("The server returned a bad response")); |
1650 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,msg); |
1651 |
Log_Print(LOG_ERROR,"%s",msg); |
1652 |
g_free(msg); |
1653 |
g_free(cddb_server_name); |
1654 |
g_free(cddb_server_cgi_path); |
1655 |
gtk_widget_set_sensitive(GTK_WIDGET(priv->stop_search_button),FALSE); |
1656 |
return FALSE; |
1657 |
} |
1658 |
|
1659 |
// Parse server answer : Check returned code in the first line |
1660 |
if (Cddb_Read_Http_Header(&file,&cddb_out) <= 0 || !cddb_out) // Order is important! |
1661 |
{ |
1662 |
msg = g_strdup_printf (_("The server returned a bad response ‘%s’"), |
1663 |
cddb_out); |
1664 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,msg); |
1665 |
Log_Print(LOG_ERROR,"%s",msg); |
1666 |
g_free(msg); |
1667 |
g_free(cddb_out); |
1668 |
g_free(cddb_server_name); |
1669 |
g_free(cddb_server_cgi_path); |
1670 |
g_free (proxy_hostname); |
1671 |
gtk_widget_set_sensitive(GTK_WIDGET(priv->stop_search_button),FALSE); |
1672 |
if (file) |
1673 |
fclose(file); |
1674 |
return FALSE; |
1675 |
} |
1676 |
g_free(cddb_out); |
1677 |
|
1678 |
// Read other lines, and get list of matching albums |
1679 |
// Composition of a line : |
1680 |
// - freedb.org |
1681 |
// <a href="http://www.freedb.org/freedb_search_fmt.php?cat=rock&id=8c0f0a0b">Bob Dylan / MTV Unplugged</a><br> |
1682 |
cat_str = g_strdup("http://www.freedb.org/freedb_search_fmt.php?cat="); |
1683 |
id_str = g_strdup("&id="); |
1684 |
art_alb_str = g_strdup("\">"); |
1685 |
end_str = g_strdup("</a>"); //"</a><br>"); |
1686 |
html_end_str = g_strdup("</body>"); // To avoid the cddb lookups to hang |
1687 |
while (!priv->stop_searching && Cddb_Read_Line (&file, &cddb_out) > 0) |
1688 |
{ |
1689 |
cddb_out_tmp = cddb_out; |
1690 |
//g_print("%s\n",cddb_out); // To print received data |
1691 |
|
1692 |
// If the web search is disabled! (ex : http://www.freedb.org/modules.php?name=News&file=article&sid=246) |
1693 |
// The following string is displayed in the search page |
1694 |
if (cddb_out != NULL && strstr(cddb_out_tmp,"Sorry, The web-based search is currently down.") != NULL) |
1695 |
{ |
1696 |
web_search_disabled = TRUE; |
1697 |
break; |
1698 |
} |
1699 |
|
1700 |
// We may have severals album in the same line (other version of the same album?) |
1701 |
// Note : we test that the 'end' delimiter exists to avoid crashes |
1702 |
while ( cddb_out != NULL && (ptr_cat=strstr(cddb_out_tmp,cat_str)) != NULL && strstr(cddb_out_tmp,end_str) != NULL ) |
1703 |
{ |
1704 |
gchar *ptr_font, *ptr_font1; |
1705 |
gchar *ptr_id, *ptr_art_alb, *ptr_end; |
1706 |
gchar *copy; |
1707 |
CddbAlbum *cddbalbum; |
1708 |
|
1709 |
cddbalbum = g_slice_new0 (CddbAlbum); |
1710 |
|
1711 |
|
1712 |
// Parameters of the server used |
1713 |
cddbalbum->server_name = g_strdup(cddb_server_name); |
1714 |
cddbalbum->server_port = cddb_server_port; |
1715 |
cddbalbum->server_cgi_path = g_strdup(cddb_server_cgi_path); |
1716 |
cddbalbum->bitmap = Cddb_Get_Pixbuf_From_Server_Name(cddbalbum->server_name); |
1717 |
|
1718 |
// Get album category |
1719 |
cddb_out_tmp = ptr_cat + strlen(cat_str); |
1720 |
strncpy(buffer,cddb_out_tmp,MAX_STRING_LEN); |
1721 |
if ( (ptr_id=strstr(buffer,id_str)) != NULL ) |
1722 |
*ptr_id = 0; |
1723 |
cddbalbum->category = Try_To_Validate_Utf8_String(buffer); |
1724 |
|
1725 |
|
1726 |
// Get album ID |
1727 |
//cddb_out_tmp = strstr(cddb_out_tmp,id_str) + strlen(id_str); |
1728 |
cddb_out_tmp = ptr_cat + strlen(cat_str) + 2; |
1729 |
strncpy(buffer,cddb_out_tmp,MAX_STRING_LEN); |
1730 |
if ( (ptr_art_alb=strstr(buffer,art_alb_str)) != NULL ) |
1731 |
*ptr_art_alb = 0; |
1732 |
cddbalbum->id = Try_To_Validate_Utf8_String(buffer); |
1733 |
|
1734 |
|
1735 |
// Get album and artist names. |
1736 |
// Note : some names can be like this "<font size=-1>2</font>" (for other version of the same album) |
1737 |
cddb_out_tmp = strstr(cddb_out_tmp,art_alb_str) + strlen(art_alb_str); |
1738 |
strncpy(buffer,cddb_out_tmp,MAX_STRING_LEN); |
1739 |
if ( (ptr_end=strstr(buffer,end_str)) != NULL ) |
1740 |
*ptr_end = 0; |
1741 |
if ( (ptr_font=strstr(buffer,"</font>")) != NULL ) |
1742 |
{ |
1743 |
copy = NULL; |
1744 |
*ptr_font = 0; |
1745 |
if ( (ptr_font1=strstr(buffer,">")) != NULL ) |
1746 |
{ |
1747 |
copy = g_strdup_printf("%s -> %s",ptr_font1+1,art_alb_tmp); |
1748 |
cddbalbum->other_version = TRUE; |
1749 |
}else |
1750 |
{ |
1751 |
copy = g_strdup(buffer); |
1752 |
} |
1753 |
|
1754 |
}else |
1755 |
{ |
1756 |
copy = g_strdup(buffer); |
1757 |
art_alb_tmp = cddbalbum->artist_album; |
1758 |
use_art_alb = TRUE; |
1759 |
} |
1760 |
|
1761 |
cddbalbum->artist_album = Try_To_Validate_Utf8_String(copy); |
1762 |
g_free(copy); |
1763 |
|
1764 |
if (use_art_alb) |
1765 |
{ |
1766 |
art_alb_tmp = cddbalbum->artist_album; |
1767 |
use_art_alb = FALSE; |
1768 |
} |
1769 |
|
1770 |
|
1771 |
// New position the search the next string |
1772 |
cddb_out_tmp = strstr(cddb_out_tmp,end_str) + strlen(end_str); |
1773 |
|
1774 |
priv->album_list = g_list_append(priv->album_list,cddbalbum); |
1775 |
} |
1776 |
|
1777 |
// To avoid the cddb lookups to hang (Patch from Paul Giordano) |
1778 |
/* It appears that on some systems that cddb lookups continue to attempt |
1779 |
* to get data from the socket even though the other system has completed |
1780 |
* sending. Here we see if the actual end of data is in the last block read. |
1781 |
* In the case of the html scan, the </body> tag is used because there's |
1782 |
* no crlf followint the </html> tag. |
1783 |
*/ |
1784 |
if (strstr(cddb_out_tmp,html_end_str)!=NULL) |
1785 |
{ |
1786 |
g_free(cddb_out); |
1787 |
break; |
1788 |
} |
1789 |
g_free(cddb_out); |
1790 |
} |
1791 |
g_free(cat_str); g_free(id_str); g_free(art_alb_str); g_free(end_str); g_free(html_end_str); |
1792 |
g_free(cddb_server_name); |
1793 |
g_free(cddb_server_cgi_path); |
1794 |
g_free (proxy_hostname); |
1795 |
|
1796 |
// Close file opened for reading lines |
1797 |
if (file) |
1798 |
{ |
1799 |
fclose(file); |
1800 |
file = NULL; |
1801 |
} |
1802 |
|
1803 |
gtk_widget_set_sensitive(GTK_WIDGET(priv->stop_search_button),FALSE); |
1804 |
|
1805 |
/* Close connection. */ |
1806 |
Cddb_Close_Connection (self, socket_id); |
1807 |
|
1808 |
if (web_search_disabled) |
1809 |
msg = g_strdup_printf(_("Sorry, the web-based search is currently not available")); |
1810 |
else |
1811 |
{ |
1812 |
msg = g_strdup_printf (ngettext ("Found one matching album", |
1813 |
"Found %u matching albums", |
1814 |
g_list_length (priv->album_list)), |
1815 |
g_list_length (priv->album_list)); |
1816 |
} |
1817 |
|
1818 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,msg); |
1819 |
g_free(msg); |
1820 |
|
1821 |
/* Load the albums found in the list. */ |
1822 |
Cddb_Load_Album_List (self, FALSE); |
1823 |
|
1824 |
return TRUE; |
1825 |
} |
1826 |
|
1827 |
/* |
1828 |
* Site GNUDB.ORG - Manual Search |
1361 |
* Site GNUDB.ORG - Manual Search |
1829 |
* Send request (using the HTML search page in freedb.org site) to the CD database |
1362 |
* Send request (using the HTML search page in gnudb.org site) to the CD database |
1830 |
* to get the list of albums matching to a string. |
1363 |
* to get the list of albums matching to a string. |
1831 |
*/ |
1364 |
*/ |
1832 |
static gboolean |
1365 |
static gboolean |
Lines 1937-1957
Link Here
|
1937 |
"?page=%d" |
1470 |
"?page=%d" |
1938 |
" HTTP/1.1\r\n" |
1471 |
" HTTP/1.1\r\n" |
1939 |
"Host: %s:%u\r\n" |
1472 |
"Host: %s:%u\r\n" |
1940 |
"User-Agent: %s %s\r\n" |
1473 |
//"User-Agent: %s %s\r\n" |
1941 |
"%s" |
1474 |
"%s" |
1942 |
"Connection: close\r\n" |
1475 |
"Connection: close\r\n\r\n", |
1943 |
"\r\n", |
|
|
1944 |
proxy_enabled ? "http://" : "", |
1476 |
proxy_enabled ? "http://" : "", |
1945 |
proxy_enabled ? cddb_server_name : "", |
1477 |
proxy_enabled ? cddb_server_name : "", |
1946 |
string, |
1478 |
string, |
1947 |
next_page_cpt, |
1479 |
next_page_cpt, |
1948 |
cddb_server_name,cddb_server_port, |
1480 |
cddb_server_name,cddb_server_port, |
1949 |
PACKAGE_NAME, PACKAGE_VERSION, |
1481 |
//PACKAGE_NAME, PACKAGE_VERSION, |
1950 |
(proxy_auth=Cddb_Format_Proxy_Authentification()) |
1482 |
(proxy_auth=Cddb_Format_Proxy_Authentification()) |
1951 |
); |
1483 |
); |
1952 |
next_page_found = FALSE; |
1484 |
next_page_found = FALSE; |
1953 |
g_free(proxy_auth); |
1485 |
g_free(proxy_auth); |
1954 |
//g_print("Request Cddb_Search_Album_List_From_String_Gnudb : '%s'\n", cddb_in); |
1486 |
//g_print("Request Cddb_Search_Album_List_From_String_Gnudb : '%s'\n", cddb_in); // Debugging: Printing the request |
1955 |
|
1487 |
|
1956 |
// Send the request |
1488 |
// Send the request |
1957 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,_("Sending request…")); |
1489 |
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,_("Sending request…")); |
Lines 2029-2036
Link Here
|
2029 |
// Read other lines, and get list of matching albums |
1561 |
// Read other lines, and get list of matching albums |
2030 |
// Composition of a line : |
1562 |
// Composition of a line : |
2031 |
// - gnudb.org |
1563 |
// - gnudb.org |
2032 |
// <a href="http://www.gnudb.org/cd/ro21123813"><b>Indochine / Le Birthday Album</b></a><br> |
1564 |
// <a href="https://gnudb.org/cd/ro21123813"><b>Indochine / Le Birthday Album</b></a><br> |
2033 |
cat_str = g_strdup("http://www.gnudb.org/cd/"); |
1565 |
cat_str = g_strdup("https://gnudb.org/cd/"); |
2034 |
art_alb_str = g_strdup("\"><b>"); |
1566 |
art_alb_str = g_strdup("\"><b>"); |
2035 |
end_str = g_strdup("</b></a>"); //"</a><br>"); |
1567 |
end_str = g_strdup("</b></a>"); //"</a><br>"); |
2036 |
html_end_str = g_strdup("</body>"); // To avoid the cddb lookups to hang |
1568 |
html_end_str = g_strdup("</body>"); // To avoid the cddb lookups to hang |
Lines 2042-2048
Link Here
|
2042 |
while (!priv->stop_searching && Cddb_Read_Line (&file, &cddb_out) > 0) |
1574 |
while (!priv->stop_searching && Cddb_Read_Line (&file, &cddb_out) > 0) |
2043 |
{ |
1575 |
{ |
2044 |
cddb_out_tmp = cddb_out; |
1576 |
cddb_out_tmp = cddb_out; |
2045 |
//g_print("%s\n",cddb_out); // To print received data |
1577 |
g_print("%s\n",cddb_out); // To print received data |
2046 |
|
1578 |
|
2047 |
// Line that displays the number of total albums return by the search |
1579 |
// Line that displays the number of total albums return by the search |
2048 |
if ( cddb_out != NULL |
1580 |
if ( cddb_out != NULL |
Lines 2067-2073
Link Here
|
2067 |
cddbalbum = g_slice_new0 (CddbAlbum); |
1599 |
cddbalbum = g_slice_new0 (CddbAlbum); |
2068 |
|
1600 |
|
2069 |
// Parameters of the server used |
1601 |
// Parameters of the server used |
2070 |
cddbalbum->server_name = g_strdup(cddb_server_name); |
1602 |
//cddbalbum->server_name = g_strdup(cddb_server_name); // This is not working right now: cddb requests on www.gnudb.org resulting in 404 |
|
|
1603 |
cddbalbum->server_name = g_settings_get_string (MainSettings, |
1604 |
"cddb-automatic-search-hostname"); |
2071 |
cddbalbum->server_port = cddb_server_port; |
1605 |
cddbalbum->server_port = cddb_server_port; |
2072 |
cddbalbum->server_cgi_path = g_strdup(cddb_server_cgi_path); |
1606 |
cddbalbum->server_cgi_path = g_strdup(cddb_server_cgi_path); |
2073 |
cddbalbum->bitmap = Cddb_Get_Pixbuf_From_Server_Name(cddbalbum->server_name); |
1607 |
cddbalbum->bitmap = Cddb_Get_Pixbuf_From_Server_Name(cddbalbum->server_name); |
Lines 2188-2194
Link Here
|
2188 |
|
1722 |
|
2189 |
/* |
1723 |
/* |
2190 |
* Select the function to use according the server adress for the manual search |
1724 |
* Select the function to use according the server adress for the manual search |
2191 |
* - freedb.freedb.org |
|
|
2192 |
* - gnudb.gnudb.org |
1725 |
* - gnudb.gnudb.org |
2193 |
*/ |
1726 |
*/ |
2194 |
static gboolean |
1727 |
static gboolean |
Lines 2205-2213
Link Here
|
2205 |
} |
1738 |
} |
2206 |
else |
1739 |
else |
2207 |
{ |
1740 |
{ |
2208 |
/* Use freedb. */ |
1741 |
/* False */ |
2209 |
g_free (hostname); |
1742 |
return FALSE; |
2210 |
return Cddb_Search_Album_List_From_String_Freedb (self); |
|
|
2211 |
} |
1743 |
} |
2212 |
} |
1744 |
} |
2213 |
|
1745 |
|
Lines 3174-3180
Link Here
|
3174 |
* Remote cddb acces |
2706 |
* Remote cddb acces |
3175 |
* |
2707 |
* |
3176 |
* Request the two servers |
2708 |
* Request the two servers |
3177 |
* - 1) www.freedb.org |
2709 |
* - 1) www.gnudb.org |
3178 |
* - 2) MusicBrainz Gateway : freedb.musicbrainz.org (in Easytag < 2.1.1, it was: www.mb.inhouse.co.uk) |
2710 |
* - 2) MusicBrainz Gateway : freedb.musicbrainz.org (in Easytag < 2.1.1, it was: www.mb.inhouse.co.uk) |
3179 |
*/ |
2711 |
*/ |
3180 |
while (server_try < 2) |
2712 |
while (server_try < 2) |
Lines 3230-3236
Link Here
|
3230 |
return FALSE; |
2762 |
return FALSE; |
3231 |
} |
2763 |
} |
3232 |
|
2764 |
|
3233 |
// CDDB Request (ex: GET /~cddb/cddb.cgi?cmd=cddb+query+0800ac01+1++150+172&hello=noname+localhost+EasyTAG+0.31&proto=1 HTTP/1.1\r\nHost: freedb.freedb.org:80\r\nConnection: close) |
2765 |
// CDDB Request GNUDB (ex: GET /~cddb/cddb.cgi?cmd=cddb+query+0800ac01+1++150+172&hello=noname+localhost+EasyTAG+2.4.3&proto=6 HTTP/1.1\r\nHost: freedb.freedb.org:80\r\nConnection: close) |
3234 |
// Without proxy : "GET /~cddb/cddb.cgi?…" but doesn't work with a proxy. |
2766 |
// Without proxy : "GET /~cddb/cddb.cgi?…" but doesn't work with a proxy. |
3235 |
// With proxy : "GET http://freedb.freedb.org/~cddb/cddb.cgi?…" |
2767 |
// With proxy : "GET http://freedb.freedb.org/~cddb/cddb.cgi?…" |
3236 |
// proto=1 => ISO-8859-1 - proto=6 => UTF-8 |
2768 |
// proto=1 => ISO-8859-1 - proto=6 => UTF-8 |
Lines 3250-3260
Link Here
|
3250 |
num_tracks, query_string->str, |
2782 |
num_tracks, query_string->str, |
3251 |
disc_length, |
2783 |
disc_length, |
3252 |
PACKAGE_NAME, PACKAGE_VERSION, |
2784 |
PACKAGE_NAME, PACKAGE_VERSION, |
3253 |
cddb_server_name,cddb_server_port, |
2785 |
cddb_server_name,cddb_server_port, |
3254 |
(proxy_auth=Cddb_Format_Proxy_Authentification()) |
2786 |
(proxy_auth=Cddb_Format_Proxy_Authentification()) |
3255 |
); |
2787 |
); |
3256 |
g_free (proxy_auth); |
2788 |
g_free (proxy_auth); |
3257 |
//g_print("Request Cddb_Search_Album_From_Selected_Files : '%s'\n", cddb_in); |
2789 |
//g_print("Request Cddb_Search_Album_From_Selected_Files : '%s'\n", cddb_in); // Debugging: Printing the request |
3258 |
|
2790 |
|
3259 |
msg = g_strdup_printf (_("Sending request (disc ID: %s, #tracks: %u, Disc length: %u)…"), |
2791 |
msg = g_strdup_printf (_("Sending request (disc ID: %s, #tracks: %u, Disc length: %u)…"), |
3260 |
cddb_discid, num_tracks, disc_length); |
2792 |
cddb_discid, num_tracks, disc_length); |
Lines 3328-3334
Link Here
|
3328 |
|
2860 |
|
3329 |
/* |
2861 |
/* |
3330 |
* Format : |
2862 |
* Format : |
3331 |
* For Freedb, Gnudb, the lines to read are like : |
2863 |
* For Gnudb, the lines to read are like : |
3332 |
* 211 Found inexact matches, list follows (until terminating `.') |
2864 |
* 211 Found inexact matches, list follows (until terminating `.') |
3333 |
* rock 8f0dc00b Archive / Noise |
2865 |
* rock 8f0dc00b Archive / Noise |
3334 |
* rock 7b0dd80b Archive / Noise |
2866 |
* rock 7b0dd80b Archive / Noise |
Lines 3470-3479
Link Here
|
3470 |
{ |
3002 |
{ |
3471 |
g_return_val_if_fail (server_name != NULL, NULL); |
3003 |
g_return_val_if_fail (server_name != NULL, NULL); |
3472 |
|
3004 |
|
3473 |
if (strstr (server_name, "freedb.org")) |
3005 |
if (strstr(server_name,"gnudb.org")) |
3474 |
return gdk_pixbuf_new_from_resource ("/org/gnome/EasyTAG/images/freedb.png", |
|
|
3475 |
NULL); |
3476 |
else if (strstr(server_name,"gnudb.org")) |
3477 |
return gdk_pixbuf_new_from_resource ("/org/gnome/EasyTAG/images/gnudb.png", |
3006 |
return gdk_pixbuf_new_from_resource ("/org/gnome/EasyTAG/images/gnudb.png", |
3478 |
NULL); |
3007 |
NULL); |
3479 |
else if (strstr(server_name,"musicbrainz.org")) |
3008 |
else if (strstr(server_name,"musicbrainz.org")) |