After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 522909 - Add a Year filename tag
Add a Year filename tag
Status: RESOLVED FIXED
Product: sound-juicer
Classification: Applications
Component: interface
2.22.x
Other Linux
: Normal enhancement
: ---
Assigned To: Sound Juicer Maintainers
Sound Juicer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-03-17 10:15 UTC by Ross Burton
Modified: 2008-06-17 08:23 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
Patch to use album's year in a file path pattern (1.72 KB, patch)
2008-04-13 03:42 UTC, Juan F. Giménez Silva
none Details | Review
Patch to use album's release year in a file pattern (1.46 KB, patch)
2008-05-27 13:59 UTC, Juan F. Giménez Silva
none Details | Review
Path that allows to use a file pattern with album's year (1.46 KB, patch)
2008-05-27 14:06 UTC, Juan F. Giménez Silva
committed Details | Review

Description Ross Burton 2008-03-17 10:15:00 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.
Comment 1 Juan F. Giménez Silva 2008-04-13 03:42:19 UTC
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.
Comment 2 Carlos Garnacho 2008-05-22 14:09:43 UTC
Looks like you should check whether track->album->release_date is not NULL
Comment 3 Martin Olsson 2008-05-22 17:48:28 UTC
Also, everyone else is calling sanitize_path() maybe you should also do that?
Comment 4 Juan F. Giménez Silva 2008-05-27 13:59:37 UTC
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 5 Juan F. Giménez Silva 2008-05-27 14:02:14 UTC
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}
Comment 6 Juan F. Giménez Silva 2008-05-27 14:06:45 UTC
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 :(.
Comment 7 Ross Burton 2008-06-17 08:23:29 UTC
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.