Track: Change constructor to take relative paths
I'm going to need to split this value earlier to do a unique lookup when inserting, so the constructor can take the relative path to make things easier. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
cfef5c07a0
commit
4edbd69fa7
|
@ -37,6 +37,7 @@ Track *tagdb :: add_track(const std::string &filepath, Library *library)
|
|||
TagLib :: Tag *tag;
|
||||
TagLib :: AudioProperties *audio;
|
||||
TagLib :: FileRef ref(filepath.c_str(), true, TagLib::AudioProperties::Fast);
|
||||
std::string path = filepath.substr(library->primary_key().size() + 1);
|
||||
|
||||
if (ref.isNull()) {
|
||||
print("WARNING: Could not read tags for file %s\n", filepath.c_str());
|
||||
|
@ -50,7 +51,7 @@ Track *tagdb :: add_track(const std::string &filepath, Library *library)
|
|||
tags :: get_album(tag->album().stripWhiteSpace().to8Bit(true), tag->year()),
|
||||
tags :: get_artist(tag->artist().stripWhiteSpace().to8Bit(true)),
|
||||
tags :: get_genre(tag->genre().stripWhiteSpace().to8Bit(true)),
|
||||
library, filepath,
|
||||
library, path,
|
||||
tag->title().stripWhiteSpace().to8Bit(true),
|
||||
audio->length(), tag->track())
|
||||
);
|
||||
|
|
|
@ -19,8 +19,7 @@ Track :: Track(Album *album, Artist *artist, Genre *genre, Library *library,
|
|||
unsigned int length, unsigned int track)
|
||||
: GenericTag(name),
|
||||
_album(album), _artist(artist), _genre(genre), _library(library),
|
||||
_count(0), _length(length), _track(track),
|
||||
_path(filepath.substr(library->primary_key().size() + 1))
|
||||
_count(0), _length(length), _track(track), _path(filepath)
|
||||
{
|
||||
//filter :: add(name(), index());
|
||||
//filter :: add(_artist->name(), index());
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
* @param artist The artist performing this track.
|
||||
* @param genre The genre describing this track.
|
||||
* @param library The library containing this track.
|
||||
* @param filepath The full filepath of this track.
|
||||
* @param filepath The path of this track, relative to the library root.
|
||||
* @param name The name (title) of this track.
|
||||
* @param length The length of this track (in seconds).
|
||||
* @param track The track number of this track.
|
||||
|
|
|
@ -59,7 +59,7 @@ static void test_track_tag_constructor()
|
|||
{
|
||||
File f("track_tag", 0);
|
||||
Track a(album, artist, genre, library,
|
||||
MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
|
||||
"Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
|
||||
"Legend of Zelda Medley", 288, 13);
|
||||
Track b;
|
||||
|
||||
|
@ -89,7 +89,7 @@ static void test_track_tag_functional()
|
|||
Track track1, track2, track3;
|
||||
|
||||
track1 = Track(album, artist, genre, library,
|
||||
MUSIC_DIR + "/Hyrule Symphony/6 - Kakariko Village.mp3",
|
||||
"Hyrule Symphony/6 - Kakariko Village.mp3",
|
||||
"Kakariko Village", 186, 6);
|
||||
track1.played();
|
||||
test_equal(track1.length_str(), (std::string)"3:06");
|
||||
|
@ -119,7 +119,7 @@ static void test_track_tag_functional()
|
|||
|
||||
/* Not an actual track on the album, I just needed something < 1 min. */
|
||||
track2 = Track(album, artist, genre, library,
|
||||
MUSIC_DIR + "/Hyrule Symphony/0 - intro.mp3",
|
||||
"Hyrule Symphony/0 - intro.mp3",
|
||||
"Intro", 56, 0);
|
||||
test_equal(track2.length_str(), (std::string)"0:56");
|
||||
|
||||
|
|
Loading…
Reference in New Issue