Implemented Cover Art functionality #50 #52

This commit is contained in:
amazing-username
2019-07-16 20:44:53 -04:00
parent 84615472ef
commit 8ec7092272
2 changed files with 11 additions and 6 deletions
+10 -5
View File
@@ -53,13 +53,17 @@ namespace Icarus.Controllers.Managers
{ {
try try
{ {
var stockCoverArtPath = _rootCoverArtPath + "/CoverArt.png"; var stockCoverArtPath = _rootCoverArtPath + "CoverArt.png";
if (!string.Equals(stockCoverArtPath, coverArt.ImagePath, if (!string.Equals(stockCoverArtPath, coverArt.ImagePath,
StringComparison.CurrentCultureIgnoreCase)) StringComparison.CurrentCultureIgnoreCase))
{ {
_logger.Info("Song does not contain the stock cover art"); _logger.Info("Song does not contain the stock cover art");
File.Delete(coverArt.ImagePath); File.Delete(coverArt.ImagePath);
_logger.Info("Cover art deleted from the database"); _logger.Info("Cover art deleted from the filesystem");
}
else
{
_logger.Info("Song contains the stock cover art");
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -89,7 +93,8 @@ namespace Icarus.Controllers.Managers
File.WriteAllBytes(coverArt.ImagePath, imgBytes); File.WriteAllBytes(coverArt.ImagePath, imgBytes);
else else
{ {
Console.WriteLine("Song has no cover art"); Console.WriteLine("Song has no cover art, applying stock cover art");
_logger.Info("Song has no cover art, applying stock cover art");
coverArt.ImagePath = _rootCoverArtPath + "CoverArt.png"; coverArt.ImagePath = _rootCoverArtPath + "CoverArt.png";
metaData.UpdateCoverArt(song, coverArt); metaData.UpdateCoverArt(song, coverArt);
File.WriteAllBytes(coverArt.ImagePath, _stockCoverArt); File.WriteAllBytes(coverArt.ImagePath, _stockCoverArt);
@@ -112,9 +117,9 @@ namespace Icarus.Controllers.Managers
if (System.IO.File.Exists(DirectoryPaths.CoverArtPath)) if (System.IO.File.Exists(DirectoryPaths.CoverArtPath))
_stockCoverArt = File.ReadAllBytes(DirectoryPaths.CoverArtPath); _stockCoverArt = File.ReadAllBytes(DirectoryPaths.CoverArtPath);
if (!File.Exists(_rootCoverArtPath + "/CoverArt.png")) if (!File.Exists(_rootCoverArtPath + "CoverArt.png"))
{ {
File.WriteAllBytes(_rootCoverArtPath + "/CoverArt.png", File.WriteAllBytes(_rootCoverArtPath + "CoverArt.png",
_stockCoverArt); _stockCoverArt);
Console.WriteLine("Copied Stock Cover Art"); Console.WriteLine("Copied Stock Cover Art");
} }
+1 -1
View File
@@ -154,7 +154,7 @@ namespace Icarus.Database.Repositories
{ {
conn.Open(); conn.Open();
var query = "DELETE CoverArt WHERE " + var query = "DELETE FROM CoverArt WHERE " +
"CoverArtId=@CoverArtId"; "CoverArtId=@CoverArtId";
using (var cmd = new MySqlCommand(query, conn)) using (var cmd = new MySqlCommand(query, conn))
{ {