diff options
author | Ross Burton <ross@burtonini.com> | 2008-01-22 20:46:34 +0000 |
---|---|---|
committer | Ross Burton <rburton@src.gnome.org> | 2008-01-22 20:46:34 +0000 |
commit | 9c1598bafdd4c31157a4bcd46ddad798eb5437ff (patch) | |
tree | b5710881f438e095602b38ac7073ea4af9a2cc73 /libjuicer | |
parent | aaecdefd3cdfa1ca4d83e9d675a3634e953aea3b (diff) |
Look for album titles with "(disc X)" in and extract the disc number.
2008-01-22 Ross Burton <ross@burtonini.com>
* libjuicer/sj-metadata-musicbrainz.c:
Look for album titles with "(disc X)" in and extract the disc number.
* src/sj-main.c:
Update the UI from the disk number if it is set.
#510439, thanks to Matthew Martin.
svn path=/trunk/; revision=1996
Diffstat (limited to 'libjuicer')
-rw-r--r-- | libjuicer/sj-metadata-musicbrainz.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libjuicer/sj-metadata-musicbrainz.c b/libjuicer/sj-metadata-musicbrainz.c index 254ed56..f980ad5 100644 --- a/libjuicer/sj-metadata-musicbrainz.c +++ b/libjuicer/sj-metadata-musicbrainz.c @@ -58,6 +58,7 @@ struct SjMetadataMusicbrainzPrivate { /* TODO: remove and use an async queue? */ GList *albums; GError *error; + GRegex *disc_regex; }; #define GET_PRIVATE(o) \ @@ -330,6 +331,7 @@ lookup_cd (SjMetadata *metadata) SjMetadataMusicbrainzPrivate *priv; GList *albums = NULL; GList *al, *tl; + GMatchInfo *info; char data[256]; int num_albums, i, j; NautilusBurnMediaType type; @@ -421,6 +423,22 @@ lookup_cd (SjMetadata *metadata) album->title = g_strdup (_("Unknown Title")); } + if (g_regex_match (priv->disc_regex, album->title, 0, &info)) { + int pos = 0; + char *s; + + g_match_info_fetch_pos (info, 1, &pos, NULL); + if (pos) { + g_free (album->title); + album->title = g_strndup (album->title, pos); + } + + s = g_match_info_fetch (info, 2); + album->disc_number = atoi (s); + g_free (s); + } + g_match_info_free (info); + { int num_releases; num_releases = mb_GetResultInt (priv->mb, MBE_AlbumGetNumReleaseDates); @@ -633,6 +651,8 @@ sj_metadata_musicbrainz_init (SjMetadataMusicbrainz *self) if (g_getenv("MUSICBRAINZ_DEBUG")) { mb_SetDebug (self->priv->mb, TRUE); } + + self->priv->disc_regex = g_regex_new (".+( \\(disc (\\d+).*)", 0, 0, NULL); } static void @@ -698,6 +718,7 @@ sj_metadata_musicbrainz_finalize (GObject *object) g_free (priv->http_proxy); g_free (priv->cdrom); + g_regex_unref (priv->disc_regex); mb_Delete (priv->mb); G_OBJECT_CLASS (sj_metadata_musicbrainz_parent_class)->finalize (object); |