Added feature to upload all songs from a directory (optional recursive). Need to document the use of it as well as how to even use this CLI

This commit is contained in:
kdeng00
2019-10-23 20:48:42 -04:00
parent 27aecc7a0d
commit 81892cc52e
11 changed files with 162 additions and 29 deletions
+12 -8
View File
@@ -42,15 +42,19 @@ namespace Syncers
cout<<"song path "<<song.songPath<<endl;
string auth{token.tokenType};
auth.append(" " + token.accessToken);
/**
auto r = cpr::Get(cpr::Url(url),
cpr::Header{{"authorization", auth}});
*/
auto r = cpr::Get(cpr::Url(url),
cpr::Header{{"Content-type", "audio/mpeg"}});
int statusCode = r.status_code;
if (statusCode == OK)
{
if (statusCode == OK) {
song.data = r.text;
saveSong(&song);
saveSong(song);
}
@@ -74,14 +78,14 @@ namespace Syncers
return url;
}
void Download::saveSong(Song *song)
void Download::saveSong(Song& song)
{
cout<<"\nSaving song to: "<<song->songPath<<endl;
int bufferLength = song->data.length();
const char *data = song->data.c_str();
cout<<"\nSaving song to: "<<song.songPath<<endl;
int bufferLength = song.data.length();
const char *data = song.data.c_str();
cout<<"buff length "<<bufferLength<<endl;
ofstream saveSong{song->songPath, std::ios::binary};
ofstream saveSong{song.songPath, std::ios::binary};
saveSong.write(data, bufferLength);
saveSong.close();
}