Neet fixes
This commit is contained in:
parent
b74c5bc5e5
commit
98b5e4d182
10 changed files with 186 additions and 23 deletions
|
|
@ -11,6 +11,23 @@ namespace tp {
|
|||
|
||||
using namespace tp;
|
||||
|
||||
#define AS_STR (int1*) trackProperty.second.to_str().c_str()
|
||||
#define AS_INT std::stoll((int1*) trackProperty.second.to_str().c_str())
|
||||
#define AS_BOOL trackProperty.second.evaluate_as_boolean()
|
||||
#define PROP(name) trackProperty.first == #name
|
||||
|
||||
tp::String getHome() {
|
||||
const char* envVarName = "LIB_VIEW_HOME";
|
||||
char* envVarValue = std::getenv(envVarName);
|
||||
if (envVarValue != nullptr) {
|
||||
tp::String out;
|
||||
out = (int1*) (std::string(envVarValue) + "/").c_str();
|
||||
return out;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
bool Library::loadJson(const String& path) {
|
||||
LocalConnection libraryFile;
|
||||
Buffer<int1> libraryFileMem;
|
||||
|
|
@ -34,12 +51,29 @@ bool Library::loadJson(const String& path) {
|
|||
|
||||
auto & track = trackNode.get<picojson::object>();
|
||||
for (auto & trackProperty : track) {
|
||||
if (trackProperty.first == "Name") {
|
||||
newTrack.mName = (int1*) trackProperty.second.to_str().c_str();
|
||||
}
|
||||
else if (trackProperty.first == "Artist") {
|
||||
newTrack.mArtist = (int1*) trackProperty.second.to_str().c_str();
|
||||
}
|
||||
if (PROP(Name)) newTrack.mName = AS_STR;
|
||||
else if (PROP(Artist)) newTrack.mArtist = AS_STR;
|
||||
else if (PROP(Track ID)) newTrack.mId = AS_INT;
|
||||
else if (PROP(Album Artist)) newTrack.mAlbumArtist = AS_STR;
|
||||
else if (PROP(Composer)) newTrack.mComposer = AS_STR;
|
||||
else if (PROP(Album)) newTrack.mAlbum = AS_STR;
|
||||
else if (PROP(Genre)) newTrack.mGenre = AS_STR;
|
||||
else if (PROP(Size)) newTrack.mSize = AS_INT;
|
||||
else if (PROP(Total Time)) newTrack.mTotalTime = AS_INT;
|
||||
else if (PROP(Year)) newTrack.mYear = AS_INT;
|
||||
else if (PROP(Date Modified)) newTrack.mDateModified = AS_STR;
|
||||
else if (PROP(Date Added)) newTrack.mDateAdded = AS_STR;
|
||||
else if (PROP(Play Count)) newTrack.mPlayCount = AS_INT;
|
||||
else if (PROP(Play Date)) newTrack.mPlayDate = AS_STR;
|
||||
else if (PROP(Play Date UTC)) newTrack.mPlayDateUTC = AS_STR;
|
||||
else if (PROP(Skip Count)) newTrack.mSkipCount = AS_INT;
|
||||
else if (PROP(Skip Date)) newTrack.mSkipDate = AS_STR;
|
||||
else if (PROP(Release Date)) newTrack.mReleaseDate = AS_STR;
|
||||
else if (PROP(Album Rating)) newTrack.mAlbumRating = AS_INT;
|
||||
else if (PROP(Album Rating Computed)) newTrack.mAlbumRatingComputed = AS_BOOL;
|
||||
else if (PROP(Loved)) newTrack.mLoved = AS_BOOL;
|
||||
else if (PROP(Album Loved)) newTrack.mAlbumLoved = AS_BOOL;
|
||||
else if (PROP(Explicit)) newTrack.mExplicit = AS_BOOL;
|
||||
}
|
||||
|
||||
mTraks.append(newTrack);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue