GNOME Bugzilla – Bug 522909
Add a Year filename tag
Last modified: 2008-06-17 08:23:29 UTC
[from Debian BTS #471294] I use to structure my music repository this way: Artist/Year - AlbumTitle/XX - SongTitle Now that the year tag is used by sound-juicer it would be nice to include this way to structure the repository.
Created attachment 109159 [details] [review] Patch to use album's year in a file path pattern This patch allows to select a pattern with the following pattern: "Artist/Year - AlbumTitle/" It modifies src/sj-extracting.c src/sj-prefs.c I can't figure why, it throws the following warning: "(sound-juicer:17128): GLib-CRITICAL **: g_date_get_year: assertion `g_date_valid (d)' failed (sound-juicer:17128): GLib-CRITICAL **: g_date_valid: assertion `d != NULL' failed" However the patch works as desired. Hope that helps.
Looks like you should check whether track->album->release_date is not NULL
Also, everyone else is calling sanitize_path() maybe you should also do that?
Created attachment 111606 [details] [review] Patch to use album's release year in a file pattern I think the warning problem is solved now, thanks a lot for your advices. I hope you like this patch :). It uses sanitize_path() and checks if the release date is not null and a valid GDate.
Comment on attachment 111606 [details] [review] Patch to use album's release year in a file pattern index 1c68020..ad3ca58 100644 --- a/src/sj-extracting.c +++ b/src/sj-extracting.c @@ -854,6 +854,7 @@ sanitize_path (const char* str, const char* filesystem_type) * * Valid markers so far are: * %at -- album title + * %ay -- album year * %aa -- album artist * %aA -- album artist (lowercase) * %as -- album artist sortname @@ -926,6 +927,13 @@ filepath_parse_pattern (const char* pattern, const TrackDetails *track) case 't': string = sanitize_path (track->album->title, filesystem_type); break; + case 'y': + if (track->album->release_date && g_date_valid(track->album->release_date)) { + string = sanitize_path (g_strdup_printf("%d", g_date_get_year(track->album->release_date)), filesystem_type); + } else { + + } + break; case 'T': tmp = g_utf8_strdown (track->album->title, -1); string = sanitize_path (tmp, filesystem_type); diff --git a/src/sj-prefs.c b/src/sj-prefs.c index 5619e3e..26cb217 100644 --- a/src/sj-prefs.c +++ b/src/sj-prefs.c @@ -59,6 +59,7 @@ static const FilePattern path_patterns[] = { {N_("Album Artist"), "%aa"}, {N_("Album Artist (sortable)"), "%as"}, {N_("Album Artist - Album Title"), "%aa - %at"}, + {N_("Album Artist, Album Year - Album Title"), "%aa/%ay - %at"}, {N_("Album Artist (sortable) - Album Title"), "%as - %at"}, {N_("[none]"), "./"}, {NULL, NULL}
Created attachment 111607 [details] [review] Path that allows to use a file pattern with album's year I think the warning problem is solved now, thanks a lot for your advices. I hope you like this patch :). It uses sanitize_path() and checks if the release date is not null and a valid GDate. Sorry guys, I really messed up with the last patch (in a really really stupid way). It wont happen again, please forgive me :(.
You need to document the tags in the schemas file, and the case statement was leaking a string as well as having an empty else {} block. I've fixed all of those and committed to trunk. I won't commit the second chunk adding a new pattern because the list is getting silly already. There is a bug for a better pattern editor which is where this should be followed up.