feat: initial database creation, loading
fixes for cartographer and automatically add track to album when adding to artist
This commit is contained in:
parent
72bbcaba9e
commit
62c99ee67c
18 changed files with 515 additions and 108 deletions
|
@ -3,9 +3,10 @@
|
|||
#include <QDebug>
|
||||
#include <string>
|
||||
|
||||
KotoLibraryConfig::KotoLibraryConfig(std::string name, fs::path path) {
|
||||
KotoLibraryConfig::KotoLibraryConfig(std::string name, fs::path path, KotoLibraryType type) {
|
||||
this->i_name = name;
|
||||
this->i_path = path;
|
||||
this->i_type = type;
|
||||
qDebug() << "Library: " << this->i_name.c_str() << " at " << this->i_path.c_str();
|
||||
}
|
||||
|
||||
|
@ -14,6 +15,7 @@ KotoLibraryConfig::~KotoLibraryConfig() {}
|
|||
KotoLibraryConfig::KotoLibraryConfig(const toml::value& v) {
|
||||
this->i_name = toml::find<std::string>(v, "name");
|
||||
this->i_path = toml::find<std::string>(v, "path");
|
||||
this->i_type = libraryTypeFromString(toml::find<std::string>(v, "type"));
|
||||
}
|
||||
|
||||
std::string KotoLibraryConfig::getName() {
|
||||
|
@ -23,3 +25,36 @@ std::string KotoLibraryConfig::getName() {
|
|||
fs::path KotoLibraryConfig::getPath() {
|
||||
return this->i_path;
|
||||
}
|
||||
|
||||
KotoLibraryType KotoLibraryConfig::getType() {
|
||||
return this->i_type;
|
||||
}
|
||||
|
||||
toml::ordered_value KotoLibraryConfig::serialize() {
|
||||
toml::ordered_value library_table(toml::ordered_table {});
|
||||
library_table["name"] = this->i_name;
|
||||
library_table["path"] = this->i_path.string();
|
||||
auto stringifiedType = libraryTypeToString(this->i_type);
|
||||
library_table["type"] = stringifiedType;
|
||||
return library_table;
|
||||
}
|
||||
|
||||
std::string libraryTypeToString(KotoLibraryType type) {
|
||||
switch (type) {
|
||||
case KotoLibraryType::Audiobooks:
|
||||
return std::string {"audiobooks"};
|
||||
case KotoLibraryType::Music:
|
||||
return std::string {"music"};
|
||||
case KotoLibraryType::Podcasts:
|
||||
return std::string {"podcasts"};
|
||||
default:
|
||||
return std::string {"unknown"};
|
||||
}
|
||||
}
|
||||
|
||||
KotoLibraryType libraryTypeFromString(const std::string& type) {
|
||||
if (type == "audiobooks") return KotoLibraryType::Audiobooks;
|
||||
if (type == "music") return KotoLibraryType::Music;
|
||||
if (type == "podcasts") return KotoLibraryType::Podcasts;
|
||||
throw std::invalid_argument("Unknown KotoLibraryType: " + type);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue