[easytag/wip/disc-number: 7/9] Add total discs support to Vorbis tag parser



commit a3c33d4867c1e5a786d72535fcbad5488a469495
Author: Mathias Reineke <saihtam gmx net>
Date:   Mon Jul 8 10:58:09 2013 +0200

    Add total discs support to Vorbis tag parser

 src/ogg_tag.c |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/src/ogg_tag.c b/src/ogg_tag.c
index a206683..2b17d03 100644
--- a/src/ogg_tag.c
+++ b/src/ogg_tag.c
@@ -309,12 +309,32 @@ ogg_tag_read_file_tag (gchar *filename, File_Tag *FileTag, GError **error)
         g_free(string);
     }
 
-    /*******************************
-     * Disc Number (Part of a Set) *
-     *******************************/
-    if ( (string = vorbis_comment_query(vc,"DISCNUMBER",0)) != NULL && g_utf8_strlen(string, -1) > 0 )
+    /**********************************************
+     * Disc Number (Part of a Set) and Disc Total *
+     **********************************************/
+    if ((string = vorbis_comment_query (vc, "DISCNUMBER", 0)) != NULL
+        && g_utf8_strlen (string, -1) > 0)
     {
-        FileTag->disc_number = g_strdup(string);
+        FileTag->disc_number = g_strdup (string);
+    }
+
+    if ((string = vorbis_comment_query (vc, "DISCNUMBER", 0)) != NULL
+        && g_utf8_strlen (string, -1) > 0)
+    {
+        /* Check if DISCTOTAL used, else takes it in DISCNUMBER. */
+        if ((string1 = vorbis_comment_query (vc, "DISCTOTAL", 0)) != NULL
+            && g_utf8_strlen (string1, -1) > 0)
+        {
+            FileTag->disc_total = et_disc_number_to_string (atoi (string1));
+        }
+        else if ((string1 = g_utf8_strchr (string, -1, '/')))
+        {
+            FileTag->disc_total = et_disc_number_to_string (atoi (string1
+                                                                  + 1));
+            *string1 = '\0';
+        }
+
+        FileTag->disc_number = et_disc_number_to_string (atoi (string));
     }
 
     /********
@@ -787,6 +807,7 @@ ogg_tag_write_file_tag (ET_File *ETFile, GError **error)
      * Disc Number *
      ***************/
     Ogg_Set_Tag(vc,"DISCNUMBER=",FileTag->disc_number,FALSE);
+    Ogg_Set_Tag (vc, "DISCTOTAL=", FileTag->disc_total, FALSE);
 
     /********
      * Year *


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