Discussion:
[PATCH 2/2] track_info: use path_basename() as a best guess for missing track title
Gregory Petrosyan
2011-09-29 15:37:23 UTC
Permalink
Signed-off-by: Gregory Petrosyan <***@gmail.com>
---
cache.c | 2 +-
track_info.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/cache.c b/cache.c
index 53ab2a0..0558b3c 100644
--- a/cache.c
+++ b/cache.c
@@ -252,7 +252,7 @@ int cache_init(void)
cache_header[4] = flags & 0xff;

/* assumed version */
- cache_header[3] = 0x06;
+ cache_header[3] = 0x07;

cache_filename = xstrjoin(cmus_config_dir, "/cache");
return read_cache();
diff --git a/track_info.c b/track_info.c
index c57e985..2109a4d 100644
--- a/track_info.c
+++ b/track_info.c
@@ -24,6 +24,7 @@
#include "xmalloc.h"
#include "utils.h"
#include "debug.h"
+#include "path.h"

#include <string.h>
#include <math.h>
@@ -70,6 +71,11 @@ void track_info_set_comments(struct track_info *ti, struct keyval *comments) {
ti->artistsort = comments_get_artistsort(comments);
ti->is_va_compilation = track_is_va_compilation(comments);

+ if (track_info_has_tag(ti) && ti->title == NULL) {
+ /* best guess */
+ ti->title = path_basename(ti->filename);
+ }
+
ti->rg_track_gain = comments_get_double(comments, "replaygain_track_gain");
ti->rg_track_peak = comments_get_double(comments, "replaygain_track_peak");
ti->rg_album_gain = comments_get_double(comments, "replaygain_album_gain");
--
1.7.4.4
Loading...