Discussion:
[PATCH] Add "media" to sort, filter and format options
Johannes Weißl
2011-12-03 04:04:40 UTC
Permalink
With this field you can describe the source media your digital files
have originated from.

TMED in ID3v2, MEDIA (and SOURCEMEDIA as alias) in free form tags.

http://musicbrainz.org/doc/Picard_Tag_Mapping
http://age.hobba.nl/audio/mirroredpages/ogg-tagging.html
---
Doc/cmus.txt | 5 +++--
comment.c | 4 +++-
expr.c | 1 +
id3.c | 2 ++
id3.h | 1 +
options.c | 1 +
track_info.c | 1 +
track_info.h | 2 ++
ui_curses.c | 3 +++
9 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Doc/cmus.txt b/Doc/cmus.txt
index b34099f..c1b4654 100644
--- a/Doc/cmus.txt
+++ b/Doc/cmus.txt
@@ -997,6 +997,7 @@ Special Keys:
%{partnumber} @br
%{part} @br
%{subtitle} @br
+ %{media} @br
%=
start align right (use at most once)
%%
@@ -1027,7 +1028,7 @@ sort keys:

artist, album, title, tracknumber, discnumber, date, originaldate,
genre, comment, albumartist, filename, filemtime, bitrate, codec,
- codec_profile, rg_track_gain, rg_track_peak, rg_album_gain,
+ media, codec_profile, rg_track_gain, rg_track_peak, rg_album_gain,
rg_album_peak


@@ -1158,7 +1159,7 @@ built-in filters. Also (and)-grouping is done implicitly.

@li long
*filename*, *artist*, *albumartist*, *album*, *title*, *genre*, *comment*,
-*codec*, *codec_profile*
+*codec*, *codec_profile*, *media*
@br
Comparators: *=* and *!=* (not equal)

diff --git a/comment.c b/comment.c
index 887df6c..12c7ce4 100644
--- a/comment.c
+++ b/comment.c
@@ -169,7 +169,7 @@ static const char *interesting[] = {
"comment",
"arranger", "composer", "conductor", "lyricist", "performer",
"remixer", "label", "publisher", "work", "opus", "partnumber", "part",
- "subtitle",
+ "subtitle", "media",
NULL
};

