[Easytag-mailing] Patch for CDDB lookup problems (EasyTAG 2.1.6)



Hi to all,

Here is attached a patch to fix the problem with the manual cddb lookup, before the next version. The server gnudb.org doesn't to use anymore the cddb service, but only a http service... This was the cause of the problem.

I'm working on a 2.1.7 version to include patches of severals people ;-)

Regards,
Jérôme

--
EasyTAG - Tag editor for MP3 and Ogg Vorbis files
http://easytag.sourceforge.net
--
Jerome COUDERC <easytag gmail com>

diff -ruN easytag-2.1.6.orig/src/cddb.c easytag-2.1.6/src/cddb.c
--- easytag-2.1.6.orig/src/cddb.c	2008-03-22 22:57:29.000000000 +0100
+++ easytag-2.1.6/src/cddb.c	2009-08-25 23:16:35.000000000 +0200
@@ -2158,10 +2158,12 @@
  */
 gboolean Cddb_Search_Album_List_From_String (void)
 {
-    if ( strstr(CDDB_SERVER_NAME_MANUAL_SEARCH,"freedb") != NULL )
-        return Cddb_Search_Album_List_From_String_Freedb();
-    else
+    if ( strstr(CDDB_SERVER_NAME_MANUAL_SEARCH,"gnudb") != NULL )
+		// Use of gnudb
         return Cddb_Search_Album_List_From_String_Gnudb();
+    else
+		// Use of freedb
+        return Cddb_Search_Album_List_From_String_Freedb();
 }
 
 
@@ -2255,7 +2257,7 @@
     g_free(string);
     g_free(tmp);
     g_free(proxy_auth);
-    //g_print("Request : '%s'\n", cddb_in);
+    //g_print("Request Cddb_Search_Album_List_From_String_Freedb : '%s'\n", cddb_in);
 
     // Send the request
     gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,_("Sending request ..."));
@@ -2574,7 +2576,7 @@
                                   );
         next_page_found = FALSE;
         g_free(proxy_auth);
-        //g_print("Request : '%s'\n", cddb_in);
+        //g_print("Request Cddb_Search_Album_List_From_String_Gnudb : '%s'\n", cddb_in);
 
         // Send the request
         gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,_("Sending request ..."));
@@ -3130,7 +3132,7 @@
                                       (proxy_auth=Cddb_Format_Proxy_Authentification())
                                       );
             g_free(proxy_auth);
-            //g_print("Request : '%s'\n", cddb_in);
+            //g_print("Request Cddb_Search_Album_From_Selected_Files : '%s'\n", cddb_in);
 
             msg = g_strdup_printf(_("Sending request (CddbId: %s, #tracks: %d, Disc length: %d) ..."),
                                 cddb_discid,num_tracks,disc_length);
@@ -3394,24 +3396,47 @@
                                              CDDB_USE_PROXY?CDDB_PROXY_PORT:cddb_server_port)) <= 0 )
             return FALSE;
 
-        // 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?...";
-        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:%d\r\n"
-                                  "%s"
-                                  "Connection: close\r\n\r\n",
-                                  CDDB_USE_PROXY?"http://":"",CDDB_USE_PROXY?cddb_server_name:"";, cddb_server_cgi_path,
-                                  cddbalbum->category,cddbalbum->id,
-                                  APPNAME,VERSION,
-                                  cddb_server_name,cddb_server_port,
-                                  (proxy_auth=Cddb_Format_Proxy_Authentification())
-                                  );
-        g_free(proxy_auth);
-        //g_print("Request : '%s'\n", cddb_in);
+		if ( strstr(cddb_server_name,"gnudb") != NULL )
+		{
+			// For gnudb
+			// New version of gnudb doesn't use a cddb request, but a http request
+		    cddb_in = g_strdup_printf("GET %s%s/gnudb/"
+		                              "%s/%s"
+		                              " HTTP/1.1\r\n"
+		                              "Host: %s:%d\r\n"
+		                              "User-Agent: %s %s\r\n"
+		                              "%s"
+		                              "Connection: close\r\n"
+		                              "\r\n",
+		                              CDDB_USE_PROXY?"http://":"";, CDDB_USE_PROXY?cddb_server_name:"",  // Needed when using proxy
+		                              cddbalbum->category,cddbalbum->id,
+		                              cddb_server_name,cddb_server_port,
+		                              APPNAME,VERSION,
+		                              (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?...";
+		    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:%d\r\n"
+		                              "%s"
+		                              "Connection: close\r\n\r\n",
+		                              CDDB_USE_PROXY?"http://":"",CDDB_USE_PROXY?cddb_server_name:"";, cddb_server_cgi_path,
+		                              cddbalbum->category,cddbalbum->id,
+		                              APPNAME,VERSION,
+		                              cddb_server_name,cddb_server_port,
+		                              (proxy_auth=Cddb_Format_Proxy_Authentification())
+		                              );
+		}
+
+		
+		g_free(proxy_auth);
+        //g_print("Request Cddb_Get_Album_Tracks_List : '%s'\n", cddb_in);
 
         // Send the request
         gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,_("Sending request ..."));
@@ -3444,20 +3469,38 @@
         }
 
 
-        // Parse server answer : Check HTTP Header and CDDB Header
+        // Parse server answer : Check HTTP Header (freedb or gnudb) and CDDB Header (freedb only)
         file = NULL;
-        if ( Cddb_Read_Http_Header(&file,&cddb_out) <= 0
-          || Cddb_Read_Cddb_Header(&file,&cddb_out) <= 0 )
-        {
-            gchar *msg = g_strdup_printf(_("The server returned a wrong answer! (%s)"),cddb_out);
-            gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg);
-            Log_Print(LOG_ERROR,"%s",msg);
-            g_free(msg);
-            g_free(cddb_out);
-            if (file)
-                fclose(file);
-            return FALSE;
-        }
+		if ( strstr(cddb_server_name,"gnudb") != NULL )
+		{
+			// For gnudb (don't check CDDB header)
+			if ( Cddb_Read_Http_Header(&file,&cddb_out) <= 0 )
+		    {
+		        gchar *msg = g_strdup_printf(_("The server returned a wrong answer! (%s)"),cddb_out);
+		        gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,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
+		      || Cddb_Read_Cddb_Header(&file,&cddb_out) <= 0 )
+		    {
+		        gchar *msg = g_strdup_printf(_("The server returned a wrong answer! (%s)"),cddb_out);
+		        gtk_statusbar_push(GTK_STATUSBAR(CddbStatusBar),CddbStatusBarContext,msg);
+		        Log_Print(LOG_ERROR,"%s",msg);
+		        g_free(msg);
+		        g_free(cddb_out);
+		        if (file)
+		            fclose(file);
+		        return FALSE;
+		    }
+		}
         g_free(cddb_out);
 
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]