* .NET 8 migration

* Fixed bugs with song management

* More cleanup and making some constants

* Updated yml

* Clean up

Removing comments, some cleanup, and moving the startup code into Program.cs

* Removing comments

* Fixed song deletion issue

* Added functionality to delete song directories

* Updated README
This commit was merged in pull request #89.
This commit is contained in:
Kun Deng
2024-06-15 12:17:12 -04:00
committed by GitHub
parent ececcb5ba3
commit 23c50de468
22 changed files with 182 additions and 454 deletions
-6
View File
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
@@ -20,8 +18,4 @@ public class Album
public int SongCount { get; set; }
[JsonProperty("year")]
public int Year { get; set; }
[JsonIgnore]
[NotMapped]
public List<Song> Songs { get; set; }
}
-5
View File
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
@@ -16,7 +14,4 @@ public class Artist
[JsonProperty("song_count")]
[NotMapped]
public int SongCount { get; set; }
[JsonIgnore]
[NotMapped]
public List<Song> Songs { get; set; }
}
+4 -9
View File
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using Newtonsoft.Json;
@@ -17,24 +18,18 @@ public class CoverArt
public string SongTitle { get; set; }
[JsonIgnore]
public string ImagePath { get; set; }
[JsonIgnore]
[NotMapped]
public int SongID { get; set; }
[JsonIgnore]
[NotMapped]
public List<Song> Songs { get; set; }
#endregion
#region Methods
public string GenerateFilename(int flag)
{
const int length = 25;
const string chars = "ABCDEF0123456789";
int length = Constants.DirectoryPaths.FILENAME_LENGTH;
string chars = Constants.DirectoryPaths.FILENAME_CHARACTERS;
var random = new Random();
var filename = new string(Enumerable.Repeat(chars, length).Select(s =>
s[random.Next(s.Length)]).ToArray());
var extension = ".mp3";
var extension = Constants.FileExtensions.JPG_EXTENSION;
return (flag == 0) ? filename : $"{filename}{extension}";
}
-5
View File
@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
@@ -16,7 +14,4 @@ public class Genre
[JsonProperty("song_count")]
[NotMapped]
public int SongCount { get; set; }
[JsonIgnore]
[NotMapped]
public List<Song> Songs { get; set; }
}
+6 -6
View File
@@ -73,20 +73,20 @@ public class Song
public string GenerateFilename(int flag = 0)
{
const int length = 25;
const string chars = "ABCDEF0123456789";
int length = Constants.DirectoryPaths.FILENAME_LENGTH;
string chars = Constants.DirectoryPaths.FILENAME_CHARACTERS;
var random = new Random();
var filename = new string(Enumerable.Repeat(chars, length).Select(s =>
s[random.Next(s.Length)]).ToArray());
var extension = ".mp3";
var extension = Icarus.Constants.FileExtensions.WAV_EXTENSION;
return flag == 0 ? filename : $"{filename}{extension}";
}
public async Task<string> GenerateFilenameAsync(int flag = 0)
{
const int length = 25;
const string chars = "ABCDEF0123456789";
var extension = ".mp3";
int length = Constants.DirectoryPaths.FILENAME_LENGTH;
string chars = Constants.DirectoryPaths.FILENAME_CHARACTERS;
var extension = Icarus.Constants.FileExtensions.WAV_EXTENSION;
var random = new Random();
var filename = await Task.Run(() =>
{