Saving changes
This commit is contained in:
+18
-6
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
|
|
||||||
project(IcarusDownloadManager)
|
project(IcarusDownloadManager)
|
||||||
@@ -9,10 +9,21 @@ message(STATUS "Checking compiler flags for C++17 support.")
|
|||||||
# Set C++17 support flags for various compilers
|
# Set C++17 support flags for various compilers
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
check_cxx_compiler_flag("-std=c++17" COMPILER_SUPPORTS_CXX17)
|
if(WIN32)
|
||||||
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
message("Windows")
|
||||||
|
set(vs_ver 19.29.30138)
|
||||||
|
|
||||||
if(COMPILER_SUPPORTS_CXX17)
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL ${vs_ver})
|
||||||
|
message("Visual Studio version is at least ${vs_ver}")
|
||||||
|
|
||||||
|
set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std:c++latest")
|
||||||
|
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++latest")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
check_cxx_compiler_flag("-std=c++17" COMPILER_SUPPORTS_CXX17)
|
||||||
|
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||||
|
|
||||||
|
if(COMPILER_SUPPORTS_CXX17)
|
||||||
message(STATUS "C++17 is supported.")
|
message(STATUS "C++17 is supported.")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
@@ -23,15 +34,16 @@ if(COMPILER_SUPPORTS_CXX17)
|
|||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||||
endif()
|
endif()
|
||||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||||
message(STATUS "C++0x is supported.")
|
message(STATUS "C++0x is supported.")
|
||||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -stdlib=libc++")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -stdlib=libc++")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler.")
|
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support. Please use a different C++ compiler.")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ private:
|
|||||||
void printAction() noexcept;
|
void printAction() noexcept;
|
||||||
void printFlags() noexcept;
|
void printFlags() noexcept;
|
||||||
|
|
||||||
|
std::vector<std::string> parsedFlags();
|
||||||
|
|
||||||
std::string action;
|
std::string action;
|
||||||
|
|
||||||
std::vector<Models::Flags> flags;
|
std::vector<Models::Flags> flags;
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ private:
|
|||||||
void downloadSong();
|
void downloadSong();
|
||||||
void retrieveObjects();
|
void retrieveObjects();
|
||||||
void uploadSong();
|
void uploadSong();
|
||||||
|
|
||||||
|
Models::Token parseToken(Models::API);
|
||||||
|
|
||||||
// Uploads a single song. The song is constructed from a metadata file that contains
|
// Uploads a single song. The song is constructed from a metadata file that contains
|
||||||
// information about the album the song is from. Also, the cover art of the song must
|
// information about the album the song is from. Also, the cover art of the song must
|
||||||
// be present.
|
// be present.
|
||||||
|
|||||||
@@ -13,13 +13,6 @@ public:
|
|||||||
std::string value;
|
std::string value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Flags
|
|
||||||
{
|
|
||||||
std::string flag;
|
|
||||||
std::string value;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+11
-10
@@ -1,18 +1,18 @@
|
|||||||
#ifndef UPLOAD_H_
|
#ifndef UPLOAD_H_
|
||||||
#define UPLOAD_H_
|
#define UPLOAD_H_
|
||||||
|
|
||||||
#include<filesystem>
|
#include <filesystem>
|
||||||
#include<string>
|
#include <string>
|
||||||
#include<vector>
|
#include <vector>
|
||||||
|
|
||||||
#include<nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include"Managers/CommitManager.h"
|
#include "Managers/CommitManager.h"
|
||||||
#include"Managers/FileManager.h"
|
#include "Managers/FileManager.h"
|
||||||
#include"Models/API.h"
|
#include "Models/API.h"
|
||||||
#include"Models/Song.h"
|
#include "Models/Song.h"
|
||||||
#include"Models/Token.h"
|
#include "Models/Token.h"
|
||||||
#include"Models/UploadForm.h"
|
#include "Models/UploadForm.h"
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@ namespace Syncers
|
|||||||
class Upload
|
class Upload
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Upload() = default;
|
||||||
Upload(Models::API api, Models::Token token) : m_token(token), api(api)
|
Upload(Models::API api, Models::Token token) : m_token(token), api(api)
|
||||||
{
|
{
|
||||||
this->api.endpoint = "song/data";
|
this->api.endpoint = "song/data";
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initializeValues();
|
void initializeValues();
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void printValue(T val);
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -36,14 +36,6 @@ IcarusAction ActionManager::retrieveIcarusAction() const
|
|||||||
return icarusAction;
|
return icarusAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ActionManager::isNumber(string_view val) noexcept
|
|
||||||
{
|
|
||||||
return !val.empty() && std::find_if(val.begin(),
|
|
||||||
val.end(), [](char c)
|
|
||||||
{
|
|
||||||
return !std::isdigit(c);
|
|
||||||
}) == val.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ActionManager::initialize()
|
void ActionManager::initialize()
|
||||||
|
|||||||
+8
-24
@@ -1,12 +1,11 @@
|
|||||||
#include<iostream>
|
#include <iostream>
|
||||||
#include<filesystem>
|
#include <filesystem>
|
||||||
#include<exception>
|
#include <exception>
|
||||||
|
|
||||||
#include<cpr/cpr.h>
|
#include "cpr/cpr.h"
|
||||||
#include<nlohmann/json.hpp>
|
|
||||||
|
|
||||||
#include"Syncers/Upload.h"
|
#include "Syncers/Upload.h"
|
||||||
#include"Utilities/Conversions.h"
|
#include "Utilities/Conversions.h"
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::cin;
|
using std::cin;
|
||||||
@@ -27,11 +26,6 @@ namespace Syncers
|
|||||||
{
|
{
|
||||||
|
|
||||||
#pragma region Constructors
|
#pragma region Constructors
|
||||||
Upload::Upload() { }
|
|
||||||
Upload::Upload(API api) : api(api)
|
|
||||||
{
|
|
||||||
this->api.endpoint = "song/data";
|
|
||||||
}
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -97,13 +91,6 @@ void Upload::uploadSongsFromDirectory(const std::string& directory,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!confirmUpload)
|
|
||||||
{
|
|
||||||
confirmUpload = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "uploading songs\n";
|
cout << "uploading songs\n";
|
||||||
for (auto& song: songs)
|
for (auto& song: songs)
|
||||||
{
|
{
|
||||||
@@ -126,10 +113,9 @@ void Upload::uploadSongWithMetadata(Managers::CommitManager::Album &album, Model
|
|||||||
auto url = retrieveUrl();
|
auto url = retrieveUrl();
|
||||||
|
|
||||||
cout<<"url "<<url<<endl;
|
cout<<"url "<<url<<endl;
|
||||||
string auth{this->m_token.tokenType};
|
string auth(this->m_token.tokenType);
|
||||||
auth.append(" " + this->m_token.accessToken);
|
auth.append(" " + this->m_token.accessToken);
|
||||||
|
|
||||||
// const auto meta = song.toMetadataJson();
|
|
||||||
nlohmann::json s;
|
nlohmann::json s;
|
||||||
s["title"] = song.title;
|
s["title"] = song.title;
|
||||||
s["album"] = album.album;
|
s["album"] = album.album;
|
||||||
@@ -146,7 +132,6 @@ void Upload::uploadSongWithMetadata(Managers::CommitManager::Album &album, Model
|
|||||||
|
|
||||||
cout<<"\n\nMeta:\n"<<meta<<"\n";
|
cout<<"\n\nMeta:\n"<<meta<<"\n";
|
||||||
|
|
||||||
/**
|
|
||||||
auto multipart = cpr::Multipart{{"cover", cpr::File{cover.path}},
|
auto multipart = cpr::Multipart{{"cover", cpr::File{cover.path}},
|
||||||
{"metadata", meta},
|
{"metadata", meta},
|
||||||
{"file", cpr::File{song.songPath}}};
|
{"file", cpr::File{song.songPath}}};
|
||||||
@@ -157,7 +142,6 @@ void Upload::uploadSongWithMetadata(Managers::CommitManager::Album &album, Model
|
|||||||
|
|
||||||
cout << "status code: " << r.status_code<< std::endl;
|
cout << "status code: " << r.status_code<< std::endl;
|
||||||
cout << r.text << endl;
|
cout << r.text << endl;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
catch (exception &e)
|
catch (exception &e)
|
||||||
{
|
{
|
||||||
@@ -250,7 +234,7 @@ void Upload::printJsonData(const json& obj)
|
|||||||
cout<<"duration: "<<obj["duration"]<<endl;
|
cout<<"duration: "<<obj["duration"]<<endl;
|
||||||
cout<<"song_data: "<<obj["song_data"]<<endl;
|
cout<<"song_data: "<<obj["song_data"]<<endl;
|
||||||
|
|
||||||
cout<<endl<<endl;;
|
cout<<endl<<endl;
|
||||||
}
|
}
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user