@@ -185,6 +185,8 @@ static struct {
{ "WM/ArtistSortOrder", "artistsort" },
{ "WM/AlbumArtistSortOrder", "albumartistsort" },
{ "WM/OriginalReleaseYear", "originaldate" },
+ { "WM/Media", "media" },
+ { "sourcemedia", "media" },
{ "MusicBrainz Track Id", "musicbrainz_trackid" },
{ "version", "subtitle" },
{ NULL, NULL }
diff --git a/expr.c b/expr.c
index cc680ab..d159552 100644
--- a/expr.c
+++ b/expr.c
@@ -434,6 +434,7 @@ static const struct {
{ "duration", EXPR_INT },
{ "filename", EXPR_STR },
{ "genre", EXPR_STR },
+ { "media", EXPR_STR },
{ "originaldate",EXPR_INT },
{ "stream", EXPR_BOOL },
{ "tag", EXPR_BOOL },
diff --git a/id3.c b/id3.c
index 77d0457..500a716 100644
--- a/id3.c
+++ b/id3.c
@@ -262,6 +262,7 @@ const char * const id3_key_names[NUM_ID3_KEYS] = {
"subtitle",
"comment",
"musicbrainz_trackid",
+ "media",
};

static int utf16_is_lsurrogate(uchar uch)
@@ -566,6 +567,7 @@ static struct {
{ "TPE4", ID3_REMIXER },
{ "TPUB", ID3_PUBLISHER }, // TPUB can be both publisher or label
{ "TIT3", ID3_SUBTITLE },
+ { "TMED", ID3_MEDIA },

/* obsolete frames (2.2.0) */
{ "TP1", ID3_ARTIST },
diff --git a/id3.h b/id3.h
index f1b5b7c..89a4454 100644
--- a/id3.h
+++ b/id3.h
@@ -49,6 +49,7 @@ enum id3_key {
ID3_SUBTITLE,
ID3_COMMENT,
ID3_MUSICBRAINZ_TRACKID,
+ ID3_MEDIA,

NUM_ID3_KEYS
};
diff --git a/options.c b/options.c
index ff86e2e..d7d6c23 100644
--- a/options.c
+++ b/options.c
@@ -241,6 +241,7 @@ static const struct {
{ "bitrate", SORT_BITRATE },
{ "codec", SORT_CODEC },
{ "codec_profile", SORT_CODEC_PROFILE },
+ { "media", SORT_MEDIA },
{ NULL, SORT_INVALID }
};

diff --git a/track_info.c b/track_info.c
index 614a92c..8779bc0 100644
--- a/track_info.c
+++ b/track_info.c
@@ -70,6 +70,7 @@ void track_info_set_comments(struct track_info *ti, struct keyval *comments) {
ti->albumartist = comments_get_albumartist(comments);
ti->artistsort = comments_get_artistsort(comments);
ti->is_va_compilation = track_is_va_compilation(comments);
+ ti->media = keyvals_get_val(comments, "media");

if (ti->artist == NULL && ti->albumartist != NULL) {
/* best guess */
diff --git a/track_info.h b/track_info.h
index 6902cfb..18ddb8c 100644
--- a/track_info.h
+++ b/track_info.h
@@ -51,6 +51,7 @@ struct track_info {
const char *comment;
const char *albumartist;
const char *artistsort;
+ const char *media;

char *collkey_artist;
char *collkey_album;
@@ -83,6 +84,7 @@ typedef size_t sort_key_t;
#define SORT_BITRATE offsetof(struct track_info, bitrate)
#define SORT_CODEC offsetof(struct track_info, codec)
#define SORT_CODEC_PROFILE offsetof(struct track_info, codec_profile)
+#define SORT_MEDIA offsetof(struct track_info, media)
#define SORT_INVALID ((sort_key_t) (-1))

#define TI_MATCH_ARTIST (1 << 0)
diff --git a/ui_curses.c b/ui_curses.c
index c1b75aa..2ef05f2 100644
--- a/ui_curses.c
+++ b/ui_curses.c
@@ -246,6 +246,7 @@ enum {
TF_PARTNUMBER,
TF_PART,
TF_SUBTITLE,
+ TF_MEDIA,
NR_TFS
};

@@ -283,6 +284,7 @@ static struct format_option track_fopts[NR_TFS + 1] = {
DEF_FO_STR('\0', "partnumber", 0),
DEF_FO_STR('\0', "part", 0),
DEF_FO_STR('\0', "subtitle", 0),
+ DEF_FO_STR('\0', "media", 0),
DEF_FO_END
};

@@ -609,6 +611,7 @@ static void fill_track_fopts_track_info(struct track_info *info)
fopt_set_str(&track_fopts[TF_PARTNUMBER], keyvals_get_val(info->comments, "partnumber"));
fopt_set_str(&track_fopts[TF_PART], keyvals_get_val(info->comments, "part"));
fopt_set_str(&track_fopts[TF_SUBTITLE], keyvals_get_val(info->comments, "subtitle"));
+ fopt_set_str(&track_fopts[TF_MEDIA], keyvals_get_val(info->comments, "media"));
if (is_http_url(info->filename)) {
fopt_set_str(&track_fopts[TF_FILE], filename);
} else {
--
1.7.7.1
Gregory Petrosyan
2011-12-03 20:02:38 UTC
Permalink
Post by Johannes Weißl
With this field you can describe the source media your digital files
have originated from.
TMED in ID3v2, MEDIA (and SOURCEMEDIA as alias) in free form tags.
http://musicbrainz.org/doc/Picard_Tag_Mapping
http://age.hobba.nl/audio/mirroredpages/ogg-tagging.html
Thanks again, merged to master!

Gregory

Loading...