Working on migrating metadata over to c++
This commit is contained in:
@@ -235,6 +235,19 @@ namespace Icarus.Controllers.Managers
|
|||||||
SongPath = song.SongPath
|
SongPath = song.SongPath
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
public static Song ConvertSngToSong(Sng song)
|
||||||
|
{
|
||||||
|
return new Song
|
||||||
|
{
|
||||||
|
Id = song.Id,
|
||||||
|
Title = song.Title,
|
||||||
|
Artist = song.Artist,
|
||||||
|
AlbumTitle = song.Album,
|
||||||
|
Genre = song.Genre,
|
||||||
|
Year = song.Year,
|
||||||
|
SongPath = song.SongPath
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task<SongData> RetrieveSongFromFileSystem(Song details)
|
private async Task<SongData> RetrieveSongFromFileSystem(Song details)
|
||||||
@@ -257,15 +270,26 @@ namespace Icarus.Controllers.Managers
|
|||||||
await songFile.CopyToAsync(filestream);
|
await songFile.CopyToAsync(filestream);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetadataRetriever meta = new MetadataRetriever();
|
//MetadataRetriever meta = new MetadataRetriever();
|
||||||
song = meta.RetrieveMetaData(filePath);
|
//song = meta.RetrieveMetaData(filePath);
|
||||||
|
Console.WriteLine("try");
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
Song *sng = new Sng();
|
||||||
|
MetadataRetriever.retrieve_metadata(ref sng, filePath);
|
||||||
|
Console.WriteLine("Hmmmm");
|
||||||
|
Console.WriteLine($"sng title {sng.Title}");
|
||||||
|
song = ConvertSngToSong(sng);
|
||||||
|
}
|
||||||
|
|
||||||
_logger.Info("Assigning song filename");
|
_logger.Info("Assigning song filename");
|
||||||
song.Filename = songFile.FileName;
|
song.Filename = songFile.FileName;
|
||||||
|
|
||||||
|
Console.WriteLine("what?");
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
private async Task SaveSongToFileSystemTemp(IFormFile song, string filePath)
|
private async Task SaveSongToFileSystemTemp(IFormFile song, string filePath)
|
||||||
{
|
{
|
||||||
using (var fileStream = new FileStream(filePath, FileMode.Create))
|
using (var fileStream = new FileStream(filePath, FileMode.Create))
|
||||||
@@ -283,6 +307,7 @@ namespace Icarus.Controllers.Managers
|
|||||||
Console.WriteLine($"Song filename retrieved: {song.FileName}");
|
Console.WriteLine($"Song filename retrieved: {song.FileName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private bool SongRecordChanged(Song currentSong, Song songUpdates)
|
private bool SongRecordChanged(Song currentSong, Song songUpdates)
|
||||||
{
|
{
|
||||||
@@ -761,20 +786,24 @@ namespace Icarus.Controllers.Managers
|
|||||||
if (year.SongCount <= 1)
|
if (year.SongCount <= 1)
|
||||||
yearStore.DeleteYear(year);
|
yearStore.DeleteYear(year);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Structs
|
#region Structs
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||||
public struct Sng
|
public struct Sng
|
||||||
{
|
{
|
||||||
public int Id;
|
public int Id;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 50)]
|
||||||
public string Title;
|
public string Title;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 50)]
|
||||||
public string Artist;
|
public string Artist;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 50)]
|
||||||
public string Album;
|
public string Album;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 50)]
|
||||||
public string Genre;
|
public string Genre;
|
||||||
public int Year;
|
public int Year;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 50)]
|
||||||
public string SongPath;
|
public string SongPath;
|
||||||
};
|
};
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -103,7 +103,8 @@ namespace Icarus.Controllers.Utilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("libicarus.so")]
|
[DllImport("libicarus.so")]
|
||||||
public static extern Icarus.Controllers.Managers.SongManager.Sng retrieve_metadata(string file_path);
|
//public static extern Icarus.Controllers.Managers.SongManager.Sng retrieve_metadata(string file_path);
|
||||||
|
public static extern void retrieve_metadata(ref Icarus.Controllers.Managers.SongManager.Sng sng, string file_path);
|
||||||
|
|
||||||
public byte[] RetrieveCoverArtBytes(Song song)
|
public byte[] RetrieveCoverArtBytes(Song song)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
#include "models.h"
|
#include "models.h"
|
||||||
|
|
||||||
Song fetch_metadata(const char*);
|
void fetch_metadata(Song&, const char*);
|
||||||
|
|||||||
@@ -1,26 +1,79 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <taglib/tag.h>
|
||||||
|
#include <taglib/fileref.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "metadata_retriever.h"
|
#include "metadata_retriever.h"
|
||||||
|
|
||||||
Song fetch_metadata(const char *song_path)
|
void fetch_metadata(Song &sng, const char *song_path)
|
||||||
{
|
{
|
||||||
Song sng;
|
//Song sng;
|
||||||
std::string title = "ddd";
|
std::cout<<"extracting metadata from: "<<std::endl;
|
||||||
sng.Title = (char*)title.c_str();
|
std::cout<<song_path<<std::endl;
|
||||||
sng.SongPath = (char*)song_path;
|
|
||||||
|
|
||||||
return sng;
|
TagLib::FileRef file(song_path);
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
sng.Title = (char*)file.tag()->title().toCString();
|
||||||
|
//sng->Title = (char*)file.tag()->title().toCString();
|
||||||
|
std::cout<<"Title: "<<sng.Title<<std::endl;
|
||||||
|
//std::cout<<"Title: "<<sng->Title<<std::endl;
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
sng.Artist = (char*)file.tag()->artist().toCString();
|
||||||
|
//sng->Artist = (char*)file.tag()->artist().toCString();
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
sng.Album = (char*)file.tag()->album().toCString();
|
||||||
|
//sng->Album = (char*)file.tag()->album().toCString();
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
sng.Genre = (char*)file.tag()->genre().toCString();
|
||||||
|
//sng->Genre = (char*)file.tag()->genre().toCString();
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
sng.Year = file.tag()->year();
|
||||||
|
//sng->Year = file.tag()->year();
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
sng.SongPath = (char*)song_path;
|
||||||
|
//sng->SongPath = (char*)song_path;
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
Song retrieve_metadata(const char*);
|
void retrieve_metadata(Song*, char*);
|
||||||
|
|
||||||
Song retrieve_metadata(const char* song_path)
|
void retrieve_metadata(Song *song, char* song_path)
|
||||||
{
|
{
|
||||||
return fetch_metadata(song_path);
|
std::cout<<"extern C"<<std::endl;
|
||||||
|
//Song sng;
|
||||||
|
Song *sng;
|
||||||
|
//fetch_metadata(sn,song_path);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
TagLib::FileRef file(song_path);
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
//sng.Title = (char*)file.tag()->title().toCString();
|
||||||
|
sng->Title = (char*)file.tag()->title().toCString();
|
||||||
|
//strcpy(sng->Title, file.tag()->title().toCString());
|
||||||
|
//std::cout<<"Title: "<<sng.Title<<std::endl;
|
||||||
|
std::cout<<"Title: "<<sng->Title<<std::endl;
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
//sng.Artist = (char*)file.tag()->artist().toCString();
|
||||||
|
sng->Artist = (char*)file.tag()->artist().toCString();
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
//sng.Album = (char*)file.tag()->album().toCString();
|
||||||
|
sng->Album = (char*)file.tag()->album().toCString();
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
//sng.Genre = (char*)file.tag()->genre().toCString();
|
||||||
|
sng->Genre = (char*)file.tag()->genre().toCString();
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
//sng.Year = file.tag()->year();
|
||||||
|
sng->Year = file.tag()->year();
|
||||||
|
//std::cout<<"0"<<std::endl;
|
||||||
|
//sng.SongPath = (char*)song_path;
|
||||||
|
sng->SongPath = (char*)song_path;
|
||||||
|
//std::cout<<"res"<<std::endl<<sn.Title<<std::endl;
|
||||||
|
//*song = sn;
|
||||||
|
std::cout<<"done"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user