Revision: 1574
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1574&view=rev
Author:   jcsjcs
Date:     2007-06-22 10:34:25 -0700 (Fri, 22 Jun 2007)

Log Message:
-----------
        * src/mp3file.c:
          added reading/writing of tags for sort artist, sort album,
          sort title, sort albumartist and sort composer.

        * src/mp4file.c:

          Added reading/writing of the grouping tag, whatever that
          is.

          The sort tags are written by iTunes as fields of the
          iTunes_CDDB_IDs tag which I don't seem to be able to access
          (only the first field seems available without hacking). For
          reference: the field names are soar (artist), sonm (title),
          soal (album), soaa (album artist), soco (composer) and sosn
          (show).

          Added reading of coverart tag. Displayed by the iPod but not
          by the coverart display. Properly displayed in the details
          window.

        * src/file.c (copy_new_info): use switch() to avoid missing
          copying new items (like the sort keys).

Modified Paths:
--------------
    gtkpod/trunk/ChangeLog_detailed
    gtkpod/trunk/src/file.c
    gtkpod/trunk/src/mp3file.c
    gtkpod/trunk/src/mp4file.c

Modified: gtkpod/trunk/ChangeLog_detailed
===================================================================
--- gtkpod/trunk/ChangeLog_detailed     2007-06-22 15:37:03 UTC (rev 1573)
+++ gtkpod/trunk/ChangeLog_detailed     2007-06-22 17:34:25 UTC (rev 1574)
@@ -1,3 +1,28 @@
+2007-06-22 Jorg Schuler <jcsjcs at users.sourceforge.net>
+
+       * src/mp3file.c:
+         added reading/writing of tags for sort artist, sort album,
+         sort title, sort albumartist and sort composer.
+
+       * src/mp4file.c:
+
+         Added reading/writing of the grouping tag, whatever that
+         is.
+
+         The sort tags are written by iTunes as fields of the
+         iTunes_CDDB_IDs tag which I don't seem to be able to access
+         (only the first field seems available without hacking). For
+         reference: the field names are soar (artist), sonm (title),
+         soal (album), soaa (album artist), soco (composer) and sosn
+         (show).
+
+         Added reading of coverart tag. Displayed by the iPod but not
+         by the coverart display. Properly displayed in the details
+         window.
+
+       * src/file.c (copy_new_info): use switch() to avoid missing
+          copying new items (like the sort keys).
+
 2007-06-22  Todd Zullinger <tmzullinger at users.sourceforge.net>
 
        * src/fetchcover.c:

