Made progress

This commit is contained in:
kdeng00
2021-12-31 19:09:31 -05:00
parent 9930aab985
commit 14d3c9acc6
10 changed files with 296 additions and 59 deletions
+17 -3
View File
@@ -1,6 +1,7 @@
#ifndef ACTIONMANAGER_H_
#define ACTIONMANAGER_H_
#include<algorithm>
#include<string>
#include<string_view>
#include<array>
@@ -18,11 +19,24 @@ namespace Managers
Models::IcarusAction retrieveIcarusAction() const;
private:
constexpr std::array<const char*, 12> supportedFlags() noexcept;
constexpr std::array<const char*, 15> supportedFlags() noexcept
{
constexpr std::array<const char*, 15> allFlags{"-u", "-p", "-t", "-h", "-s",
"-sd", "-sr", "-d", "-D", "-b", "-rt", "-nc",
"-m", "-ca", "-smca"};
return allFlags;
}
constexpr std::array<const char*, 4> supportedActions() noexcept;
bool isNumber(const std::string_view) noexcept;
bool isNumber(const std::string_view val) noexcept
{
return !val.empty() && std::find_if(val.begin(),
val.end(), [](char c)
{
return !std::isdigit(c);
}) == val.end();
}
void initialize();
void validateFlags();
+52 -2
View File
@@ -2,11 +2,14 @@
#define COMMITMANAGER_H_
#include<map>
#include<iostream>
#include<string>
#include<string_view>
#include"Models/API.h"
#include"Models/Token.h"
#include"Models/IcarusAction.h"
#include"Models/Song.h"
#include"Models/Token.h"
namespace Managers
{
@@ -22,6 +25,24 @@ namespace Managers
songs
};
// Used for parsing songs from the metadata file
class Album
{
public:
Album() = default;
void printInfo();
std::string album;
std::string albumArtist;
std::string genre;
int year;
int trackCount;
int discCount;
std::vector<Models::Song> songs;
};
private:
enum class ActionValues;
@@ -33,15 +54,44 @@ namespace Managers
void downloadSong();
void retrieveObjects();
void uploadSong();
// 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
// be present.
//
// Expects
// * Song - mp3 file path
// * Metadata - Source file containing metadata of the song
// * Cover art - path to image cover art
void uploadSingleSong();
// Checks for the no confirm flag. Used when uploading songs from a directory
bool checkForNoConfirm()
{
for (const auto &arg: this->icaAction.flags)
{
if (arg.flag.compare("-nc") == 0)
{
return true;
}
}
return false;
}
Album retrieveMetadata(const std::string_view path);
std::string retrieveFileContent(const std::string_view path);
enum class ActionValues
{
deleteAct,
downloadAct,
retrieveAct,
uploadAct
uploadAct,
UPLOAD_SONG_WITH_METADATA // Uploads the song with metadata, including cover art
};
Models::IcarusAction icaAction;
};
}