Compare commits

...

8 Commits

Author SHA1 Message Date
kdeng00 a1edbeb164 Fixed issue of the configuration verification test failing 2020-02-15 17:37:51 -05:00
kdeng00 437a6b1453 Fixed issue with special characters not being recorded properly 2020-02-15 17:32:52 -05:00
Kun Deng f2d0947b36 Merge pull request #63 from kdeng00/dist_change
API is functional again after the dependency updates
2020-02-02 20:33:48 -05:00
kdeng00 b067882c09 API is functional again after the dependency updates 2020-02-02 20:32:09 -05:00
kdeng00 57f76ee4a4 api is functional after the dependency updates 2020-02-01 20:58:48 -05:00
kdeng00 e846989a7f Not finished updating dependencies. oatpp has changed 2020-01-30 19:30:21 -05:00
kdeng00 91ae3a908e Updated json dependency 2020-01-29 19:12:23 -05:00
kdeng00 a970ba207e updating dependencies and code refactoring for the new changes 2020-01-28 21:03:56 -05:00
17 changed files with 227 additions and 51 deletions
+1 -1
+1 -1
+1 -1
View File
@@ -1,5 +1,5 @@
[requires] [requires]
jsonformoderncpp/3.7.0@vthiery/stable jsonformoderncpp/3.7.3@vthiery/stable
[generators] [generators]
cmake cmake
+4 -2
View File
@@ -4,7 +4,9 @@
#include <string> #include <string>
#include "oatpp/core/data/stream/FileStream.hpp" #include "oatpp/core/data/stream/FileStream.hpp"
#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp" #include "oatpp/core/data/stream/Stream.hpp"
#include "oatpp/core/async/Coroutine.hpp"
//#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp"
namespace callback { namespace callback {
class StreamCallback : public oatpp::data::stream::ReadCallback { class StreamCallback : public oatpp::data::stream::ReadCallback {
@@ -12,7 +14,7 @@ namespace callback {
StreamCallback(); StreamCallback();
StreamCallback(const std::string&); StreamCallback(const std::string&);
oatpp::data::v_io_size read(void*, oatpp::data::v_io_size); oatpp::v_io_size read(void*, v_buff_size, oatpp::async::Action&);
private: private:
std::string m_songPath; std::string m_songPath;
+13 -8
View File
@@ -9,13 +9,15 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <oatpp/core/async/Coroutine.hpp>
#include "oatpp/core/data/stream/ChunkedBuffer.hpp" #include "oatpp/core/data/stream/ChunkedBuffer.hpp"
#include "oatpp/core/data/stream/FileStream.hpp" #include "oatpp/core/data/stream/FileStream.hpp"
#include "oatpp/core/base/StrBuffer.hpp"
#include "oatpp/core/macro/codegen.hpp" #include "oatpp/core/macro/codegen.hpp"
#include "oatpp/core/macro/component.hpp" #include "oatpp/core/macro/component.hpp"
#include "oatpp/web/mime/multipart/InMemoryPartReader.hpp" #include "oatpp/web/mime/multipart/InMemoryPartReader.hpp"
#include "oatpp/web/mime/multipart/Reader.hpp" #include "oatpp/web/mime/multipart/Reader.hpp"
#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp" #include "oatpp/web/protocol/http/outgoing/StreamingBody.hpp"
#include "oatpp/web/server/api/ApiController.hpp" #include "oatpp/web/server/api/ApiController.hpp"
#include "callback/StreamCallback.h" #include "callback/StreamCallback.h"
@@ -41,10 +43,12 @@ namespace controller {
// endpoint for uploading a song // endpoint for uploading a song
ENDPOINT("POST", "/api/v1/song/data", songUpload, ENDPOINT("POST", "/api/v1/song/data", songUpload,
//AUTHORIZATION(std::shared_ptr<oatpp::web::server::handler::DefaultBearerAuthorizationObject>, authObject),
REQUEST(std::shared_ptr<IncomingRequest>, request)) { REQUEST(std::shared_ptr<IncomingRequest>, request)) {
auto authHeader = request->getHeader("Authorization"); auto authHeader = request->getHeader("Authorization");
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope"); OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
auto auth = authHeader->std_str(); auto auth = authHeader->std_str();
manager::TokenManager tok; manager::TokenManager tok;
OATPP_ASSERT_HTTP(tok.isTokenValid(auth, OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
type::Scope::upload), Status::CODE_403, "Not allowed"); type::Scope::upload), Status::CODE_403, "Not allowed");
@@ -64,10 +68,10 @@ namespace controller {
OATPP_ASSERT_HTTP(file, Status::CODE_400, "file is null"); OATPP_ASSERT_HTTP(file, Status::CODE_400, "file is null");
auto buff = std::unique_ptr<char>(new char[file->getKnownSize()]); auto buff = std::make_unique<const char*>(file->getInMemoryData()->c_str());
auto buffSize = file->getInputStream()->read(buff.get(), file->getKnownSize()); auto buffSize = file->getKnownSize();
std::vector<unsigned char> data(buff.get(), buff.get() + buffSize); std::vector<unsigned char> data(*buff, *buff + buffSize);
model::Song sng; model::Song sng;
sng.data = std::move(data); sng.data = std::move(data);
@@ -221,11 +225,12 @@ namespace controller {
songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id); songDb = songRepo.retrieveRecord(songDb, type::SongFilter::id);
oatpp::data::v_io_size dSize = 1024; auto dSize = 1024;
auto db = std::make_shared<oatpp::web::protocol::http::outgoing::ChunkedBody>( auto callback = std::make_shared<callback::StreamCallback>(songDb.songPath);
std::make_shared<callback::StreamCallback>(songDb.songPath), auto db = std::make_shared<oatpp::web::protocol::http::outgoing::StreamingBody>(
nullptr, dSize); callback
);
auto response = OutgoingResponse::createShared(Status::CODE_200, db); auto response = OutgoingResponse::createShared(Status::CODE_200, db);
response->putHeader(Header::CONNECTION, Header::Value::CONNECTION_KEEP_ALIVE); response->putHeader(Header::CONNECTION, Header::Value::CONNECTION_KEEP_ALIVE);
+8 -1
View File
@@ -3,6 +3,7 @@
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <filesystem>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
@@ -12,7 +13,9 @@
namespace manager { namespace manager {
class DirectoryManager { class DirectoryManager {
public: public:
static std::string createDirectoryProcess(model::Song, const std::string&); DirectoryManager() = default;
static std::string createDirectoryProcess(const model::Song&, const std::string&);
static std::string createDirectoryProcess(const model::Song&, static std::string createDirectoryProcess(const model::Song&,
const model::BinaryPath&, type::PathType); const model::BinaryPath&, type::PathType);
static std::string configPath(std::string_view); static std::string configPath(std::string_view);
@@ -29,6 +32,10 @@ namespace manager {
void deleteCoverArtFile(const std::string&, const std::string&); void deleteCoverArtFile(const std::string&, const std::string&);
private: private:
std::filesystem::path relativeDiscSongPathFilesystem(const std::filesystem::path&,
const model::Song&);
std::string relativeDiscSongPath(const std::filesystem::path&, const model::Song&);
void deleteSong(const model::Song); void deleteSong(const model::Song);
}; };
} }
+3 -1
View File
@@ -10,7 +10,9 @@ namespace type {
albumArtist, albumArtist,
genre, genre,
year, year,
titleAndArtist titleAndArtist,
titleAlbArtistAlbum,
titleAlbArtistAlbumTrack
}; };
} }
+7 -1
View File
@@ -4,13 +4,19 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <attachedpictureframe.h>
#include <textidentificationframe.h>
#include <fileref.h>
#include <mpegfile.h>
#include <tag.h>
#include "model/Models.h" #include "model/Models.h"
namespace utility { namespace utility {
class MetadataRetriever { class MetadataRetriever {
public: public:
model::Song retrieveMetadata(model::Song&); model::Song retrieveMetadata(model::Song&);
model::Cover updateCoverArt(const model::Song&, model::Cover&, const std::string&); model::Cover updateCoverArt(const model::Song&, model::Cover&, const std::string&);
model::Cover applyStockCoverArt(const model::Song&, model::Cover&, const std::string&); model::Cover applyStockCoverArt(const model::Song&, model::Cover&, const std::string&);
model::Cover applyCoverArt(const model::Song&, model::Cover&); model::Cover applyCoverArt(const model::Song&, model::Cover&);
+3 -1
View File
@@ -18,7 +18,9 @@ namespace callback {
} }
oatpp::data::v_io_size StreamCallback::read(void *buff, oatpp::data::v_io_size count) {
oatpp::v_io_size StreamCallback::read(void *buff, v_buff_size count,
oatpp::async::Action& action) {
if (m_counter >= m_fileSize) { if (m_counter >= m_fileSize) {
std::cout << "done streaming song\n"; std::cout << "done streaming song\n";
return 0; return 0;
+103 -6
View File
@@ -41,6 +41,12 @@ namespace database {
case type::SongFilter::titleAndArtist: case type::SongFilter::titleAndArtist:
valueFilterCount = 2; valueFilterCount = 2;
break; break;
case type::SongFilter::titleAlbArtistAlbum:
valueFilterCount = 3;
break;
case type::SongFilter::titleAlbArtistAlbumTrack:
valueFilterCount = 4;
break;
default: default:
break; break;
} }
@@ -53,6 +59,8 @@ namespace database {
auto titleLength = song.title.size(); auto titleLength = song.title.size();
auto artistLength = song.artist.size(); auto artistLength = song.artist.size();
auto albumArtistLength = song.albumArtist.size();
auto albumLength = song.album.size();
switch (filter) { switch (filter) {
case type::SongFilter::id: case type::SongFilter::id:
qry << "sng.SongId = ?"; qry << "sng.SongId = ?";
@@ -86,6 +94,47 @@ namespace database {
std::cout << "title: " << song.title.c_str() << " artist: " << std::cout << "title: " << song.title.c_str() << " artist: " <<
song.artist.c_str() << "\n"; song.artist.c_str() << "\n";
break; break;
case type::SongFilter::titleAlbArtistAlbum:
qry << "sng.Title = ? AND sng.Album = ? AND alb.Artist = ?";
params[0].buffer_type = MYSQL_TYPE_STRING;
params[0].buffer = (char*)song.title.c_str();
params[0].length = &titleLength;
params[0].is_null = 0;
params[1].buffer_type = MYSQL_TYPE_STRING;
params[1].buffer = (char*)song.album.c_str();
params[1].length = &albumLength;
params[1].is_null = 0;
params[2].buffer_type = MYSQL_TYPE_STRING;
params[2].buffer = (char*)song.albumArtist.c_str();
params[2].length = &albumArtistLength;
params[2].is_null = 0;
break;
case type::SongFilter::titleAlbArtistAlbumTrack:
qry << "sng.Title = ? AND sng.Album = ? AND alb.Artist = ? AND sng.Track = ?";
params[0].buffer_type = MYSQL_TYPE_STRING;
params[0].buffer = (char*)song.title.c_str();
params[0].length = &titleLength;
params[0].is_null = 0;
params[1].buffer_type = MYSQL_TYPE_STRING;
params[1].buffer = (char*)song.album.c_str();
params[1].length = &titleLength;
params[1].is_null = 0;
params[2].buffer_type = MYSQL_TYPE_STRING;
params[2].buffer = (char*)song.albumArtist.c_str();
params[2].length = &titleLength;
params[2].is_null = 0;
params[3].buffer_type = MYSQL_TYPE_LONG;
params[3].buffer = (char*)&song.track;
params[3].length = 0;
params[3].is_null = 0;;
break;
default: default:
break; break;
} }
@@ -103,7 +152,6 @@ namespace database {
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
mysql_close(conn); mysql_close(conn);
std::cout << "done\n";
return retrievedSong; return retrievedSong;
} }
@@ -119,6 +167,12 @@ namespace database {
case type::SongFilter::titleAndArtist: case type::SongFilter::titleAndArtist:
valueFilterCount = 2; valueFilterCount = 2;
break; break;
case type::SongFilter::titleAlbArtistAlbum:
valueFilterCount = 3;
break;
case type::SongFilter::titleAlbArtistAlbumTrack:
valueFilterCount = 4;
break;
default: default:
break; break;
} }
@@ -127,13 +181,16 @@ namespace database {
MYSQL_BIND params[valueFilterCount]; MYSQL_BIND params[valueFilterCount];
memset(params, 0, sizeof(params)); memset(params, 0, sizeof(params));
qry << "SELECT * FROM Song WHERE "; qry << "SELECT sng.* FROM Song sng ";
qry << "LEFT JOIN Album alb ON sng.AlbumId = alb.AlbumId WHERE ";
auto titleLength = song.title.size(); auto titleLength = song.title.size();
auto artistLength = song.artist.size(); auto artistLength = song.artist.size();
auto albumArtistLength = song.albumArtist.size();
auto albumLength = song.album.size();
switch (filter) { switch (filter) {
case type::SongFilter::id: case type::SongFilter::id:
qry << "SongId = ?"; qry << "sng.SongId = ?";
params[0].buffer_type = MYSQL_TYPE_LONG; params[0].buffer_type = MYSQL_TYPE_LONG;
params[0].buffer = (char*)&song.id; params[0].buffer = (char*)&song.id;
@@ -141,7 +198,7 @@ namespace database {
params[0].is_null = 0; params[0].is_null = 0;
break; break;
case type::SongFilter::title: case type::SongFilter::title:
qry << "Title = ?"; qry << "sng.Title = ?";
params[0].buffer_type = MYSQL_TYPE_STRING; params[0].buffer_type = MYSQL_TYPE_STRING;
params[0].buffer = (char*)song.title.c_str(); params[0].buffer = (char*)song.title.c_str();
@@ -149,7 +206,7 @@ namespace database {
params[0].is_null = 0; params[0].is_null = 0;
break; break;
case type::SongFilter::titleAndArtist: case type::SongFilter::titleAndArtist:
qry << "Title = ? AND Artist = ?"; qry << "sng.Title = ? AND sng.Artist = ?";
params[0].buffer_type = MYSQL_TYPE_STRING; params[0].buffer_type = MYSQL_TYPE_STRING;
params[0].buffer = (char*)song.title.c_str(); params[0].buffer = (char*)song.title.c_str();
@@ -161,6 +218,47 @@ namespace database {
params[1].length = &artistLength; params[1].length = &artistLength;
params[1].is_null = 0; params[1].is_null = 0;
break; break;
case type::SongFilter::titleAlbArtistAlbum:
qry << "sng.Title = ? AND sng.Album = ? AND alb.Artist = ?";
params[0].buffer_type = MYSQL_TYPE_STRING;
params[0].buffer = (char*)song.title.c_str();
params[0].length = &titleLength;
params[0].is_null = 0;
params[1].buffer_type = MYSQL_TYPE_STRING;
params[1].buffer = (char*)song.album.c_str();
params[1].length = &albumLength;
params[1].is_null = 0;
params[1].buffer_type = MYSQL_TYPE_STRING;
params[1].buffer = (char*)song.albumArtist.c_str();
params[1].length = &albumArtistLength;
params[1].is_null = 0;
break;
case type::SongFilter::titleAlbArtistAlbumTrack:
qry << "sng.Title = ? AND sng.Album = ? AND alb.Artist = ? AND sng.Track = ?";
params[0].buffer_type = MYSQL_TYPE_STRING;
params[0].buffer = (char*)song.title.c_str();
params[0].length = &titleLength;
params[0].is_null = 0;
params[1].buffer_type = MYSQL_TYPE_STRING;
params[1].buffer = (char*)song.album.c_str();
params[1].length = &titleLength;
params[1].is_null = 0;
params[2].buffer_type = MYSQL_TYPE_STRING;
params[2].buffer = (char*)song.albumArtist.c_str();
params[2].length = &titleLength;
params[2].is_null = 0;
params[3].buffer_type = MYSQL_TYPE_LONG;
params[3].buffer = (char*)&song.track;
params[3].length = 0;
params[3].is_null = 0;;
break;
default: default:
break; break;
} }
@@ -179,7 +277,6 @@ namespace database {
mysql_stmt_close(stmt); mysql_stmt_close(stmt);
mysql_close(conn); mysql_close(conn);
std::cout << "done\n";
return (rowCount > 0) ? true : false; return (rowCount > 0) ? true : false;
} }
+63 -4
View File
@@ -8,7 +8,7 @@
namespace fs = std::filesystem; namespace fs = std::filesystem;
namespace manager { namespace manager {
std::string DirectoryManager::createDirectoryProcess(model::Song song, std::string DirectoryManager::createDirectoryProcess(const model::Song& song,
const std::string& rootPath) { const std::string& rootPath) {
auto currPath = fs::path(rootPath); auto currPath = fs::path(rootPath);
@@ -27,7 +27,7 @@ namespace manager {
fs::create_directory(artPath); fs::create_directory(artPath);
} }
auto albPath = fs::path(artPath.string() + "/" + song.album); auto albPath = fs::path(artPath.string() + "/" + song.albumArtist);
if (fs::exists(albPath)) { if (fs::exists(albPath)) {
std::cout << "album path exists\n"; std::cout << "album path exists\n";
} else { } else {
@@ -35,7 +35,16 @@ namespace manager {
fs::create_directory(albPath); fs::create_directory(albPath);
} }
return albPath.string() + "/"; auto discPath = DirectoryManager().relativeDiscSongPathFilesystem(albPath, song);
if (fs::exists(discPath)) {
std::cout << "disc path exists\n";
} else {
std::cout << "creating disc path\n";
fs::create_directory(discPath);
}
return discPath.string() + "/";
} }
std::string DirectoryManager::createDirectoryProcess(const model::Song& song, std::string DirectoryManager::createDirectoryProcess(const model::Song& song,
@@ -67,7 +76,15 @@ namespace manager {
fs::create_directory(albPath); fs::create_directory(albPath);
} }
return albPath.string() + "/"; auto discPath = DirectoryManager().relativeDiscSongPathFilesystem(albPath, song);
if (fs::exists(discPath)) {
std::cout << "disc path exists\n";
} else {
std::cout << "creating disc path\n";
fs::create_directory(discPath);
}
return discPath.string() + "/";
} }
std::string DirectoryManager::configPath(std::string_view path) { std::string DirectoryManager::configPath(std::string_view path) {
@@ -136,6 +153,15 @@ namespace manager {
std::cout << "checking for empty directories to delete\n"; std::cout << "checking for empty directories to delete\n";
const std::string art(rootPath + std::string("/") + song.albumArtist); const std::string art(rootPath + std::string("/") + song.albumArtist);
const std::string alb(art + "/" + song.album); const std::string alb(art + "/" + song.album);
const std::string disc(alb + "/" + std::to_string(song.disc) + "/");
auto discPath = fs::path(disc);
if (fs::exists(discPath)) {
std::cout << "disc directory does not exist\n";
} else if (fs::is_empty(discPath)) {
fs::remove(discPath);
}
auto albPath = fs::path(alb); auto albPath = fs::path(alb);
@@ -168,6 +194,39 @@ namespace manager {
} }
} }
fs::path DirectoryManager::relativeDiscSongPathFilesystem(const fs::path& albPath,
const model::Song& song) {
std::string albPathStr(albPath.string() + "/disc");
if (song.disc >= 10) {
albPathStr.append(std::to_string(song.disc));
} else {
albPathStr.append("0");
albPathStr.append(std::to_string(song.disc));
}
albPathStr.append("/");
auto relPath = fs::path(albPathStr.c_str());
return relPath;
}
std::string DirectoryManager::relativeDiscSongPath(const fs::path& albPath,
const model::Song& song) {
std::string albPathStr(albPath.string() + "/disc");
if (song.disc >= 10) {
albPathStr.append(std::to_string(song.disc));
} else {
albPathStr.append("0");
albPathStr.append(std::to_string(song.disc));
}
albPathStr.append("/");
return albPathStr;
}
void DirectoryManager::deleteSong(const model::Song song) { void DirectoryManager::deleteSong(const model::Song song) {
std::cout << "deleting song\n"; std::cout << "deleting song\n";
auto songPath = fs::path(song.songPath); auto songPath = fs::path(song.songPath);
+5 -5
View File
@@ -5,7 +5,7 @@
#include <random> #include <random>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp" //#include "oatpp/web/protocol/http/outgoing/ChunkedBody.hpp"
#include "oatpp/web/server/api/ApiController.hpp" #include "oatpp/web/server/api/ApiController.hpp"
#include "database/CoverArtRepository.h" #include "database/CoverArtRepository.h"
@@ -33,7 +33,7 @@ namespace manager {
song.data = std::move(data); song.data = std::move(data);
database::SongRepository songRepo(m_bConf); database::SongRepository songRepo(m_bConf);
if (songRepo.doesSongExist(song, type::SongFilter::titleAndArtist)) { if (songRepo.doesSongExist(song, type::SongFilter::titleAlbArtistAlbum)) {
std::cout << "\ntitle: " << song.title << "\nartist: " << song.artist << "\n"; std::cout << "\ntitle: " << song.title << "\nartist: " << song.artist << "\n";
std::cout << "does not exist\n"; std::cout << "does not exist\n";
return std::make_pair(false, type::SongUpload::AlreadyExist); return std::make_pair(false, type::SongUpload::AlreadyExist);
@@ -44,7 +44,7 @@ namespace manager {
printSong(song); printSong(song);
songRepo.saveRecord(song); songRepo.saveRecord(song);
song = songRepo.retrieveRecord(song, type::SongFilter::titleAndArtist); song = songRepo.retrieveRecord(song, type::SongFilter::titleAlbArtistAlbum);
return std::make_pair(true, type::SongUpload::Successful); return std::make_pair(true, type::SongUpload::Successful);
} }
@@ -293,8 +293,8 @@ namespace manager {
fs::remove(songPath); fs::remove(songPath);
} }
std::cout << "copying song to the appropriate directory\n"; std::cout << "copying song to the appropriate directory\n";
std::cout << song.songPath << std::endl; std::cout << song.songPath << "\n";
std::cout << songPath << std::endl; std::cout << songPath << "\n";
fs::copy(song.songPath, songPath); fs::copy(song.songPath, songPath);
fs::remove(song.songPath); fs::remove(song.songPath);
song.songPath = std::move(songPath); song.songPath = std::move(songPath);
+8 -12
View File
@@ -6,11 +6,6 @@
#include <sstream> #include <sstream>
#include <string.h> #include <string.h>
#include <attachedpictureframe.h>
#include <textidentificationframe.h>
#include <fileref.h>
#include <mpegfile.h>
#include <tag.h>
#include "manager/DirectoryManager.h" #include "manager/DirectoryManager.h"
#include "utility/ImageFile.h" #include "utility/ImageFile.h"
@@ -22,12 +17,13 @@ namespace utility {
model::Song MetadataRetriever::retrieveMetadata(model::Song& song) { model::Song MetadataRetriever::retrieveMetadata(model::Song& song) {
TagLib::MPEG::File sameFile(song.songPath.c_str()); TagLib::MPEG::File sameFile(song.songPath.c_str());
auto tag = sameFile.ID3v2Tag(); auto tag = sameFile.ID3v2Tag();
song.title = tag->title().toCString(); song.title = tag->title().toCString(true);
song.artist = tag->artist().toCString(); song.artist = tag->artist().toCString(true);
song.album = tag->album().toCString(); song.album = tag->album().toCString(true);
song.genre = tag->genre().toCString(); song.genre = tag->genre().toCString(true);
song.year = tag->year(); song.year = tag->year();
song.track = tag->track(); song.track = tag->track();
song.duration = sameFile.audioProperties()->lengthInSeconds(); song.duration = sameFile.audioProperties()->lengthInSeconds();
constexpr auto id3DiscName = "TPOS"; constexpr auto id3DiscName = "TPOS";
@@ -49,12 +45,12 @@ namespace utility {
if (albumArtistFrame.isEmpty()) { if (albumArtistFrame.isEmpty()) {
TagLib::ID3v2::TextIdentificationFrame *emptyFrame = TagLib::ID3v2::TextIdentificationFrame *emptyFrame =
new TagLib::ID3v2::TextIdentificationFrame(id3DiscName); new TagLib::ID3v2::TextIdentificationFrame(id3AlbumArtistName);
tag->addFrame(emptyFrame); tag->addFrame(emptyFrame);
emptyFrame->setText(song.artist.c_str()); emptyFrame->setText(song.artist.c_str());
sameFile.save(); sameFile.save();
} else { } else {
song.albumArtist = albumArtistFrame.front()->toString().toCString(); song.albumArtist = albumArtistFrame.front()->toString().toCString(true);
} }
return song; return song;
@@ -84,7 +80,7 @@ namespace utility {
tag->addFrame(pic); tag->addFrame(pic);
sngF.save(); sngF.save();
std::cout << "applied stock cover art" << std::endl; std::cout << "applied stock cover art\n";
} else { } else {
auto frame = dynamic_cast<TagLib::ID3v2::AttachedPictureFrame*>( auto frame = dynamic_cast<TagLib::ID3v2::AttachedPictureFrame*>(
frameList.front()); frameList.front());
+4 -4
View File
@@ -13,16 +13,16 @@ namespace utility {
std::unique_ptr<char[]> salt(new char[BCRYPT_HASHSIZE]); std::unique_ptr<char[]> salt(new char[BCRYPT_HASHSIZE]);
std::unique_ptr<char[]> hash(new char[BCRYPT_HASHSIZE]); std::unique_ptr<char[]> hash(new char[BCRYPT_HASHSIZE]);
std::cout << "generating salt" << std::endl; std::cout << "generating salt\n";
bcrypt_gensalt(saltSize(), salt.get()); bcrypt_gensalt(saltSize(), salt.get());
std::cout << "hashing password" << std::endl; std::cout << "hashing password\n";
bcrypt_hashpw(user.password.c_str(), salt.get(), hash.get()); bcrypt_hashpw(user.password.c_str(), salt.get(), hash.get());
passSec.salt = salt.get(); passSec.salt = salt.get();
passSec.hashPassword = hash.get(); passSec.hashPassword = hash.get();
std::cout << "hash: " << passSec.hashPassword << std::endl; std::cout << "hash: " << passSec.hashPassword << "\n";
std::cout << "salt: " << passSec.salt << std::endl; std::cout << "salt: " << passSec.salt << "\n";
return passSec; return passSec;
} }
+1 -1
View File
@@ -22,7 +22,7 @@ namespace verify {
auto database = confirmConfigDatabase(bConf); auto database = confirmConfigDatabase(bConf);
auto path = confirmConfigPaths(bConf); auto path = confirmConfigPaths(bConf);
if ((auth && database && path) == false) { if ((!auth) && (!database) && (!path)) {
failedConfirmation(); failedConfirmation();
} }