Modified: gtkpod/trunk/src/file.c
===================================================================
--- gtkpod/trunk/src/file.c     2007-06-22 15:37:03 UTC (rev 1573)
+++ gtkpod/trunk/src/file.c     2007-06-22 17:34:25 UTC (rev 1574)
@@ -782,6 +782,7 @@
 static void copy_new_info (Track *from, Track *to)
 {
     ExtraTrackData *efrom, *eto;
+    T_item item;
 
     g_return_if_fail (from);
     g_return_if_fail (to);
@@ -790,90 +791,139 @@
     g_return_if_fail (efrom);
     g_return_if_fail (eto);
 
-    g_free (to->title);
-    to->title = g_strdup (from->title);
 
-    g_free (to->artist);
-    to->artist = g_strdup (from->artist);
+    for (item=0; item<T_ITEM_NUM; ++item)
+    {
+       gchar **fromcp, **tocp;
+       switch (item)
+       {
+       case T_ALBUM:
+       case T_ARTIST:
+       case T_TITLE:
+       case T_GENRE:
+       case T_COMMENT:
+       case T_COMPOSER:
+       case T_FILETYPE:
+       case T_DESCRIPTION:
+       case T_PODCASTURL:
+       case T_PODCASTRSS:
+       case T_SUBTITLE:
+       case T_TV_SHOW:
+       case T_TV_EPISODE:
+       case T_TV_NETWORK:
+       case T_THUMB_PATH:
+       case T_PC_PATH:
+       case T_ALBUMARTIST:
+       case T_SORT_ARTIST:
+       case T_SORT_TITLE:
+       case T_SORT_ALBUM:
+       case T_SORT_ALBUMARTIST:
+       case T_SORT_COMPOSER:
+       case T_SORT_TVSHOW:
+           fromcp = track_get_item_pointer (from, item);
+           tocp = track_get_item_pointer (to, item);
+           g_free (*tocp);
+           *tocp = g_strdup (*fromcp);
+           break;
+       case T_GROUPING:
+       case T_CATEGORY:
+           /* not implemented from tags */
+           break;
+       case T_RATING:
+       case T_REMEMBER_PLAYBACK_POSITION:
+       case T_SKIP_WHEN_SHUFFLING:
+       case T_CHECKED:
+       case T_TIME_PLAYED:
+       case T_IPOD_PATH:
+       case T_ALL:
+       case T_IPOD_ID:
+       case T_TRANSFERRED:
+       case T_PLAYCOUNT:
+       case T_VOLUME:
+           /* not applicable */
+           break;
+       case T_YEAR:
+           g_free (eto->year_str);
+           eto->year_str = g_strdup (efrom->year_str);
+           to->year = from->year;
+           break;
+       case T_TRACK_NR:
+           to->track_nr = from->track_nr;
+           to->tracks = from->tracks;
+           break;
+       case T_SIZE:
+           to->size = from->size;
+           break;
+       case T_TRACKLEN:
+           to->tracklen = from->tracklen;
+           break;
+       case T_STARTTIME:
+           to->starttime = from->starttime;
+           break;
+       case T_STOPTIME:
+           to->stoptime = from->stoptime;
+           break;
+       case T_BITRATE:
+           to->bitrate = from->bitrate;
+           break;
+       case T_SAMPLERATE:
+           to->samplerate = from->samplerate;
+           break;
+       case T_BPM:
+           to->BPM = from->BPM;
+           break;
+       case T_TIME_ADDED:
+           to->time_added = from->time_added;
+           break;
+       case T_TIME_MODIFIED:
+           to->time_modified = from->time_modified;
+           eto->mtime = efrom->mtime;
+           break;
+       case T_TIME_RELEASED:
+           to->time_released = from->time_released;
+           break;
+       case T_SOUNDCHECK:
+           to->soundcheck = from->soundcheck;
+           break;
+       case T_CD_NR:
+           to->cd_nr = from->cd_nr;
+           to->cds = from->cds;
+           break;
+       case T_COMPILATION:
+           to->compilation = from->compilation;
+           break;
+       case T_MEDIA_TYPE:
+           to->mediatype = from->mediatype;
+           break;
+       case T_SEASON_NR:
+           to->season_nr = from->season_nr;
+           break;
+       case T_EPISODE_NR:
+           to->episode_nr = from->episode_nr;
+           break;
+       case T_ITEM_NUM:
+           g_return_if_reached ();
+       }
+    }
 
-    g_free (to->album);
-    to->album = g_strdup (from->album);
 
-    g_free (to->genre);
-    to->genre = g_strdup (from->genre);
-
-    g_free (to->composer);
-    to->composer = g_strdup (from->composer);
-
-    g_free (to->comment);
-    to->comment = g_strdup (from->comment);
-
-    g_free (to->filetype);
-    to->filetype = g_strdup (from->filetype);
-
-    g_free (to->description);
-    to->description = g_strdup (from->description);
-
-    g_free (to->podcasturl);
-    to->podcasturl = g_strdup (from->podcasturl);
-
-    g_free (to->podcastrss);
-    to->podcastrss = g_strdup (from->podcastrss);
-
-    g_free (to->subtitle);
-    to->subtitle = g_strdup (from->subtitle);
-
-    g_free (to->tvshow);
-    to->tvshow = g_strdup (from->tvshow);
-
-    g_free (to->tvepisode);
-    to->tvepisode = g_strdup (from->tvepisode);
-
-    g_free (to->tvnetwork);
-    to->tvnetwork = g_strdup (from->tvnetwork);
-
-    g_free (eto->thumb_path_utf8);
-    eto->thumb_path_utf8 = g_strdup (efrom->thumb_path_utf8);
-
     g_free (eto->thumb_path_locale);
     eto->thumb_path_locale = g_strdup (efrom->thumb_path_locale);
 
-    g_free (eto->pc_path_utf8);
-    eto->pc_path_utf8 = g_strdup (efrom->pc_path_utf8);
-
     g_free (eto->pc_path_locale);
     eto->pc_path_locale = g_strdup (efrom->pc_path_locale);
 
     g_free (eto->charset);
     eto->charset = g_strdup (efrom->charset);
 
-    g_free (eto->year_str);
-    eto->year_str = g_strdup_printf ("%d", to->year);
-
     itdb_artwork_free (to->artwork);
     to->artwork = itdb_artwork_duplicate (from->artwork);
     to->artwork_size = from->artwork_size;
     to->artwork_count = from->artwork_count;
     to->has_artwork = from->has_artwork;
 
-    to->size = from->size;
-    to->tracklen = from->tracklen;
-    to->cd_nr = from->cd_nr;
-    to->cds = from->cds;
-    to->track_nr = from->track_nr;
-    to->tracks = from->tracks;
-    to->bitrate = from->bitrate;
-    to->samplerate = from->samplerate;
-    to->soundcheck = from->soundcheck;
-    eto->mtime = efrom->mtime;
-    to->time_added = from->time_added;
-    to->time_modified = from->time_modified;
-    to->year = from->year;
-    to->compilation = from->compilation;
-    to->mediatype = from->mediatype;
     to->lyrics_flag = from->lyrics_flag;
     to->movie_flag = from->movie_flag;
-    to->BPM = from->BPM;
 }
 
 /* Updates mserv data (rating only) of @track using filename @name to

Modified: gtkpod/trunk/src/mp3file.c
===================================================================
--- gtkpod/trunk/src/mp3file.c  2007-06-22 15:37:03 UTC (rev 1573)
+++ gtkpod/trunk/src/mp3file.c  2007-06-22 17:34:25 UTC (rev 1574)
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-06-18 00:48:53 jcs>
+/* Time-stamp: <2007-06-23 01:34:40 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -70,6 +70,11 @@
     gchar *cdno_total;    /* The number of discs in the album (ex: 1/2) */
     gchar *compilation;   /* The track is a member of a compilation */
     gchar *podcasturl;    /* The following are mainly used for podcasts */
