Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a1edbeb164 | |||
| 437a6b1453 | |||
| f2d0947b36 | |||
| b067882c09 | |||
| 57f76ee4a4 | |||
| e846989a7f | |||
| 91ae3a908e | |||
| a970ba207e |
Vendored
+1
-1
Submodule 3rdparty/cpr updated: feebd2fd54...07d784ccfe
Vendored
+1
-1
Submodule 3rdparty/jwt-cpp updated: 27f32983fb...65b632b674
Vendored
+1
-1
Submodule 3rdparty/oatpp updated: 5b4b313a0b...27c46444db
Vendored
+1
-1
Submodule 3rdparty/taglib updated: 79bc9ccf8e...e36a9cabb9
+1
-1
@@ -1,5 +1,5 @@
|
||||
[requires]
|
||||
jsonformoderncpp/3.7.0@vthiery/stable
|
||||
jsonformoderncpp/3.7.3@vthiery/stable
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
#include <string>
|
||||
|
||||
#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 {
|
||||
class StreamCallback : public oatpp::data::stream::ReadCallback {
|
||||
@@ -12,7 +14,7 @@ namespace callback {
|
||||
StreamCallback();
|
||||
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:
|
||||
std::string m_songPath;
|
||||
|
||||
|
||||
@@ -9,13 +9,15 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <oatpp/core/async/Coroutine.hpp>
|
||||
#include "oatpp/core/data/stream/ChunkedBuffer.hpp"
|
||||
#include "oatpp/core/data/stream/FileStream.hpp"
|
||||
#include "oatpp/core/base/StrBuffer.hpp"
|
||||
#include "oatpp/core/macro/codegen.hpp"
|
||||
#include "oatpp/core/macro/component.hpp"
|
||||
#include "oatpp/web/mime/multipart/InMemoryPartReader.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 "callback/StreamCallback.h"
|
||||
@@ -41,10 +43,12 @@ namespace controller {
|
||||
|
||||
// endpoint for uploading a song
|
||||
ENDPOINT("POST", "/api/v1/song/data", songUpload,
|
||||
//AUTHORIZATION(std::shared_ptr<oatpp::web::server::handler::DefaultBearerAuthorizationObject>, authObject),
|
||||
REQUEST(std::shared_ptr<IncomingRequest>, request)) {
|
||||
auto authHeader = request->getHeader("Authorization");
|
||||
OATPP_ASSERT_HTTP(authHeader, Status::CODE_403, "Nope");
|
||||
auto auth = authHeader->std_str();
|
||||
|
||||
manager::TokenManager tok;
|
||||
OATPP_ASSERT_HTTP(tok.isTokenValid(auth,
|
||||
type::Scope::upload), Status::CODE_403, "Not allowed");
|
||||
@@ -64,10 +68,10 @@ namespace controller {
|
||||
|
||||
OATPP_ASSERT_HTTP(file, Status::CODE_400, "file is null");
|
||||
|
||||
auto buff = std::unique_ptr<char>(new char[file->getKnownSize()]);
|
||||
auto buffSize = file->getInputStream()->read(buff.get(), file->getKnownSize());
|
||||
auto buff = std::make_unique<const char*>(file->getInMemoryData()->c_str());
|
||||
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;
|
||||
sng.data = std::move(data);
|
||||
@@ -221,11 +225,12 @@ namespace controller {
|
||||
|
||||
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>(
|
||||
std::make_shared<callback::StreamCallback>(songDb.songPath),
|
||||
nullptr, dSize);
|
||||
auto callback = std::make_shared<callback::StreamCallback>(songDb.songPath);
|
||||
auto db = std::make_shared<oatpp::web::protocol::http::outgoing::StreamingBody>(
|
||||
callback
|
||||
);
|
||||
|
||||
auto response = OutgoingResponse::createShared(Status::CODE_200, db);
|
||||
response->putHeader(Header::CONNECTION, Header::Value::CONNECTION_KEEP_ALIVE);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <filesystem>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
@@ -12,7 +13,9 @@
|
||||
namespace manager {
|
||||
class DirectoryManager {
|
||||
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&,
|
||||
const model::BinaryPath&, type::PathType);
|
||||
static std::string configPath(std::string_view);
|
||||
@@ -29,6 +32,10 @@ namespace manager {
|
||||
void deleteCoverArtFile(const std::string&, const std::string&);
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace type {
|
||||
albumArtist,
|
||||
genre,
|
||||
year,
|
||||
titleAndArtist
|
||||
titleAndArtist,
|
||||
titleAlbArtistAlbum,
|
||||
titleAlbArtistAlbumTrack
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,19 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <attachedpictureframe.h>
|
||||
#include <textidentificationframe.h>
|
||||
#include <fileref.h>
|
||||
#include <mpegfile.h>
|
||||
#include <tag.h>
|
||||
|
||||
#include "model/Models.h"
|
||||
|
||||
namespace utility {
|
||||
class MetadataRetriever {
|
||||
public:
|
||||
model::Song retrieveMetadata(model::Song&);
|
||||
|
||||
|
||||
model::Cover updateCoverArt(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&);
|
||||
|
||||
@@ -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) {
|
||||
std::cout << "done streaming song\n";
|
||||
return 0;
|
||||
|
||||
@@ -41,6 +41,12 @@ namespace database {
|
||||
case type::SongFilter::titleAndArtist:
|
||||
valueFilterCount = 2;
|
||||
break;
|
||||
case type::SongFilter::titleAlbArtistAlbum:
|
||||
valueFilterCount = 3;
|
||||
break;
|
||||
case type::SongFilter::titleAlbArtistAlbumTrack:
|
||||
valueFilterCount = 4;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -53,6 +59,8 @@ namespace database {
|
||||
|
||||
auto titleLength = song.title.size();
|
||||
auto artistLength = song.artist.size();
|
||||
auto albumArtistLength = song.albumArtist.size();
|
||||
auto albumLength = song.album.size();
|
||||
switch (filter) {
|
||||
case type::SongFilter::id:
|
||||
qry << "sng.SongId = ?";
|
||||
@@ -86,6 +94,47 @@ namespace database {
|
||||
std::cout << "title: " << song.title.c_str() << " artist: " <<
|
||||
song.artist.c_str() << "\n";
|
||||
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:
|
||||
break;
|
||||
}
|
||||
@@ -103,7 +152,6 @@ namespace database {
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
mysql_close(conn);
|
||||
std::cout << "done\n";
|
||||
|
||||
return retrievedSong;
|
||||
}
|
||||
@@ -119,6 +167,12 @@ namespace database {
|
||||
case type::SongFilter::titleAndArtist:
|
||||
valueFilterCount = 2;
|
||||
break;
|
||||
case type::SongFilter::titleAlbArtistAlbum:
|
||||
valueFilterCount = 3;
|
||||
break;
|
||||
case type::SongFilter::titleAlbArtistAlbumTrack:
|
||||
valueFilterCount = 4;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -127,13 +181,16 @@ namespace database {
|
||||
MYSQL_BIND params[valueFilterCount];
|
||||
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 artistLength = song.artist.size();
|
||||
auto albumArtistLength = song.albumArtist.size();
|
||||
auto albumLength = song.album.size();
|
||||
switch (filter) {
|
||||
case type::SongFilter::id:
|
||||
qry << "SongId = ?";
|
||||
qry << "sng.SongId = ?";
|
||||
|
||||
params[0].buffer_type = MYSQL_TYPE_LONG;
|
||||
params[0].buffer = (char*)&song.id;
|
||||
@@ -141,7 +198,7 @@ namespace database {
|
||||
params[0].is_null = 0;
|
||||
break;
|
||||
case type::SongFilter::title:
|
||||
qry << "Title = ?";
|
||||
qry << "sng.Title = ?";
|
||||
|
||||
params[0].buffer_type = MYSQL_TYPE_STRING;
|
||||
params[0].buffer = (char*)song.title.c_str();
|
||||
@@ -149,7 +206,7 @@ namespace database {
|
||||
params[0].is_null = 0;
|
||||
break;
|
||||
case type::SongFilter::titleAndArtist:
|
||||
qry << "Title = ? AND Artist = ?";
|
||||
qry << "sng.Title = ? AND sng.Artist = ?";
|
||||
|
||||
params[0].buffer_type = MYSQL_TYPE_STRING;
|
||||
params[0].buffer = (char*)song.title.c_str();
|
||||
@@ -161,6 +218,47 @@ namespace database {
|
||||
params[1].length = &artistLength;
|
||||
params[1].is_null = 0;
|
||||
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:
|
||||
break;
|
||||
}
|
||||
@@ -179,7 +277,6 @@ namespace database {
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
mysql_close(conn);
|
||||
std::cout << "done\n";
|
||||
|
||||
return (rowCount > 0) ? true : false;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace manager {
|
||||
std::string DirectoryManager::createDirectoryProcess(model::Song song,
|
||||
std::string DirectoryManager::createDirectoryProcess(const model::Song& song,
|
||||
const std::string& rootPath) {
|
||||
auto currPath = fs::path(rootPath);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace manager {
|
||||
fs::create_directory(artPath);
|
||||
}
|
||||
|
||||
auto albPath = fs::path(artPath.string() + "/" + song.album);
|
||||
auto albPath = fs::path(artPath.string() + "/" + song.albumArtist);
|
||||
if (fs::exists(albPath)) {
|
||||
std::cout << "album path exists\n";
|
||||
} else {
|
||||
@@ -35,7 +35,16 @@ namespace manager {
|
||||
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,
|
||||
@@ -67,7 +76,15 @@ namespace manager {
|
||||
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) {
|
||||
@@ -136,6 +153,15 @@ namespace manager {
|
||||
std::cout << "checking for empty directories to delete\n";
|
||||
const std::string art(rootPath + std::string("/") + song.albumArtist);
|
||||
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);
|
||||
|
||||
@@ -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) {
|
||||
std::cout << "deleting song\n";
|
||||
auto songPath = fs::path(song.songPath);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <random>
|
||||
|
||||
#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 "database/CoverArtRepository.h"
|
||||
@@ -33,7 +33,7 @@ namespace manager {
|
||||
song.data = std::move(data);
|
||||
|
||||
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 << "does not exist\n";
|
||||
return std::make_pair(false, type::SongUpload::AlreadyExist);
|
||||
@@ -44,7 +44,7 @@ namespace manager {
|
||||
printSong(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);
|
||||
}
|
||||
@@ -293,8 +293,8 @@ namespace manager {
|
||||
fs::remove(songPath);
|
||||
}
|
||||
std::cout << "copying song to the appropriate directory\n";
|
||||
std::cout << song.songPath << std::endl;
|
||||
std::cout << songPath << std::endl;
|
||||
std::cout << song.songPath << "\n";
|
||||
std::cout << songPath << "\n";
|
||||
fs::copy(song.songPath, songPath);
|
||||
fs::remove(song.songPath);
|
||||
song.songPath = std::move(songPath);
|
||||
|
||||
@@ -6,11 +6,6 @@
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
|
||||
#include <attachedpictureframe.h>
|
||||
#include <textidentificationframe.h>
|
||||
#include <fileref.h>
|
||||
#include <mpegfile.h>
|
||||
#include <tag.h>
|
||||
|
||||
#include "manager/DirectoryManager.h"
|
||||
#include "utility/ImageFile.h"
|
||||
@@ -22,12 +17,13 @@ namespace utility {
|
||||
model::Song MetadataRetriever::retrieveMetadata(model::Song& song) {
|
||||
TagLib::MPEG::File sameFile(song.songPath.c_str());
|
||||
auto tag = sameFile.ID3v2Tag();
|
||||
song.title = tag->title().toCString();
|
||||
song.artist = tag->artist().toCString();
|
||||
song.album = tag->album().toCString();
|
||||
song.genre = tag->genre().toCString();
|
||||
song.title = tag->title().toCString(true);
|
||||
song.artist = tag->artist().toCString(true);
|
||||
song.album = tag->album().toCString(true);
|
||||
song.genre = tag->genre().toCString(true);
|
||||
song.year = tag->year();
|
||||
song.track = tag->track();
|
||||
|
||||
song.duration = sameFile.audioProperties()->lengthInSeconds();
|
||||
|
||||
constexpr auto id3DiscName = "TPOS";
|
||||
@@ -49,12 +45,12 @@ namespace utility {
|
||||
|
||||
if (albumArtistFrame.isEmpty()) {
|
||||
TagLib::ID3v2::TextIdentificationFrame *emptyFrame =
|
||||
new TagLib::ID3v2::TextIdentificationFrame(id3DiscName);
|
||||
new TagLib::ID3v2::TextIdentificationFrame(id3AlbumArtistName);
|
||||
tag->addFrame(emptyFrame);
|
||||
emptyFrame->setText(song.artist.c_str());
|
||||
sameFile.save();
|
||||
} else {
|
||||
song.albumArtist = albumArtistFrame.front()->toString().toCString();
|
||||
song.albumArtist = albumArtistFrame.front()->toString().toCString(true);
|
||||
}
|
||||
|
||||
return song;
|
||||
@@ -84,7 +80,7 @@ namespace utility {
|
||||
tag->addFrame(pic);
|
||||
|
||||
sngF.save();
|
||||
std::cout << "applied stock cover art" << std::endl;
|
||||
std::cout << "applied stock cover art\n";
|
||||
} else {
|
||||
auto frame = dynamic_cast<TagLib::ID3v2::AttachedPictureFrame*>(
|
||||
frameList.front());
|
||||
|
||||
@@ -13,16 +13,16 @@ namespace utility {
|
||||
std::unique_ptr<char[]> salt(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());
|
||||
std::cout << "hashing password" << std::endl;
|
||||
std::cout << "hashing password\n";
|
||||
bcrypt_hashpw(user.password.c_str(), salt.get(), hash.get());
|
||||
|
||||
passSec.salt = salt.get();
|
||||
passSec.hashPassword = hash.get();
|
||||
|
||||
std::cout << "hash: " << passSec.hashPassword << std::endl;
|
||||
std::cout << "salt: " << passSec.salt << std::endl;
|
||||
std::cout << "hash: " << passSec.hashPassword << "\n";
|
||||
std::cout << "salt: " << passSec.salt << "\n";
|
||||
|
||||
return passSec;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace verify {
|
||||
auto database = confirmConfigDatabase(bConf);
|
||||
auto path = confirmConfigPaths(bConf);
|
||||
|
||||
if ((auth && database && path) == false) {
|
||||
if ((!auth) && (!database) && (!path)) {
|
||||
failedConfirmation();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user