tsk-103: Confirmed functionality is working

This commit is contained in:
phoenix
2025-02-16 17:16:53 -05:00
parent 6bff36bc03
commit 63f3c955a1
28 changed files with 148 additions and 76 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ public class AlbumController : BaseController
[HttpGet("{id}")]
public IActionResult GetAlbum(int id)
{
Album album = new Album{ Id = id };
Album album = new Album { Id = id };
var albumContext = new AlbumContext(_connectionString!);
+1 -1
View File
@@ -49,7 +49,7 @@ public class ArtistController : BaseController
public IActionResult GetArtist(int id)
{
Artist artist = new Artist { Id = id };
var artistContext = new ArtistContext(_connectionString!);
if (artistContext.DoesRecordExist(artist))
+2 -2
View File
@@ -20,7 +20,7 @@ public class BaseController : ControllerBase
const string otherTokenType = "Jwt";
var req = Request;
var auth = req.Headers.Authorization;
var auth = req.Headers.Authorization;
var val = auth.ToString();
if ((val.Contains(tokenType) || val.Contains(otherTokenType)) && val.Split(" ").Count() > 1)
@@ -31,7 +31,7 @@ public class BaseController : ControllerBase
return token;
}
}
#endregion
}
+4 -4
View File
@@ -63,7 +63,7 @@ public class CoverArtController : BaseController
var coverArtBytes = System.IO.File.ReadAllBytes(
coverArt.ImagePath());
return File(coverArtBytes, "application/x-msdownload",
return File(coverArtBytes, "application/x-msdownload",
coverArt.SongTitle);
}
else
@@ -78,14 +78,14 @@ public class CoverArtController : BaseController
{
var songContext = new SongContext(_connectionString!);
var covMgr = new CoverArtManager(this._config!);
var songMetaData = songContext.RetrieveRecord(new Song { Id = id});
var songMetaData = songContext.RetrieveRecord(new Song { Id = id });
var c = covMgr.GetCoverArt(songMetaData);
var filename = DirectoryManager.GenerateDownloadFilename(10, Constants.FileExtensions.JPG_EXTENSION, songMetaData.Title!, randomizeFilename);
var data = await c.GetData();
return File(data, "application/x-msdownload", filename);
}
#endregion
+1 -1
View File
@@ -58,7 +58,7 @@ public class GenreController : BaseController
if (genreStore.DoesRecordExist(genre))
{
genre = genreStore.RetrieveRecord(genre);
genre = genreStore.RetrieveRecord(genre);
return Ok(genre);
}
+1 -1
View File
@@ -44,7 +44,7 @@ public class LoginController : ControllerBase
var context = new UserContext(_connectionString!);
_logger.LogInformation("Starting process of validating credentials");
var message = "Invalid credentials";
var password = user.Password;
@@ -42,11 +42,11 @@ public class SongCompressedDataController : BaseController
var context = new SongContext(_connectionString!);
SongCompression cmp = new SongCompression(_archiveDir!);
Console.WriteLine($"Archive directory root: {_archiveDir}");
Console.WriteLine("Starting process of retrieving comrpessed song");
var sng = context.RetrieveRecord(new Song{ Id = id });
var sng = context.RetrieveRecord(new Song { Id = id });
SongData song = await cmp.RetrieveCompressedSong(sng);
var filename = DirectoryManager.GenerateDownloadFilename(10, Constants.FileExtensions.ZIP_EXTENSION, sng.Title!, randomizeFilename);
+3 -3
View File
@@ -41,7 +41,7 @@ public class SongController : BaseController
{
Console.WriteLine("Attemtping to retrieve songs");
_logger!.LogInformation("Attempting to retrieve songs");
var context = new SongContext(_connectionString!);
var songs = context.Songs!.ToList();
@@ -60,8 +60,8 @@ public class SongController : BaseController
public IActionResult GetSong(int id)
{
var context = new SongContext(_connectionString!);
var song = context.RetrieveRecord(new Song{ Id = id });
var song = context.RetrieveRecord(new Song { Id = id });
Console.WriteLine("Here");
+20 -3
View File
@@ -7,6 +7,8 @@ using Icarus.Database.Contexts;
namespace Icarus.Controllers.V1;
[Route("api/v1/song/data")]
[ApiController]
[Authorize]
@@ -151,10 +153,13 @@ public class SongDataController : BaseController
switch (song.AudioType)
{
case "wav":
// song = _songMgr.SaveSongToFileSystem(up.SongData, up.CoverArtData, song);
// TODO: Make sure the tmp file gets deleted. Check
var _ = _songMgr.DeleteSongFromFileSystem(tmpSong);
return BadRequest("No support for .wav files");
return BadRequest(new UploadSongWithDataResponse
{
Subject = "No longer supported",
Message = "No support for .wav files",
Songs = new List<Song>()
});
case "flac":
song = _songMgr.SaveFlacSongToFileSystem(up.SongData, up.CoverArtData, song);
break;
@@ -209,4 +214,16 @@ public class SongDataController : BaseController
[FromForm(Name = "metadata")]
public string? SongFile { get; set; }
}
public class UploadSongWithDataResponse
{
#region Properties
[Newtonsoft.Json.JsonProperty("message")]
public string Message { get; set; }
[Newtonsoft.Json.JsonProperty("subject")]
public string Subject { get; set; }
[Newtonsoft.Json.JsonProperty("data")]
public List<Song> Songs { get; set; }
#endregion
}
}
@@ -39,7 +39,7 @@ public class SongStreamController : BaseController
var stream = new FileStream(song!.SongPath(), FileMode.Open, FileAccess.Read);
stream.Position = 0;
var filename = song.Filename;
if (string.IsNullOrEmpty(song.Filename))
{
filename = song.GenerateFilename();
@@ -48,7 +48,8 @@ public class SongStreamController : BaseController
_logger!.LogInformation("Starting to stream song...>");
Console.WriteLine("Starting to streamsong...");
return await Task.Run(() => {
return await Task.Run(() =>
{
return File(stream, "application/octet-stream", filename);
});
}