[Tracker] [PATCH] tracker-extract-mp3.c: remove trailing whitespaces



Remove trailing whitespaces from values before inserting them in tracker-store.

Thus, 'Artist A' and 'Artist A  ' are considered the same.
---
 src/tracker-extract/tracker-extract-mp3.c |   36 +++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index e71fb9a..6ae0a5a 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -1926,6 +1926,7 @@ extract_mp3 (const gchar *uri,
                                           filedata.id3v23_info.title2,
                                           filedata.id3v22_info.title2,
                                           filedata.id3v1_info.title);
+
        if (!filedata.title) {
                gchar *p;
                
@@ -1938,6 +1939,10 @@ extract_mp3 (const gchar *uri,
                }
        }
 
+       if (filedata.title) {
+               g_strchomp (filedata.title);
+       }
+
        filedata.performer = tracker_coalesce (7, filedata.id3v24_info.performer1,
                                               filedata.id3v24_info.performer2,
                                               filedata.id3v23_info.performer1,
@@ -1945,10 +1950,18 @@ extract_mp3 (const gchar *uri,
                                               filedata.id3v22_info.performer1,
                                               filedata.id3v22_info.performer2,
                                               filedata.id3v1_info.artist);
+       if (filedata.performer) {
+               g_strchomp (filedata.performer);
+       }
+
        filedata.album = tracker_coalesce (4, filedata.id3v24_info.album,
                                           filedata.id3v23_info.album,
                                           filedata.id3v22_info.album,
                                           filedata.id3v1_info.album);
+       if (filedata.album) {
+               g_strchomp (filedata.album);
+       }
+
        filedata.genre = tracker_coalesce (7, filedata.id3v24_info.content_type,
                                           filedata.id3v24_info.title1,
                                           filedata.id3v23_info.content_type,
@@ -1956,6 +1969,10 @@ extract_mp3 (const gchar *uri,
                                           filedata.id3v22_info.content_type,
                                           filedata.id3v22_info.title1,
                                           filedata.id3v1_info.genre);
+       if (filedata.genre) {
+               g_strchomp (filedata.genre);
+       }
+
        filedata.recording_time = tracker_coalesce (7, filedata.id3v24_info.recording_time,
                                                    filedata.id3v24_info.release_time,
                                                    filedata.id3v23_info.recording_time,
@@ -1963,15 +1980,31 @@ extract_mp3 (const gchar *uri,
                                                    filedata.id3v22_info.recording_time,
                                                    filedata.id3v22_info.release_time,
                                                    filedata.id3v1_info.recording_time);
+       if (filedata.recording_time) {
+               g_strchomp (filedata.recording_time);
+       }
+
        filedata.publisher = tracker_coalesce (3, filedata.id3v24_info.publisher,
                                               filedata.id3v23_info.publisher,
                                               filedata.id3v22_info.publisher);
+       if (filedata.publisher) {
+               g_strchomp (filedata.publisher);
+       }
+
        filedata.text = tracker_coalesce (3, filedata.id3v24_info.text,
                                          filedata.id3v23_info.text,
                                          filedata.id3v22_info.text);
+       if (filedata.text) {
+               g_strchomp (filedata.text);
+       }
+
        filedata.copyright = tracker_coalesce (3, filedata.id3v24_info.copyright,
                                               filedata.id3v23_info.copyright,
                                               filedata.id3v22_info.copyright);
+       if (filedata.copyright) {
+               g_strchomp (filedata.copyright);
+       }
+
        filedata.comment = tracker_coalesce (7, filedata.id3v24_info.title3,
                                             filedata.id3v24_info.comment,
                                             filedata.id3v23_info.title3,
@@ -1979,6 +2012,9 @@ extract_mp3 (const gchar *uri,
                                             filedata.id3v22_info.title3,
                                             filedata.id3v22_info.comment,
                                             filedata.id3v1_info.comment);
+       if (filedata.comment) {
+               g_strchomp (filedata.comment);
+       }
 
        if (filedata.id3v24_info.track_number != 0) {
                filedata.track_number = filedata.id3v24_info.track_number;
-- 
1.6.0.4




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