Switching to C++ #60
@@ -14,11 +14,11 @@ public:
|
||||
base_repository(const std::string&);
|
||||
protected:
|
||||
MYSQL* setup_mysql_connection();
|
||||
MYSQL* setup_mysql_connection(database_connection);
|
||||
MYSQL* setup_mysql_connection(Model::database_connection);
|
||||
|
||||
MYSQL_RES* perform_mysql_query(MYSQL*, const std::string&);
|
||||
|
||||
database_connection details;
|
||||
Model::database_connection details;
|
||||
private:
|
||||
void intitalizeDetails();
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ class coverArtRepository : public base_repository
|
||||
public:
|
||||
coverArtRepository(const std::string&);
|
||||
|
||||
Cover retrieveRecord(Cover&, coverFilter);
|
||||
Model::Cover retrieveRecord(Model::Cover&, coverFilter);
|
||||
|
||||
void deleteRecord(const Cover&);
|
||||
void saveRecord(const Cover&);
|
||||
void deleteRecord(const Model::Cover&);
|
||||
void saveRecord(const Model::Cover&);
|
||||
private:
|
||||
Cover parseRecord(MYSQL_RES*);
|
||||
Model::Cover parseRecord(MYSQL_RES*);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,16 +15,16 @@ class songRepository : public base_repository
|
||||
public:
|
||||
songRepository(const std::string&);
|
||||
|
||||
std::vector<Song> retrieveRecords();
|
||||
std::vector<Model::Song> retrieveRecords();
|
||||
|
||||
Song retrieveRecord(Song&, songFilter);
|
||||
Model::Song retrieveRecord(Model::Song&, songFilter);
|
||||
|
||||
void deleteRecord(const Song&);
|
||||
void saveRecord(const Song&);
|
||||
void deleteRecord(const Model::Song&);
|
||||
void saveRecord(const Model::Song&);
|
||||
private:
|
||||
std::vector<Song> parseRecords(MYSQL_RES*);
|
||||
std::vector<Model::Song> parseRecords(MYSQL_RES*);
|
||||
|
||||
Song parseRecord(MYSQL_RES*);
|
||||
Model::Song parseRecord(MYSQL_RES*);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,7 @@ class coverArtManager
|
||||
public:
|
||||
coverArtManager(const std::string&);
|
||||
|
||||
Cover saveCover(const Song&, std::string&, const std::string&);
|
||||
Model::Cover saveCover(const Model::Song&, std::string&, const std::string&);
|
||||
private:
|
||||
std::string path;
|
||||
};
|
||||
|
||||
@@ -12,24 +12,19 @@ class directory_manager
|
||||
{
|
||||
public:
|
||||
|
||||
static std::string create_directory_process(Song, const std::string&);
|
||||
static std::string create_directory_process(Model::Song, const std::string&);
|
||||
static std::string configPath(std::string_view);
|
||||
static std::string contentOfPath(std::string_view);
|
||||
|
||||
static nlohmann::json credentialConfigContent(const std::string&);
|
||||
static nlohmann::json databaseConfigContent(const std::string&);
|
||||
static nlohmann::json pathConfigContent(const std::string&);
|
||||
// Return Cover instead
|
||||
//std::string read_cover_art(const std::string&);
|
||||
|
||||
|
||||
//void copy_stock_to_root(const std::string&, const std::string&);
|
||||
//void copy_song_to_path(const std::string&, const std::string&);
|
||||
void delete_cover_art_file(const std::string&, const std::string&);
|
||||
static void delete_directories(Song, const std::string&);
|
||||
static void delete_directories(Model::Song, const std::string&);
|
||||
|
||||
private:
|
||||
void delete_song(const Song);
|
||||
void delete_song(const Model::Song);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,12 +13,12 @@ class song_manager
|
||||
public:
|
||||
song_manager(std::string&);
|
||||
|
||||
void saveSong(Song&);
|
||||
void deleteSong(Song&);
|
||||
void saveSong(Model::Song&);
|
||||
void deleteSong(Model::Song&);
|
||||
|
||||
static void printSong(const Song&);
|
||||
static void printSong(const Model::Song&);
|
||||
private:
|
||||
void saveSongTemp(Song&);
|
||||
void saveSongTemp(Model::Song&);
|
||||
|
||||
std::string exe_path;
|
||||
};
|
||||
|
||||
@@ -16,12 +16,12 @@ class token_manager
|
||||
public:
|
||||
token_manager();
|
||||
|
||||
loginResult retrieve_token();
|
||||
loginResult retrieve_token(std::string_view);
|
||||
Model::loginResult retrieve_token();
|
||||
Model::loginResult retrieve_token(std::string_view);
|
||||
|
||||
bool is_token_valid(std::string&, Scope);
|
||||
private:
|
||||
auth_credentials parse_auth_credentials(std::string_view);
|
||||
Model::auth_credentials parse_auth_credentials(std::string_view);
|
||||
|
||||
std::vector<std::string> extract_scopes(const jwt::decoded_jwt&&);
|
||||
std::pair<bool, std::vector<std::string>> fetch_auth_header(const std::string&);
|
||||
|
||||
+66
-65
@@ -4,77 +4,78 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct Song
|
||||
namespace Model
|
||||
{
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
int disc;
|
||||
std::string songPath;
|
||||
std::vector<unsigned char> data;
|
||||
int coverArtId;
|
||||
};
|
||||
struct Song
|
||||
{
|
||||
int id;
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::string album;
|
||||
std::string genre;
|
||||
int year;
|
||||
int duration;
|
||||
int track;
|
||||
int disc;
|
||||
std::string songPath;
|
||||
std::vector<unsigned char> data;
|
||||
int coverArtId;
|
||||
};
|
||||
|
||||
struct Cover
|
||||
{
|
||||
int id;
|
||||
std::string songTitle;
|
||||
std::string imagePath;
|
||||
// Not being used but it should be
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
struct Album
|
||||
{
|
||||
int id;
|
||||
std::string title;
|
||||
int year;
|
||||
std::vector<Song> songs;
|
||||
};
|
||||
|
||||
struct LoginRes
|
||||
{
|
||||
int UserId;
|
||||
char Username[1024];
|
||||
char Token[1024];
|
||||
char TokenType[1024];
|
||||
char Message[1024];
|
||||
int Expiration;
|
||||
};
|
||||
struct Cover
|
||||
{
|
||||
int id;
|
||||
std::string songTitle;
|
||||
std::string imagePath;
|
||||
// Not being used but it should be
|
||||
std::vector<unsigned char> data;
|
||||
};
|
||||
|
||||
struct loginResult
|
||||
{
|
||||
int user_id;
|
||||
std::string username;
|
||||
std::string access_token;
|
||||
std::string token_type;
|
||||
std::string message;
|
||||
int expiration;
|
||||
};
|
||||
struct LoginRes
|
||||
{
|
||||
int UserId;
|
||||
char Username[1024];
|
||||
char Token[1024];
|
||||
char TokenType[1024];
|
||||
char Message[1024];
|
||||
int Expiration;
|
||||
};
|
||||
|
||||
struct auth_credentials
|
||||
{
|
||||
std::string domain;
|
||||
std::string api_identifier;
|
||||
std::string client_id;
|
||||
std::string client_secret;
|
||||
std::string uri;
|
||||
std::string endpoint;
|
||||
};
|
||||
struct loginResult
|
||||
{
|
||||
int user_id;
|
||||
std::string username;
|
||||
std::string access_token;
|
||||
std::string token_type;
|
||||
std::string message;
|
||||
int expiration;
|
||||
};
|
||||
|
||||
struct database_connection
|
||||
{
|
||||
std::string server;
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string database;
|
||||
};
|
||||
struct auth_credentials
|
||||
{
|
||||
std::string domain;
|
||||
std::string api_identifier;
|
||||
std::string client_id;
|
||||
std::string client_secret;
|
||||
std::string uri;
|
||||
std::string endpoint;
|
||||
};
|
||||
|
||||
struct TokenReq
|
||||
{
|
||||
char ClientId[1024];
|
||||
char ClientSecret[1024];
|
||||
char Audience[1024];
|
||||
char GrantType[1024];
|
||||
char URI[1024];
|
||||
char Endpoint[1024];
|
||||
};
|
||||
struct database_connection
|
||||
{
|
||||
std::string server;
|
||||
std::string username;
|
||||
std::string password;
|
||||
std::string database;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,45 +1,21 @@
|
||||
#include <iostream>
|
||||
|
||||
//#include <taglib/attachedpictureframe.h>
|
||||
#include <attachedpictureframe.h>
|
||||
//#include <taglib/mpegfile.h>
|
||||
//#include <mpegfile.h>
|
||||
//#include <taglib/tag.h>
|
||||
#include <tag.h>
|
||||
//#include <taglib/tfile.h>
|
||||
#include <tfile.h>
|
||||
//#include <taglib/tfilestream.h>
|
||||
#include <tfilestream.h>
|
||||
//#include <taglib/fileref.h>
|
||||
#include <fileref.h>
|
||||
//#include <taglib/tbytevector.h>
|
||||
#include <tbytevector.h>
|
||||
//#include <taglib/tbytevectorstream.h>
|
||||
#include <tbytevectorstream.h>
|
||||
//#include <taglib/tpropertymap.h>
|
||||
#include <tpropertymap.h>
|
||||
//#include <taglib/id3v2tag.h>
|
||||
#include <id3v2tag.h>
|
||||
|
||||
class imageFile : public TagLib::File
|
||||
{
|
||||
public:
|
||||
imageFile(const char *file);
|
||||
/**
|
||||
imageFile(const char *file) : TagLib::File(file)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
TagLib::ByteVector data();
|
||||
/**
|
||||
TagLib::ByteVector data()
|
||||
{
|
||||
return readBlock(length());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
private:
|
||||
virtual TagLib::Tag *tag() const { return 0; }
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
class metadata_retriever
|
||||
{
|
||||
public:
|
||||
Song retrieve_metadata(std::string&);
|
||||
Cover update_cover_art(const Song&, Cover& cov, const std::string&);
|
||||
Model::Song retrieve_metadata(std::string&);
|
||||
Model::Cover update_cover_art(const Model::Song&, Model::Cover& cov, const std::string&);
|
||||
|
||||
void update_metadata(Song updated_song, const Song old_song);
|
||||
void update_metadata(Model::Song updated_song, const Model::Song old_song);
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
std::vector<unsigned char> data(buff.get(), buff.get() + buffSize);
|
||||
|
||||
Song sng;
|
||||
Model::Song sng;
|
||||
sng.data = std::move(data);
|
||||
|
||||
song_manager s_mgr(m_exe_path);
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
PATH(Int32, id)) {
|
||||
|
||||
songRepository songRepo(m_exe_path);
|
||||
Song songDb;
|
||||
Model::Song songDb;
|
||||
songDb.id = id;
|
||||
|
||||
songDb = songRepo.retrieveRecord(songDb, songFilter::id);
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
PATH(Int32, id)) {
|
||||
|
||||
songRepository songRepo(m_exe_path);
|
||||
Song songDb;
|
||||
Model::Song songDb;
|
||||
songDb.id = id;
|
||||
songDb = songRepo.retrieveRecord(songDb, songFilter::id);
|
||||
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
|
||||
ENDPOINT("DELETE", "api/v1/song/data/{id}", songDelete, PATH(Int32, id)) {
|
||||
|
||||
Song song;
|
||||
Model::Song song;
|
||||
song.id = id;
|
||||
|
||||
song_manager sngMgr(m_exe_path);
|
||||
|
||||
@@ -25,7 +25,7 @@ MYSQL* base_repository::setup_mysql_connection()
|
||||
|
||||
return conn;
|
||||
}
|
||||
MYSQL* base_repository::setup_mysql_connection(database_connection details)
|
||||
MYSQL* base_repository::setup_mysql_connection(Model::database_connection details)
|
||||
{
|
||||
MYSQL *connection = mysql_init(NULL);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
coverArtRepository::coverArtRepository(const std::string& path) : base_repository(path)
|
||||
{ }
|
||||
|
||||
Cover coverArtRepository::retrieveRecord(Cover& cov, coverFilter filter = coverFilter::id)
|
||||
Model::Cover coverArtRepository::retrieveRecord(Model::Cover& cov, coverFilter filter = coverFilter::id)
|
||||
{
|
||||
std::stringstream qry;
|
||||
auto conn = setup_mysql_connection();
|
||||
@@ -45,7 +45,7 @@ Cover coverArtRepository::retrieveRecord(Cover& cov, coverFilter filter = coverF
|
||||
return covDb;
|
||||
}
|
||||
|
||||
void coverArtRepository::deleteRecord(const Cover& cov)
|
||||
void coverArtRepository::deleteRecord(const Model::Cover& cov)
|
||||
{
|
||||
auto conn = setup_mysql_connection();
|
||||
const std::string query("DELETE FROM CoverArt WHERE CoverArtId = " + std::to_string(cov.id));
|
||||
@@ -55,7 +55,7 @@ void coverArtRepository::deleteRecord(const Cover& cov)
|
||||
mysql_close(conn);
|
||||
}
|
||||
|
||||
void coverArtRepository::saveRecord(const Cover& cov)
|
||||
void coverArtRepository::saveRecord(const Model::Cover& cov)
|
||||
{
|
||||
auto conn = setup_mysql_connection();
|
||||
|
||||
@@ -93,10 +93,10 @@ void coverArtRepository::saveRecord(const Cover& cov)
|
||||
std::cout << "done" << std::endl;
|
||||
}
|
||||
|
||||
Cover coverArtRepository::parseRecord(MYSQL_RES *results)
|
||||
Model::Cover coverArtRepository::parseRecord(MYSQL_RES *results)
|
||||
{
|
||||
std::cout << "parsing record" << std::endl;
|
||||
Cover cov;
|
||||
Model::Cover cov;
|
||||
auto fieldNum = mysql_num_fields(results);
|
||||
|
||||
MYSQL_ROW row = mysql_fetch_row(results);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
songRepository::songRepository(const std::string& path) : base_repository(path)
|
||||
{ }
|
||||
|
||||
std::vector<Song> songRepository::retrieveRecords()
|
||||
std::vector<Model::Song> songRepository::retrieveRecords()
|
||||
{
|
||||
auto conn = setup_mysql_connection();
|
||||
const std::string query = "SELECT * FROM Song";
|
||||
@@ -24,7 +24,7 @@ std::vector<Song> songRepository::retrieveRecords()
|
||||
return songs;
|
||||
}
|
||||
|
||||
Song songRepository::retrieveRecord(Song& song, songFilter filter)
|
||||
Model::Song songRepository::retrieveRecord(Model::Song& song, songFilter filter)
|
||||
{
|
||||
std::stringstream qry;
|
||||
auto conn = setup_mysql_connection();
|
||||
@@ -57,7 +57,7 @@ Song songRepository::retrieveRecord(Song& song, songFilter filter)
|
||||
return song;
|
||||
}
|
||||
|
||||
void songRepository::deleteRecord(const Song& song)
|
||||
void songRepository::deleteRecord(const Model::Song& song)
|
||||
{
|
||||
auto conn = setup_mysql_connection();
|
||||
auto status = 0;
|
||||
@@ -69,7 +69,7 @@ void songRepository::deleteRecord(const Song& song)
|
||||
mysql_close(conn);
|
||||
}
|
||||
|
||||
void songRepository::saveRecord(const Song& song)
|
||||
void songRepository::saveRecord(const Model::Song& song)
|
||||
{
|
||||
auto conn = setup_mysql_connection();
|
||||
auto status = 0;
|
||||
@@ -148,16 +148,16 @@ void songRepository::saveRecord(const Song& song)
|
||||
std::cout << "done inserting song record" << std::endl;
|
||||
}
|
||||
|
||||
std::vector<Song> songRepository::parseRecords(MYSQL_RES* results)
|
||||
std::vector<Model::Song> songRepository::parseRecords(MYSQL_RES* results)
|
||||
{
|
||||
auto fieldNum = mysql_num_fields(results);
|
||||
auto numRows = mysql_num_rows(results);
|
||||
|
||||
std::vector<Song> songs;
|
||||
std::vector<Model::Song> songs;
|
||||
songs.reserve(numRows);
|
||||
|
||||
for (MYSQL_ROW row = nullptr; (row = mysql_fetch_row(results)) != nullptr; ) {
|
||||
Song song;
|
||||
Model::Song song;
|
||||
|
||||
for (auto i = 0; i != fieldNum; ++i) {
|
||||
switch (i) {
|
||||
@@ -203,9 +203,9 @@ std::vector<Song> songRepository::parseRecords(MYSQL_RES* results)
|
||||
return songs;
|
||||
}
|
||||
|
||||
Song songRepository::parseRecord(MYSQL_RES* results)
|
||||
Model::Song songRepository::parseRecord(MYSQL_RES* results)
|
||||
{
|
||||
Song song;
|
||||
Model::Song song;
|
||||
auto fieldNum = mysql_num_fields(results);
|
||||
|
||||
MYSQL_ROW row = mysql_fetch_row(results);
|
||||
|
||||
@@ -8,10 +8,10 @@ coverArtManager::coverArtManager(const std::string& configPath) : path(configPat
|
||||
{ }
|
||||
|
||||
|
||||
Cover coverArtManager::saveCover(const Song& song, std::string& rootPath, const std::string& stockCoverPath)
|
||||
Model::Cover coverArtManager::saveCover(const Model::Song& song, std::string& rootPath, const std::string& stockCoverPath)
|
||||
{
|
||||
metadata_retriever meta;
|
||||
Cover cov;
|
||||
Model::Cover cov;
|
||||
cov.imagePath = rootPath;
|
||||
cov = meta.update_cover_art(song, cov, stockCoverPath);
|
||||
cov.songTitle = song.title;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
std::string directory_manager::create_directory_process(Song song, const std::string& root_path)
|
||||
std::string directory_manager::create_directory_process(Model::Song song, const std::string& root_path)
|
||||
{
|
||||
auto curr_path = fs::path(root_path);
|
||||
|
||||
@@ -74,52 +74,6 @@ nlohmann::json directory_manager::pathConfigContent(const std::string& exe_path)
|
||||
return nlohmann::json::parse(contentOfPath(path));
|
||||
}
|
||||
|
||||
/**
|
||||
std::string directory_manager::read_cover_art(const std::string& source)
|
||||
{
|
||||
auto source_path = fs::path(source);
|
||||
|
||||
std::fstream cov(source, std::ios::in | std::ios::binary);
|
||||
|
||||
cov.seekg(0);
|
||||
|
||||
std::stringstream buf;
|
||||
std::copy(std::istreambuf_iterator<char>(cov),
|
||||
std::istreambuf_iterator<char>(),
|
||||
std::ostreambuf_iterator<char>(buf));
|
||||
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
void directory_manager::copy_stock_to_root(const std::string& target, const std::string& buff)
|
||||
{
|
||||
std::cout<<"starting process"<<std::endl;
|
||||
auto target_path = fs::path(target);
|
||||
if (fs::exists(target_path)) {
|
||||
std::cout<<target_path.string()<<" exists"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout<<target_path.string()<<" does not exist, copying over"<<std::endl;
|
||||
std::fstream cov(target, std::ios::out | std::ios::binary);
|
||||
cov.write(buff.c_str(), buff.size());
|
||||
cov.close();
|
||||
|
||||
std::cout<<"copy finished"<<std::endl;
|
||||
}
|
||||
void directory_manager::copy_song_to_path(const std::string& target, const std::string& source)
|
||||
{
|
||||
std::cout<<"starting process to copy song"<<std::endl;
|
||||
auto target_path = fs::path(target);
|
||||
auto src_path = fs::path(source);
|
||||
|
||||
std::cout<<"copting over to "<<target_path.string()<<std::endl;
|
||||
fs::copy(src_path, target_path);
|
||||
|
||||
fs::remove(source);
|
||||
std::cout<<"copy finished"<<std::endl;
|
||||
}
|
||||
*/
|
||||
void directory_manager::delete_cover_art_file(const std::string& cov_path, const std::string& stock_cover_path)
|
||||
{
|
||||
if (cov_path.compare(stock_cover_path) == 0) {
|
||||
@@ -130,7 +84,7 @@ void directory_manager::delete_cover_art_file(const std::string& cov_path, const
|
||||
fs::remove(cov);
|
||||
}
|
||||
}
|
||||
void directory_manager::delete_directories(Song song, const std::string& root_path)
|
||||
void directory_manager::delete_directories(Model::Song song, const std::string& root_path)
|
||||
{
|
||||
std::cout<<"checking to for empty directories to delete"<<std::endl;
|
||||
const std::string art{root_path + std::string{"/"} + song.artist};
|
||||
@@ -155,7 +109,7 @@ void directory_manager::delete_directories(Song song, const std::string& root_pa
|
||||
|
||||
std::cout<<"deleted empty directory or directories"<<std::endl;
|
||||
}
|
||||
void directory_manager::delete_song(const Song song)
|
||||
void directory_manager::delete_song(const Model::Song song)
|
||||
{
|
||||
std::cout<<"deleting song"<<std::endl;
|
||||
auto song_path = fs::path(song.songPath);
|
||||
|
||||
@@ -19,7 +19,7 @@ song_manager::song_manager(std::string& x_path)
|
||||
{ }
|
||||
|
||||
|
||||
void song_manager::saveSong(Song& song)
|
||||
void song_manager::saveSong(Model::Song& song)
|
||||
{
|
||||
saveSongTemp(song);
|
||||
metadata_retriever meta;
|
||||
@@ -53,7 +53,7 @@ void song_manager::saveSong(Song& song)
|
||||
songRepo.saveRecord(song);
|
||||
}
|
||||
|
||||
void song_manager::deleteSong(Song& song)
|
||||
void song_manager::deleteSong(Model::Song& song)
|
||||
{
|
||||
coverArtRepository covRepo(exe_path);
|
||||
songRepository songRepo(exe_path);
|
||||
@@ -61,7 +61,7 @@ void song_manager::deleteSong(Song& song)
|
||||
song = songRepo.retrieveRecord(song, songFilter::id);
|
||||
songRepo.deleteRecord(song);
|
||||
|
||||
Cover cov;
|
||||
Model::Cover cov;
|
||||
cov.id = song.coverArtId;
|
||||
cov = covRepo.retrieveRecord(cov, coverFilter::id);
|
||||
covRepo.deleteRecord(cov);
|
||||
@@ -81,7 +81,7 @@ void song_manager::deleteSong(Song& song)
|
||||
directory_manager::delete_directories(song, coverArtPath);
|
||||
}
|
||||
|
||||
void song_manager::printSong(const Song& song)
|
||||
void song_manager::printSong(const Model::Song& song)
|
||||
{
|
||||
std::cout << "\n\nsong" << std::endl;
|
||||
std::cout << "title: " << song.title << std::endl;
|
||||
@@ -98,7 +98,7 @@ void song_manager::printSong(const Song& song)
|
||||
}
|
||||
}
|
||||
|
||||
void song_manager::saveSongTemp(Song& song)
|
||||
void song_manager::saveSongTemp(Model::Song& song)
|
||||
{
|
||||
auto config = directory_manager::pathConfigContent(exe_path);
|
||||
|
||||
|
||||
@@ -21,15 +21,15 @@ token_manager::token_manager()
|
||||
{
|
||||
}
|
||||
|
||||
loginResult token_manager::retrieve_token()
|
||||
Model::loginResult token_manager::retrieve_token()
|
||||
{
|
||||
loginResult lr;
|
||||
Model::loginResult lr;
|
||||
lr.access_token = "dsfdsf";
|
||||
lr.token_type = "demo";
|
||||
|
||||
return lr;
|
||||
}
|
||||
loginResult token_manager::retrieve_token(std::string_view path)
|
||||
Model::loginResult token_manager::retrieve_token(std::string_view path)
|
||||
{
|
||||
auto cred = parse_auth_credentials(path);
|
||||
|
||||
@@ -50,7 +50,7 @@ loginResult token_manager::retrieve_token(std::string_view path)
|
||||
|
||||
auto post_res = nlohmann::json::parse(r.text);
|
||||
|
||||
loginResult lr;
|
||||
Model::loginResult lr;
|
||||
lr.access_token = post_res["access_token"].get<std::string>();
|
||||
lr.token_type = post_res["token_type"].get<std::string>();
|
||||
lr.expiration = post_res["expires_in"].get<int>();
|
||||
@@ -87,14 +87,14 @@ bool token_manager::is_token_valid(std::string& auth, Scope scope)
|
||||
return false;
|
||||
}
|
||||
|
||||
auth_credentials token_manager::parse_auth_credentials(std::string_view path)
|
||||
Model::auth_credentials token_manager::parse_auth_credentials(std::string_view path)
|
||||
{
|
||||
auto exe_path = directory_manager::configPath(path);
|
||||
exe_path.append("/authcredentials.json");
|
||||
|
||||
auto con = directory_manager::credentialConfigContent(exe_path);
|
||||
|
||||
auth_credentials auth;
|
||||
Model::auth_credentials auth;
|
||||
auth.uri = "https://";
|
||||
auth.uri.append(con["domain"]);
|
||||
auth.api_identifier = con["api_identifier"];
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
Song metadata_retriever::retrieve_metadata(std::string& song_path)
|
||||
Model::Song metadata_retriever::retrieve_metadata(std::string& song_path)
|
||||
{
|
||||
TagLib::FileRef file(song_path.c_str());
|
||||
Song song;
|
||||
Model::Song song;
|
||||
song.title = file.tag()->title().toCString();
|
||||
song.artist = file.tag()->artist().toCString();
|
||||
song.album = file.tag()->album().toCString();
|
||||
@@ -48,7 +48,7 @@ Song metadata_retriever::retrieve_metadata(std::string& song_path)
|
||||
return song;
|
||||
}
|
||||
|
||||
Cover metadata_retriever::update_cover_art(const Song& song, Cover& cov, const std::string& stockCoverPath)
|
||||
Model::Cover metadata_retriever::update_cover_art(const Model::Song& song, Model::Cover& cov, const std::string& stockCoverPath)
|
||||
{
|
||||
TagLib::MPEG::File sngF(song.songPath.c_str());
|
||||
auto tag = sngF.ID3v2Tag();
|
||||
@@ -94,7 +94,7 @@ Cover metadata_retriever::update_cover_art(const Song& song, Cover& cov, const s
|
||||
return cov;
|
||||
}
|
||||
|
||||
void metadata_retriever::update_metadata(Song sng_updated, const Song sng_old)
|
||||
void metadata_retriever::update_metadata(Model::Song sng_updated, const Model::Song sng_old)
|
||||
{
|
||||
std::cout<<"updating metadata"<<std::endl;
|
||||
TagLib::FileRef file(sng_old.songPath.c_str());
|
||||
|
||||
Reference in New Issue
Block a user