+    gchar *sort_artist;
+    gchar *sort_title;
+    gchar *sort_album;
+    gchar *sort_albumartist;
+    gchar *sort_composer;
     gchar *description;
     gchar *podcastrss;
     gchar *time_released;
@@ -1424,6 +1429,11 @@
        tag->description = id3_get_string (id3tag, "YTDS");
        tag->time_released = id3_get_string (id3tag, "YTDR");
        tag->BPM = id3_get_string (id3tag, "TBPM");
+       tag->sort_artist = id3_get_string (id3tag, "TSOP");
+       tag->sort_album = id3_get_string (id3tag, "TSOA");
+       tag->sort_title = id3_get_string (id3tag, "TSOT");
+       tag->sort_albumartist = id3_get_string (id3tag, "TSO2");
+       tag->sort_composer = id3_get_string (id3tag, "TSOC");
 
        string = id3_get_string (id3tag, "TLEN");
        if (string)
@@ -1582,6 +1592,11 @@
        id3_set_string (id3tag, ID3_FRAME_GENRE, track->genre, encoding);
        id3_set_string (id3tag, ID3_FRAME_COMMENT, track->comment, encoding);
        id3_set_string (id3tag, "TIT3", track->subtitle, encoding);
+       id3_set_string (id3tag, "TSOP", track->sort_artist, encoding);
+       id3_set_string (id3tag, "TSOA", track->sort_album, encoding);
+       id3_set_string (id3tag, "TSOT", track->sort_title, encoding);
+       id3_set_string (id3tag, "TSO2", track->sort_albumartist, encoding);
+       id3_set_string (id3tag, "TSOC", track->sort_composer, encoding);
 
        set_uncommon_tag (id3tag, "YTID", track->podcasturl, encoding);
        set_uncommon_tag (id3tag, "YTDS", track->description, encoding);
@@ -2250,6 +2265,31 @@
            track->description = filetag.description;
        }
 
+       if (filetag.sort_artist)
+       {
+           track->sort_artist = filetag.sort_artist;
+       }
+
+       if (filetag.sort_title)
+       {
+           track->sort_title = filetag.sort_title;
+       }
+
+       if (filetag.sort_album)
+       {
+           track->sort_album = filetag.sort_album;
+       }
+
+       if (filetag.sort_albumartist)
+       {
+           track->sort_albumartist = filetag.sort_albumartist;
+       }
+
+       if (filetag.sort_composer)
+       {
+           track->sort_composer = filetag.sort_composer;
+       }
+
        if (filetag.year == NULL)
        {
            track->year = 0;

Modified: gtkpod/trunk/src/mp4file.c
===================================================================
--- gtkpod/trunk/src/mp4file.c  2007-06-22 15:37:03 UTC (rev 1573)
+++ gtkpod/trunk/src/mp4file.c  2007-06-22 17:34:25 UTC (rev 1574)
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-06-18 00:48:52 jcs>
+/* Time-stamp: <2007-06-23 02:24:54 jcs>
 |
 |  Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
 |  Part of the gtkpod project.
@@ -344,6 +344,11 @@
                        track->cd_nr = numvalue;
                        track->cds = numvalue2;
                    }
+                   if (MP4GetMetadataGrouping(mp4File, &value) && value != 
NULL)
+                   {
+                       track->grouping = charset_to_utf8 (value);
+                       g_free (value);
+                   }
                    if (MP4GetMetadataGenre(mp4File, &value) && value != NULL)
                    {
                        track->genre = charset_to_utf8 (value);
@@ -356,6 +361,26 @@
                }
                mp4_scan_soundcheck (mp4File, track);
                audio_or_video_found = TRUE;
+
+               if (prefs_get_int("coverart_apic"))
+               {
+                   u_int8_t *image_data;
+                   u_int32_t image_data_len;
+                   if (MP4GetMetadataCoverArt (mp4File,
+                                               &image_data, &image_data_len))
+                   {
+                       if (image_data)
+                       {
+/*                         FILE *file = fopen ("/tmp/tttt", "w");
+                           fwrite (image_data, 1, image_data_len, file);
+                           fclose (file);*/
+                           gp_track_set_thumbnails_from_data (track,
+                                                              image_data,
+                                                              image_data_len);
+                           g_free (image_data);
+                       }
+                   }
+               }
            }
        }
        if (!audio_or_video_found)
@@ -460,6 +485,8 @@
 
            MP4SetMetadataTempo (mp4File, track->BPM);
 
+           MP4SetMetadataGrouping (mp4File, track->grouping);
+
            value = charset_from_utf8 (track->genre);
            MP4SetMetadataGenre (mp4File, value);
            g_free (value);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to