read/parse file tags
import audiofiles
This commit is contained in:
@@ -1 +1,3 @@
|
||||
*.o
|
||||
build/
|
||||
data/
|
||||
|
||||
+2
-1
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "Metadata.h"
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -19,3 +18,5 @@ class File {
|
||||
std::string fileName_;
|
||||
fs::path fp_ = musicFolder_ / fileName_;
|
||||
};
|
||||
|
||||
std::string_view parseFiletype( std::string_view path );
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+4
-1
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "Metadata.h"
|
||||
#include <memory>
|
||||
#include <taglib/tstring.h>
|
||||
#include <taglib/fileref.h>
|
||||
#include <taglib/tvariant.h>
|
||||
|
||||
|
||||
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_;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "include/Tag.h"
|
||||
#include "include/File.h"
|
||||
//#include "include/Metadata.h"
|
||||
|
||||
//#include <filesystem>
|
||||
#include <iostream>
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
@@ -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 );
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
+4
-1
@@ -1,9 +1,10 @@
|
||||
#include "../include/Metadata.h"
|
||||
#include "../include/Tag.h"
|
||||
#include "../include/File.h"
|
||||
|
||||
#include <taglib/tag.h>
|
||||
#include <taglib/fileref.h>
|
||||
|
||||
|
||||
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_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user