--- b/src/cddb_dialog.c 2016-08-30 17:31:39.000000000 +0200
+++ a/src/cddb_dialog.c 2021-12-17 02:23:35.479421924 +0100
@@ -813,7 +813,7 @@
*bytes_read_total += bytes_read;
- //g_print("\nLine : %lu : %s\n",bytes_read,cddb_out);
+ //g_print("\nLine : %lu : %s\n",bytes_read,cddb_out); // Debugging
// Display message
size_str = g_format_size (*bytes_read_total);
@@ -852,7 +852,7 @@
}
/*
- * Look up a specific album in freedb, and save to a CddbAlbum structure
+ * Look up a specific album in gnudb, and save to a CddbAlbum structure
*/
static gboolean
Cddb_Get_Album_Tracks_List (EtCDDBDialog *self, GtkTreeSelection* selection)
@@ -923,51 +923,30 @@
if ( strstr(cddb_server_name,"gnudb") != NULL )
{
// For gnudb
- // New version of gnudb doesn't use a cddb request, but a http request
- /* HTTP/1.0 to avoid the server returning chunked results.
- * https://bugzilla.gnome.org/show_bug.cgi?id=743812 */
- cddb_in = g_strdup_printf("GET %s%s/gnudb/"
- "%s/%s"
- " HTTP/1.0\r\n"
- "Host: %s:%u\r\n"
- "User-Agent: %s %s\r\n"
- "%s"
- "Connection: close\r\n"
- "\r\n",
- proxy_enabled ? "http://" : "",
- proxy_enabled ? cddb_server_name : "",
- cddbalbum->category,cddbalbum->id,
- cddb_server_name,cddb_server_port,
- PACKAGE_NAME, PACKAGE_VERSION,
- (proxy_auth=Cddb_Format_Proxy_Authentification())
- );
- }else
+ cddb_in = g_strdup_printf("GET %s%s%s?cmd=cddb+read+"
+ "%s+%s"
+ "&hello=noname+localhost+%s+%s"
+ "&proto=6 HTTP/1.1\r\n"
+ "Host: %s:%u\r\n"
+ "%s"
+ "Connection: close\r\n\r\n",
+ proxy_enabled ? "http://" : "",
+ proxy_enabled ? cddb_server_name : "",
+ cddb_server_cgi_path,
+ cddbalbum->category,cddbalbum->id,
+ PACKAGE_NAME, PACKAGE_VERSION,
+ cddb_server_name,cddb_server_port,
+ (proxy_auth=Cddb_Format_Proxy_Authentification())
+ );
+ }else
{
- // 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)
- // Without proxy : "GET /~cddb/cddb.cgi?…" but doesn't work with a proxy.
- // With proxy : "GET http://freedb.freedb.org/~cddb/cddb.cgi?…"
- /* HTTP/1.0 to avoid the server returning chunked results.
- * https://bugzilla.gnome.org/show_bug.cgi?id=743812 */
- cddb_in = g_strdup_printf("GET %s%s%s?cmd=cddb+read+"
- "%s+%s"
- "&hello=noname+localhost+%s+%s"
- "&proto=6 HTTP/1.0\r\n"
- "Host: %s:%u\r\n"
- "%s"
- "Connection: close\r\n\r\n",
- proxy_enabled ? "http://" : "",
- proxy_enabled ? cddb_server_name : "",
- cddb_server_cgi_path,
- cddbalbum->category,cddbalbum->id,
- PACKAGE_NAME, PACKAGE_VERSION,
- cddb_server_name,cddb_server_port,
- (proxy_auth=Cddb_Format_Proxy_Authentification())
- );
+ // No freedb anymore
+ return FALSE;
}
g_free(proxy_auth);
- //g_print("Request Cddb_Get_Album_Tracks_List : '%s'\n", cddb_in);
+ //g_print("Request Cddb_Get_Album_Tracks_List : '%s'\n", cddb_in); // Debugging: Printing the request
// Send the request
gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,_("Sending request…"));
@@ -1002,27 +981,10 @@
}
- // Parse server answer : Check HTTP Header (freedb or gnudb) and CDDB Header (freedb only)
+ // Parse server answer : Check HTTP Header and CDDB Header
file = NULL;
- if ( strstr(cddb_server_name,"gnudb") != NULL )
- {
- // For gnudb (don't check CDDB header)
- if ( Cddb_Read_Http_Header(&file,&cddb_out) <= 0 )
- {
- msg = g_strdup_printf (_("The server returned a bad response ‘%s’"),
- cddb_out);
- gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,msg);
- Log_Print(LOG_ERROR,"%s",msg);
- g_free(msg);
- g_free(cddb_out);
- if (file)
- fclose(file);
- return FALSE;
- }
- }else
- {
- /* For freedb. */
- if (Cddb_Read_Http_Header (&file, &cddb_out) <= 0)
+
+ if (Cddb_Read_Http_Header (&file, &cddb_out) <= 0)
{
msg = g_strdup_printf (_("The server returned a bad response ‘%s’"),
cddb_out);
@@ -1060,9 +1022,9 @@
}
return FALSE;
- }
- }
- g_free(cddb_out);
+ }
+
+ g_free(cddb_out);
}
@@ -1070,7 +1032,7 @@
{
if (!cddb_out) // Empty line?
continue;
- //g_print("%s\n",cddb_out);
+ //g_print("%s\n",cddb_out); // Debugging
// To avoid the cddb lookups to hang (Patch from Paul Giordano)
/* It appears that on some systems that cddb lookups continue to attempt
@@ -1396,437 +1358,8 @@
}
/*
- * Fields : artist, title, track, rest
- * CDDB Categories : blues, classical, country, data, folk, jazz, misc, newage, reggae, rock, soundtrack
- */
-static gchar *
-Cddb_Generate_Request_String_With_Fields_And_Categories_Options (EtCDDBDialog *self)
-{
- GString *string;
- guint search_fields;
- guint search_categories;
-
- /* Init. */
- string = g_string_sized_new (256);
-
- /* Fields. */
- /* FIXME: Fetch cddb-search-fields "all-set" mask. */
-#if 0
- if (search_all_fields)
- {
- g_string_append (string, "&allfields=YES");
- }
- else
- {
- g_string_append (string, "&allfields=NO");
- }
-#endif
-
- search_fields = g_settings_get_flags (MainSettings, "cddb-search-fields");
-
- if (search_fields & ET_CDDB_SEARCH_FIELD_ARTIST)
- {
- g_string_append (string, "&fields=artist");
- }
- if (search_fields & ET_CDDB_SEARCH_FIELD_TITLE)
- {
- g_string_append (string, "&fields=title");
- }
- if (search_fields & ET_CDDB_SEARCH_FIELD_TRACK)
- {
- g_string_append (string, "&fields=track");
- }
- if (search_fields & ET_CDDB_SEARCH_FIELD_OTHER)
- {
- g_string_append (string, "&fields=rest");
- }
-
- /* Categories (warning: there is one other CDDB category that is not used
- * here ("data")) */
- search_categories = g_settings_get_flags (MainSettings,
- "cddb-search-categories");
- g_string_append (string, "&allcats=NO");
-
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_BLUES)
- {
- g_string_append (string, "&cats=blues");
- }
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_CLASSICAL)
- {
- g_string_append (string, "&cats=classical");
- }
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_COUNTRY)
- {
- g_string_append (string, "&cats=country");
- }
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_FOLK)
- {
- g_string_append (string, "&cats=folk");
- }
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_JAZZ)
- {
- g_string_append (string, "&cats=jazz");
- }
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_MISC)
- {
- g_string_append (string, "&cats=misc");
- }
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_NEWAGE)
- {
- g_string_append (string, "&cats=newage");
- }
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_REGGAE)
- {
- g_string_append (string, "&cats=reggae");
- }
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_ROCK)
- {
- g_string_append (string, "&cats=rock");
- }
- if (search_categories & ET_CDDB_SEARCH_CATEGORY_SOUNDTRACK)
- {
- g_string_append (string, "&cats=soundtrack");
- }
-
- return g_string_free (string, FALSE);
-}
-
-
-/*
- * Site FREEDB.ORG - Manual Search
- * Send request (using the HTML search page in freedb.org site) to the CD database
- * to get the list of albums matching to a string.
- */
-static gboolean
-Cddb_Search_Album_List_From_String_Freedb (EtCDDBDialog *self)
-{
- EtCDDBDialogPrivate *priv;
- gint socket_id;
- gchar *string = NULL;
- gchar *tmp, *tmp1;
- gchar *cddb_in; // For the request to send
- gchar *cddb_out = NULL; // Answer received
- gchar *cddb_out_tmp;
- gchar *msg;
- gchar *proxy_auth = NULL;
- gchar *cddb_server_name;
- guint cddb_server_port;
- gchar *cddb_server_cgi_path;
- gboolean proxy_enabled;
- gchar *proxy_hostname;
- guint proxy_port;
-
- gchar *ptr_cat, *cat_str, *id_str, *art_alb_str;
- gchar *art_alb_tmp = NULL;
- gboolean use_art_alb = FALSE;
- gchar *end_str;
- gchar *html_end_str;
- gchar buffer[MAX_STRING_LEN+1];
- gint bytes_written;
- gulong bytes_read_total = 0;
- FILE *file = NULL;
- gboolean web_search_disabled = FALSE;
-
- priv = et_cddb_dialog_get_instance_private (self);
-
- gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,"");
-
- /* Get words to search... */
- string = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->search_entry)));
- if (et_str_empty (string))
- {
- return FALSE;
- }
-
- /* Format the string of words */
- g_strstrip (string);
- /* Remove the duplicated spaces */
- while ((tmp=strstr(string," "))!=NULL) // Search 2 spaces
- {
- tmp1 = tmp + 1;
- while (*tmp1)
- *(tmp++) = *(tmp1++);
- *tmp = '\0';
- }
-
- /* Convert spaces to '+' */
- while ( (tmp=strchr(string,' '))!=NULL )
- *tmp = '+';
-
- cddb_server_name = g_settings_get_string (MainSettings,
- "cddb-manual-search-hostname");
- cddb_server_port = g_settings_get_uint (MainSettings,
- "cddb-manual-search-port");
- cddb_server_cgi_path = g_settings_get_string (MainSettings,
- "cddb-manual-search-path");
-
- /* Connection to the server */
- proxy_enabled = g_settings_get_boolean (MainSettings,
- "cddb-proxy-enabled");
- proxy_hostname = g_settings_get_string (MainSettings,
- "cddb-proxy-hostname");
- proxy_port = g_settings_get_uint (MainSettings, "cddb-proxy-port");
- if ((socket_id = Cddb_Open_Connection (self,
- proxy_enabled
- ? proxy_hostname
- : cddb_server_name,
- proxy_enabled
- ? proxy_port
- : cddb_server_port)) <= 0)
- {
- g_free (string);
- g_free (cddb_server_name);
- g_free (cddb_server_cgi_path);
- g_free (proxy_hostname);
- return FALSE;
- }
-
- /* Build request */
- //cddb_in = g_strdup_printf("GET http://www.freedb.org/freedb_search.php?" // In this case, problem with squid cache...
- cddb_in = g_strdup_printf("GET %s%s/freedb_search.php?"
- "words=%s"
- "%s"
- "&grouping=none"
- " HTTP/1.1\r\n"
- "Host: %s:%u\r\n"
- "User-Agent: %s %s\r\n"
- "%s"
- "Connection: close\r\n"
- "\r\n",
- proxy_enabled ? "http://" : "",
- proxy_enabled ? cddb_server_name : "",
- string,
- (tmp = Cddb_Generate_Request_String_With_Fields_And_Categories_Options (self)),
- cddb_server_name,cddb_server_port,
- PACKAGE_NAME, PACKAGE_VERSION,
- (proxy_auth=Cddb_Format_Proxy_Authentification())
- );
-
- g_free(string);
- g_free(tmp);
- g_free(proxy_auth);
- //g_print("Request Cddb_Search_Album_List_From_String_Freedb : '%s'\n", cddb_in);
-
- // Send the request
- gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,_("Sending request…"));
- while (gtk_events_pending()) gtk_main_iteration();
- if ( (bytes_written=send(socket_id,cddb_in,strlen(cddb_in)+1,0)) < 0)
- {
- Log_Print (LOG_ERROR, _("Cannot send the request ‘%s’"),
- g_strerror (errno));
- Cddb_Close_Connection (self, socket_id);
- g_free(cddb_in);
- g_free(string);
- g_free(cddb_server_name);
- g_free(cddb_server_cgi_path);
- g_free (proxy_hostname);
- return FALSE;
- }
- g_free(cddb_in);
-
-
- /* Delete previous album list. */
- cddb_album_model_clear (self);
- cddb_track_model_clear (self);
-
- if (priv->album_list)
- {
- Cddb_Free_Album_List (self);
- }
- gtk_widget_set_sensitive (GTK_WIDGET (priv->stop_search_button), TRUE);
-
-
- /*
- * Read the answer
- */
- gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,_("Receiving data…"));
- while (gtk_events_pending())
- gtk_main_iteration();
-
- /* Write result in a file. */
- if (Cddb_Write_Result_To_File (self, socket_id, &bytes_read_total) < 0)
- {
- msg = g_strdup(_("The server returned a bad response"));
- gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,msg);
- Log_Print(LOG_ERROR,"%s",msg);
- g_free(msg);
- g_free(cddb_server_name);
- g_free(cddb_server_cgi_path);
- gtk_widget_set_sensitive(GTK_WIDGET(priv->stop_search_button),FALSE);
- return FALSE;
- }
-
- // Parse server answer : Check returned code in the first line
- if (Cddb_Read_Http_Header(&file,&cddb_out) <= 0 || !cddb_out) // Order is important!
- {
- msg = g_strdup_printf (_("The server returned a bad response ‘%s’"),
- cddb_out);
- gtk_statusbar_push(GTK_STATUSBAR(priv->status_bar),priv->status_bar_context,msg);
- Log_Print(LOG_ERROR,"%s",msg);
- g_free(msg);
- g_free(cddb_out);
- g_free(cddb_server_name);
- g_free(cddb_server_cgi_path);
- g_free (proxy_hostname);
- gtk_widget_set_sensitive(GTK_WIDGET(priv->stop_search_button),FALSE);
- if (file)
- fclose(file);
- return FALSE;
- }
- g_free(cddb_out);
-
- // Read other lines, and get list of matching albums
- // Composition of a line :
- // - freedb.org
- // Bob Dylan / MTV Unplugged
- cat_str = g_strdup("http://www.freedb.org/freedb_search_fmt.php?cat=");
- id_str = g_strdup("&id=");
- art_alb_str = g_strdup("\">");
- end_str = g_strdup(""); //"
");
- html_end_str = g_strdup("