diff --git a/.gitignore b/.gitignore index 8fce603..3f12463 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ +*.o +build/ data/ diff --git a/include/File.h b/include/File.h index 24e1c47..6d5f598 100644 --- a/include/File.h +++ b/include/File.h @@ -1,6 +1,5 @@ #pragma once -#include "Metadata.h" #include #include #include @@ -19,3 +18,5 @@ class File { std::string fileName_; fs::path fp_ = musicFolder_ / fileName_; }; + + std::string_view parseFiletype( std::string_view path ); diff --git a/include/Metadata.h b/include/Metadata.h index 0c404b8..cc04db4 100644 --- a/include/Metadata.h +++ b/include/Metadata.h @@ -9,7 +9,7 @@ struct Metadata { TagLib::String album; TagLib::String albumArtist; unsigned int year; - std::string artwork; + TagLib::VariantList artwork; TagLib::String genre; unsigned int trackNr; double length; diff --git a/include/Tag.h b/include/Tag.h index 7827894..4d12100 100644 --- a/include/Tag.h +++ b/include/Tag.h @@ -1,8 +1,10 @@ #pragma once #include "Metadata.h" +#include #include #include +#include class Tag { @@ -10,7 +12,8 @@ class Tag { void readTag( TagLib::FileName fileName ); Metadata getMetadata() const; - std::string& getFilePath() const; + const std::string& getFilePath() const; + const auto getArtwork() const; private: Metadata metadata_; std::string filePath_; diff --git a/main.cpp b/main.cpp index 8a4fea9..09b2190 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,6 @@ #include "include/Tag.h" #include "include/File.h" +//#include "include/Metadata.h" //#include #include @@ -9,10 +10,10 @@ //namespace fs = std::filesystem; int main() { - File file; Tag tag; + File file; //fs::path folderPath{ "data" }; - file.importFolder( "/home/fegger/Projects/soundServe/data/" ); + file.importFolder( "/home/fegger/Code/projects/soundServe/data/" ); for ( auto& fp : file.filenames_) { std::cout << fp << "\n"; } @@ -29,6 +30,7 @@ int main() { << "\nGenre: " << meta.genre << "\nSamplerate: " << meta.sampleRate << "\nBitrate: " << meta.bitRate + << "\nFormat: " << meta.format << "\nLength: " << meta.length; std::cout << "\n----------------------------------------------------------------------\n"; } diff --git a/main.o b/main.o index 4a61de4..c1fa833 100644 Binary files a/main.o and b/main.o differ diff --git a/soundServe b/soundServe index 5655198..ecf7453 100755 Binary files a/soundServe and b/soundServe differ diff --git a/src/File.cpp b/src/File.cpp index fe3889b..e7abbe1 100644 --- a/src/File.cpp +++ b/src/File.cpp @@ -19,3 +19,11 @@ void File::importFile( std::string fileName ) { fs::path fp = fp_; } + +std::string_view parseFiletype( std::string_view path ){ + + size_t length = path.size(); + size_t dot = path.find_last_of( "."); + + return path.substr( dot + 1, length-dot ); +} diff --git a/src/File.o b/src/File.o index f73b2af..9c0da17 100644 Binary files a/src/File.o and b/src/File.o differ diff --git a/src/Tag.cpp b/src/Tag.cpp index f1ae0be..89ab7bc 100644 --- a/src/Tag.cpp +++ b/src/Tag.cpp @@ -1,9 +1,10 @@ -#include "../include/Metadata.h" #include "../include/Tag.h" +#include "../include/File.h" #include #include + void Tag::readTag( TagLib::FileName fileName ){ TagLib::FileRef f( fileName ); if ( !f.isNull() ) { @@ -16,11 +17,13 @@ void Tag::readTag( TagLib::FileName fileName ){ metadata_.sampleRate = f.audioProperties()->sampleRate(); metadata_.bitRate = f.audioProperties()->bitrate(); metadata_.length = f.audioProperties()->lengthInSeconds(); + metadata_.format = parseFiletype( fileName ); // TODO // file format } } + Metadata Tag::getMetadata() const { return metadata_; } diff --git a/src/Tag.o b/src/Tag.o index d85c6f2..5807f8b 100644 Binary files a/src/Tag.o and b/src/Tag.o differ