#103: Remove WAV support (#105)

* #103: Adding checks to prevent .wav files from being uploaded:

* #103: Added method to create song and moving some code around

* #103: Fixed build issue

* tsk-103: Cleanup of temporary files

* tsk-103: Formatting changes

* tsk-103: Minor changes

* tsk-103: Fixing build issue

* tsk-103: Refactored enum

* CORE-23734: Refactoring

* tsk-103: Confirmed functionality is working

* Removed commented code

* Removed commented code
This commit was merged in pull request #105.
This commit is contained in:
KD
2025-02-16 17:24:50 -05:00
committed by GitHub
parent a89580ac70
commit fd3ce9f96a
33 changed files with 242 additions and 99 deletions
@@ -9,8 +9,8 @@ public class MetadataRetriever
{
#region Fields
private static NLog.Logger? _logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
private List<string>? _supportedAudioFileTypes = new List<string> {"wav", "flac"};
private List<string>? _supportedImageFileTypes = new List<string> {"jpeg", "jpg", "png"};
private List<string>? _supportedAudioFileTypes = new List<string> { "wav", "flac" };
private List<string>? _supportedImageFileTypes = new List<string> { "jpeg", "jpg", "png" };
private Song? _updatedSong;
private string? _message;
private string? _title;
@@ -99,7 +99,7 @@ public class MetadataRetriever
public bool IsSupportedFile(IFormFile file)
{
var supportedTypes = this._supportedAudioFileTypes;
this._supportedImageFileTypes!.ForEach(t =>
this._supportedImageFileTypes!.ForEach(t =>
{
if (!supportedTypes!.Contains(t))
{
@@ -115,7 +115,7 @@ public class MetadataRetriever
public bool IsSupportedFile(string path)
{
var supportedTypes = this._supportedAudioFileTypes;
this._supportedImageFileTypes!.ForEach(t =>
this._supportedImageFileTypes!.ForEach(t =>
{
if (!supportedTypes!.Contains(t))
{
@@ -199,7 +199,7 @@ public class MetadataRetriever
return [];
}
public void UpdateMetadata(Song updatedSong, Song oldSong)
{
try
@@ -267,7 +267,7 @@ public class MetadataRetriever
break;
case "artists":
_updatedSong!.Artist = artist;
fileTag.Tag.Performers = new []{artist};
fileTag.Tag.Performers = new[] { artist };
break;
case "album":
_updatedSong!.AlbumTitle = album;
@@ -275,7 +275,7 @@ public class MetadataRetriever
break;
case "genre":
_updatedSong!.Genre = genre;
fileTag.Tag.Genres = new []{genre};
fileTag.Tag.Genres = new[] { genre };
break;
case "year":
_updatedSong!.Year = year;
@@ -283,7 +283,7 @@ public class MetadataRetriever
break;
case "albumartist":
_updatedSong!.AlbumArtist = albumArtist;
fileTag.Tag.AlbumArtists = new []{albumArtist};
fileTag.Tag.AlbumArtists = new[] { albumArtist };
break;
case "track":
_updatedSong!.Track = track;
@@ -352,7 +352,7 @@ public class MetadataRetriever
}
return songValues;
}
}
private bool CheckIntField(int? value)
{
@@ -70,14 +70,14 @@ public class PasswordEncryption
password: password, salt: salt,
prf: KeyDerivationPrf.HMACSHA1,
iterationCount: 10000,
numBytesRequested: 256/8));
numBytesRequested: 256 / 8));
return hashed;
}
byte[] GenerateSalt()
{
byte[] salt = new byte[128/8];
byte[] salt = new byte[128 / 8];
using (var rng = RandomNumberGenerator.Create())
rng.GetBytes(salt);
@@ -43,10 +43,10 @@ public class SongCompression
{
var archivePath = RetrieveCompressesSongPath(song);
Console.WriteLine($"Compressed song saved to: {archivePath}");
songData.Data = await System.IO.File.ReadAllBytesAsync(archivePath);
}
catch(Exception ex)
catch (Exception ex)
{
var exMsg = ex.Message;
Console.WriteLine($"An error ocurred: \n{exMsg}");