diff options
author | Robert Keevil <rkeevil+rockbox@gmail.com> | 2008-10-07 18:39:44 +0000 |
---|---|---|
committer | Robert Keevil <rkeevil+rockbox@gmail.com> | 2008-10-07 18:39:44 +0000 |
commit | 2c170356f38f5630b9fefdc5b1e7e57babb5cc40 (patch) | |
tree | 9ba565416427f76e6cf4754ef199ed02f804edf6 | |
parent | 7eb194477a19a12d76bceb64108ffad2da784c9f (diff) |
FS#9139 - support for ver 1.1 scrobbler log files. Upload any old files first - uploading software may need updating, see the LastFMLog wiki page
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18732 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/metadata/asf.c | 3 | ||||
-rw-r--r-- | apps/metadata/metadata_common.c | 5 | ||||
-rw-r--r-- | apps/metadata/mp4.c | 5 | ||||
-rw-r--r-- | apps/scrobbler.c | 14 | ||||
-rw-r--r-- | firmware/export/id3.h | 3 | ||||
-rw-r--r-- | firmware/id3.c | 28 |
6 files changed, 52 insertions, 6 deletions
diff --git a/apps/metadata/asf.c b/apps/metadata/asf.c index fa1308b560..255a0bcba4 100644 --- a/apps/metadata/asf.c +++ b/apps/metadata/asf.c @@ -465,6 +465,9 @@ static int asf_parse_header(int fd, struct mp3entry* id3, id3buf = value; id3buf_remaining = buf_len; } + } else if (!strcmp("MusicBrainz/Track Id", utf8buf)) { + id3->mb_track_id = id3buf; + asf_utf16LEdecode(fd, length, &id3buf, &id3buf_remaining); } else { lseek(fd, length, SEEK_CUR); } diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c index 1fff030e57..e4df874cff 100644 --- a/apps/metadata/metadata_common.c +++ b/apps/metadata/metadata_common.c @@ -293,6 +293,11 @@ long parse_tag(const char* name, char* value, struct mp3entry* id3, { p = &(id3->grouping); } + else if (strcasecmp(name, "musicbrainz_trackid") == 0 + || strcasecmp(name, "http://musicbrainz.org") == 0 ) + { + p = &(id3->mb_track_id); + } else { len = parse_replaygain(name, value, id3, buf, buf_remaining); diff --git a/apps/metadata/mp4.c b/apps/metadata/mp4.c index 187459b7fb..493bc48da7 100644 --- a/apps/metadata/mp4.c +++ b/apps/metadata/mp4.c @@ -498,6 +498,11 @@ static bool read_mp4_tags(int fd, struct mp3entry* id3, DEBUGF("AAC: lead_trim %d, tail_trim %d\n", id3->lead_trim, id3->tail_trim); } + else if (strcasecmp(tag_name, "musicbrainz track id") == 0) + { + read_mp4_tag_string(fd, size, &buffer, &buffer_left, + &id3->mb_track_id); + } else { char* any; diff --git a/apps/scrobbler.c b/apps/scrobbler.c index 7af45a0c8f..3b35e0d66a 100644 --- a/apps/scrobbler.c +++ b/apps/scrobbler.c @@ -7,7 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright (C) 2006 Robert Keevil + * Copyright (C) 2006-2008 Robert Keevil * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -42,7 +42,7 @@ http://www.audioscrobbler.net/wiki/Portable_Player_Logging #include "scrobbler.h" -#define SCROBBLER_VERSION "1.0" +#define SCROBBLER_VERSION "1.1" #if CONFIG_RTC #define SCROBBLER_FILE "/.scrobbler.log" @@ -151,24 +151,26 @@ static void add_to_cache(unsigned long play_length) { ret = snprintf(scrobbler_cache+(SCROBBLER_CACHE_LEN*cache_pos), SCROBBLER_CACHE_LEN, - "%s\t%s\t%s\t%d\t%d\t%c\t%ld\n", + "%s\t%s\t%s\t%d\t%d\t%c\t%ld\t%s\n", scrobbler_entry.artist, scrobbler_entry.album?scrobbler_entry.album:"", scrobbler_entry.title, scrobbler_entry.tracknum, (int)scrobbler_entry.length/1000, rating, - (long)timestamp); + (long)timestamp, + scrobbler_entry.mb_track_id?scrobbler_entry.mb_track_id:""); } else { ret = snprintf(scrobbler_cache+(SCROBBLER_CACHE_LEN*cache_pos), SCROBBLER_CACHE_LEN, - "%s\t%s\t%s\t\t%d\t%c\t%ld\n", + "%s\t%s\t%s\t\t%d\t%c\t%ld\t%s\n", scrobbler_entry.artist, scrobbler_entry.album?scrobbler_entry.album:"", scrobbler_entry.title, (int)scrobbler_entry.length/1000, rating, - (long)timestamp); + (long)timestamp, + scrobbler_entry.mb_track_id?scrobbler_entry.mb_track_id:""); } if ( ret >= SCROBBLER_CACHE_LEN ) diff --git a/firmware/export/id3.h b/firmware/export/id3.h index 3e4db0674f..da2faf1b12 100644 --- a/firmware/export/id3.h +++ b/firmware/export/id3.h @@ -223,6 +223,9 @@ struct mp3entry { /* Cuesheet support */ int cuesheet_type; /* 0: none, 1: external, 2: embedded */ + + /* Musicbrainz Track ID */ + char* mb_track_id; }; enum { diff --git a/firmware/id3.c b/firmware/id3.c index 3b7d165597..c1541e30df 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -486,6 +486,31 @@ static int parserva2( struct mp3entry* entry, char* tag, int bufferpos ) } #endif +static int parsembtid( struct mp3entry* entry, char* tag, int bufferpos ) +{ + char* value = NULL; + int desc_len = strlen(tag); + /*DEBUGF("MBID len: %d\n", desc_len);*/ + int value_len = 0; + + if ((tag - entry->id3v2buf + desc_len + 2) < bufferpos) + { + value = tag + desc_len + 1; + + if (strcasecmp(tag, "http://musicbrainz.org") == 0) + { + /* Musicbrainz track IDs are always 36 chars long plus null */ + value_len = 37; + + entry->mb_track_id = value; + + /*DEBUGF("ENTRY: %s LEN: %d\n", entry->mb_track_id, strlen(entry->mb_track_id));*/ + } + } + + return tag - entry->id3v2buf + value_len; +} + static const struct tag_resolver taglist[] = { { "TPE1", 4, offsetof(struct mp3entry, artist), NULL, false }, { "TP1", 3, offsetof(struct mp3entry, artist), NULL, false }, @@ -511,6 +536,7 @@ static const struct tag_resolver taglist[] = { { "TXXX", 4, 0, &parseuser, false }, { "RVA2", 4, 0, &parserva2, true }, #endif + { "UFID", 4, 0, &parsembtid, false }, }; #define TAGLIST_SIZE ((int)(sizeof(taglist) / sizeof(taglist[0]))) @@ -1261,6 +1287,8 @@ void adjust_mp3entry(struct mp3entry *entry, void *dest, const void *orig) if (entry->album_gain_string) entry->album_gain_string += offset; #endif + if (entry->mb_track_id) + entry->mb_track_id += offset; } void copy_mp3entry(struct mp3entry *dest, const struct mp3entry *orig) |