From 319c9699fb09e7c35e2aafa022ff8e1f0dcfcd8b Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Tue, 21 May 2019 22:23:06 +0200
Subject: [PATCH] tag/Type: add TAG_GROUPING

Map ID3 "TIT1" to this new core tag type.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/563
---
 NEWS                | 2 ++
 doc/protocol.rst    | 3 +++
 src/tag/Id3Scan.cxx | 3 ++-
 src/tag/Id3Scan.hxx | 2 +-
 src/tag/Names.c     | 3 ++-
 src/tag/Type.h      | 3 ++-
 6 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index de839ce21..5db16df52 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ ver 0.22 (not yet released)
 * protocol
   - "findadd"/"searchadd"/"searchaddpl" support the "sort" and
     "window" parameters
+* tags
+  - new tag "Grouping" (for ID3 "TIT1")
 * input
   - ffmpeg: allow partial reads
 * filter
diff --git a/doc/protocol.rst b/doc/protocol.rst
index 187c6ed32..381e3cab7 100644
--- a/doc/protocol.rst
+++ b/doc/protocol.rst
@@ -274,6 +274,9 @@ The following tags are supported by :program:`MPD`:
 * **date**: the song's release date. This is usually a 4-digit year.
 * **composer**: the artist who composed the song.
 * **performer**: the artist who performed the song.
+* **grouping**: "used if the sound belongs to a larger category of
+  sounds/music" (`from the IDv2.4.0 TIT1 description
+  <http://id3.org/id3v2.4.0-frames>`_).
 * **comment**: a human-readable comment about this song. The exact meaning of this tag is not well-defined.
 * **disc**: the decimal disc number in a multi-disc album.
 * **label**: the name of the label or publisher.
diff --git a/src/tag/Id3Scan.cxx b/src/tag/Id3Scan.cxx
index b32b1a37b..faf98cc00 100644
--- a/src/tag/Id3Scan.cxx
+++ b/src/tag/Id3Scan.cxx
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2019 The Music Player Daemon Project
  * http://www.musicpd.org
  *
  * This program is free software; you can redistribute it and/or modify
@@ -317,6 +317,7 @@ scan_id3_tag(const struct id3_tag *tag, TagHandler &handler) noexcept
 	tag_id3_import_text(tag, "TPE3", TAG_PERFORMER,
 			    handler);
 	tag_id3_import_text(tag, "TPE4", TAG_PERFORMER, handler);
+	tag_id3_import_text(tag, "TIT1", TAG_GROUPING, handler);
 	tag_id3_import_comment(tag, ID3_FRAME_COMMENT, TAG_COMMENT,
 			       handler);
 	tag_id3_import_text(tag, ID3_FRAME_DISC, TAG_DISC,
diff --git a/src/tag/Id3Scan.hxx b/src/tag/Id3Scan.hxx
index 34ca73c68..0446258bb 100644
--- a/src/tag/Id3Scan.hxx
+++ b/src/tag/Id3Scan.hxx
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2019 The Music Player Daemon Project
  * http://www.musicpd.org
  *
  * This program is free software; you can redistribute it and/or modify
diff --git a/src/tag/Names.c b/src/tag/Names.c
index f330f7f70..a3a575ea6 100644
--- a/src/tag/Names.c
+++ b/src/tag/Names.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2019 The Music Player Daemon Project
  * http://www.musicpd.org
  *
  * This program is free software; you can redistribute it and/or modify
@@ -34,6 +34,7 @@ const char *const tag_item_names[TAG_NUM_OF_ITEM_TYPES] = {
 	[TAG_ORIGINAL_DATE] = "OriginalDate",
 	[TAG_COMPOSER] = "Composer",
 	[TAG_PERFORMER] = "Performer",
+	[TAG_GROUPING] = "Grouping",
 	[TAG_COMMENT] = "Comment",
 	[TAG_DISC] = "Disc",
 	[TAG_LABEL] = "Label",
diff --git a/src/tag/Type.h b/src/tag/Type.h
index 07429688e..0a7b98e7b 100644
--- a/src/tag/Type.h
+++ b/src/tag/Type.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2018 The Music Player Daemon Project
+ * Copyright 2003-2019 The Music Player Daemon Project
  * http://www.musicpd.org
  *
  * This program is free software; you can redistribute it and/or modify
@@ -49,6 +49,7 @@ enum TagType
 	TAG_ORIGINAL_DATE,
 	TAG_COMPOSER,
 	TAG_PERFORMER,
+	TAG_GROUPING,
 	TAG_COMMENT,
 	TAG_DISC,
 	TAG_LABEL,