Support new upload endpoint #9
@@ -7,7 +7,7 @@ IcarusDownloadManager is a Linux CLI software client application that has the fe
|
||||
|
||||
* C++ with C++17 features
|
||||
* CMake
|
||||
* GCC >= 9
|
||||
* GCC >= 9 or Visual Studio >= 16 [2019]
|
||||
* [conan](https://github.com/conan-io/conan)
|
||||
* [json](https://github.com/nlohmann/json)
|
||||
* [openssl](https://github.com/openssl/openssl)
|
||||
@@ -28,18 +28,20 @@ cd build
|
||||
|
||||
conan install .. --build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=RELEASE
|
||||
cmake --build . -j
|
||||
cmake ..
|
||||
cmake --build . --config release -j
|
||||
```
|
||||
|
||||
The program has been built and can be executed by the binary file *icd*. For information on how to use icd, merely execute the program without any command line arguments.
|
||||
|
||||
### Downloading Song
|
||||
|
||||
```BASH
|
||||
icd download -u spacecadet -p stellar40 -h https://icarus.com -b 15
|
||||
```
|
||||
|
||||
### Uploading Song
|
||||
|
||||
```BASH
|
||||
icd upload -u spacecadet -p stellar40 -h https://icarus.com -s /path/of/song.mp3
|
||||
```
|
||||
@@ -53,16 +55,18 @@ icd upload-meta -u spacecadet -p stellar40 -h https://icarus.com -s /path/of/son
|
||||
### Uploading Song with metadata from directory
|
||||
|
||||
```BASH
|
||||
icd upload-meta -u spacecadet -p stellar40 -h https://icarus.com -smca /path/where/songs/and/metadata/exist
|
||||
icd upload-meta -u spacecadet -p stellar40 -h https://icarus.com -smca /path/where/songs/and/metadata/exists/
|
||||
```
|
||||
|
||||
|
||||
### Retrieving Song in json
|
||||
|
||||
```Bash
|
||||
icd retrieve -u spacecadet -p stellar40 -h https://icarus.com -rt songs
|
||||
```
|
||||
|
||||
### Deleting Song
|
||||
|
||||
```BASH
|
||||
icd delete -u spacecadet -p stellar40 -h https://icarus.com -D 15
|
||||
```
|
||||
@@ -74,6 +78,7 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the code of conduc
|
||||
|
||||
## Versioning
|
||||
|
||||
[v0.2.0](https://github.com/kdeng00/IcarusDownloadManager/releases/tag/v0.2.0)
|
||||
[v0.1.1](https://github.com/kdeng00/IcarusDownloadManager/releases/tag/v0.1.1)
|
||||
[v0.1.0](https://github.com/kdeng00/IcarusDownloadManager/releases/tag/0.1.0)
|
||||
|
||||
|
||||
+44
-2
@@ -1,8 +1,9 @@
|
||||
#ifndef SONG_H_
|
||||
#define SONG_H_
|
||||
|
||||
#include<string>
|
||||
#include<iostream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
namespace Models
|
||||
@@ -19,6 +20,44 @@ public:
|
||||
std::cout<<"\n";
|
||||
}
|
||||
|
||||
std::string song_path() noexcept
|
||||
{
|
||||
std::stringstream buffer;
|
||||
|
||||
buffer << this->directory;
|
||||
|
||||
const auto count = this->directory.size();
|
||||
|
||||
if (this->directory.at(count - 1) != '/' || this->directory.at(count - 1) != '\\')
|
||||
{
|
||||
buffer << "/";
|
||||
}
|
||||
|
||||
buffer << this->filename;
|
||||
|
||||
return buffer.str();
|
||||
}
|
||||
|
||||
int generate_filename_from_track()
|
||||
{
|
||||
auto result = 0;
|
||||
std::stringstream buffer;
|
||||
buffer << "track";
|
||||
|
||||
// NOTE: Multiple discs in one directory is not being addressed
|
||||
if (this->track < 10)
|
||||
{
|
||||
buffer << "0";
|
||||
}
|
||||
|
||||
buffer << this->track << ".mp3";
|
||||
|
||||
|
||||
this->filename.assign(buffer.str());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string toMetadataJson();
|
||||
|
||||
|
||||
@@ -32,7 +71,10 @@ public:
|
||||
int track;
|
||||
int disc;
|
||||
std::string data;
|
||||
[[deprecated("Use song_path() function instead")]]
|
||||
std::string songPath;
|
||||
std::string filename;
|
||||
std::string directory;
|
||||
};
|
||||
|
||||
class CoverArt
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ using Managers::CommitManager;
|
||||
|
||||
constexpr static auto IcarusDownloadManager_version()
|
||||
{
|
||||
return "v0.1.2";
|
||||
return "v0.2.0";
|
||||
}
|
||||
|
||||
void printHelp()
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
#include"Managers/CommitManager.h"
|
||||
|
||||
#include<iostream>
|
||||
#include<fstream>
|
||||
#include<sstream>
|
||||
#include<filesystem>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <filesystem>
|
||||
|
||||
#include"nlohmann/json.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include"Models/API.h"
|
||||
#include"Models/Song.h"
|
||||
#include"Models/Token.h"
|
||||
#include"Parsers/APIParser.h"
|
||||
#include"Syncers/Delete.h"
|
||||
#include"Syncers/Download.h"
|
||||
#include"Syncers/RetrieveRecords.h"
|
||||
#include"Syncers/Upload.h"
|
||||
#include "Models/API.h"
|
||||
#include "Models/Song.h"
|
||||
#include "Models/Token.h"
|
||||
#include "Parsers/APIParser.h"
|
||||
#include "Syncers/Delete.h"
|
||||
#include "Syncers/Download.h"
|
||||
#include "Syncers/RetrieveRecords.h"
|
||||
#include "Syncers/Upload.h"
|
||||
|
||||
#include"Managers/TokenManager.h"
|
||||
#include"Managers/UserManager.h"
|
||||
#include "Managers/TokenManager.h"
|
||||
#include "Managers/UserManager.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@@ -308,7 +308,9 @@ void CommitManager::singTargetUpload(const std::string &songPath, const std::str
|
||||
}
|
||||
|
||||
song = *sng;
|
||||
song.songPath = songPath;
|
||||
const auto p = fs::path(songPath);
|
||||
song.directory = p.parent_path.string();
|
||||
song.generate_filename_from_track();
|
||||
|
||||
Models::CoverArt cover;
|
||||
cover.title = song.title;
|
||||
@@ -363,6 +365,8 @@ void CommitManager::multiTargetUpload(const std::string &sourcePath)
|
||||
}
|
||||
|
||||
auto album = retrieveMetadata(metadataPath);
|
||||
songs.clear();
|
||||
songs.assign(album.songs.begin(), album.songs.end());
|
||||
|
||||
Upload up(api, token);
|
||||
|
||||
@@ -399,6 +403,9 @@ CommitManager::Album CommitManager::retrieveMetadata(const std::string_view path
|
||||
song.album = album.album;
|
||||
song.year = album.year;
|
||||
song.genre = album.genre;
|
||||
song.generate_filename_from_track();
|
||||
const auto p = fs::path(path);
|
||||
song.directory = p.parent_path().string();
|
||||
|
||||
album.songs.push_back(song);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ void Upload::uploadSongWithMetadata(Managers::CommitManager::Album &album, Model
|
||||
{
|
||||
auto url = retrieveUrl();
|
||||
|
||||
cout<<"url "<<url<<endl;
|
||||
cout << "url " << url << "\n";
|
||||
string auth(this->m_token.tokenType);
|
||||
auth.append(" " + this->m_token.accessToken);
|
||||
|
||||
@@ -131,10 +131,11 @@ void Upload::uploadSongWithMetadata(Managers::CommitManager::Album &album, Model
|
||||
const auto meta = s.dump();
|
||||
|
||||
cout<<"\n\nMeta:\n"<<meta<<"\n";
|
||||
cout << "Filepath: " << song.song_path() << "\n";
|
||||
|
||||
auto multipart = cpr::Multipart{{"cover", cpr::File{cover.path}},
|
||||
{"metadata", meta},
|
||||
{"file", cpr::File{song.songPath}}};
|
||||
{"file", cpr::File{song.song_path()}}};
|
||||
|
||||
auto r = cpr::Post(cpr::Url{url}, multipart,
|
||||
cpr::Header{{"authorization", auth}}
|
||||
|
||||
Reference in New Issue
Block a user