Simplify song-image detection
Store comment as 1 string
This commit is contained in:
1 parent
2ec094e734
commit
a9b3e1d3f8
3 files changed
+18
-12
No files matched your search
@@ -54,7 +54,7 @@ namespace VocaluxeLib
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static List<int> GetSetBits(this int value)
|
||||
public static IEnumerable<int> GetSetBits(this int value)
|
||||
{
|
||||
var result = new List<int>();
|
||||
int curBit = 0;
|
||||
@@ -68,5 +68,10 @@ namespace VocaluxeLib
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool ContainsIgnoreCase(this string value, string other)
|
||||
{
|
||||
return value.IndexOf(other, StringComparison.CurrentCultureIgnoreCase) >= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ namespace VocaluxeLib.Songs
|
||||
public float Gap;
|
||||
public float VideoGap;
|
||||
|
||||
private readonly List<string> _Comment = new List<string>();
|
||||
private string _Comment = "";
|
||||
|
||||
// Sorting
|
||||
public int ID;
|
||||
@@ -208,7 +208,7 @@ namespace VocaluxeLib.Songs
|
||||
Gap = song.Gap;
|
||||
VideoGap = song.VideoGap;
|
||||
|
||||
_Comment = new List<string>(song._Comment);
|
||||
_Comment = song._Comment;
|
||||
|
||||
ID = song.ID;
|
||||
_Visible = song._Visible;
|
||||
@@ -271,11 +271,12 @@ namespace VocaluxeLib.Songs
|
||||
if (CoverFileName == "")
|
||||
{
|
||||
List<string> files = CHelper.ListFiles(Folder, "*.jpg");
|
||||
files.AddRange(CHelper.ListFiles(Folder, "*.jpeg"));
|
||||
files.AddRange(CHelper.ListFiles(Folder, "*.png"));
|
||||
foreach (String file in files)
|
||||
{
|
||||
if (Regex.IsMatch(file, @".[CO].", RegexOptions.IgnoreCase) &&
|
||||
(Regex.IsMatch(file, @"" + Regex.Escape(Title), RegexOptions.IgnoreCase) || Regex.IsMatch(file, @"" + Regex.Escape(Artist), RegexOptions.IgnoreCase)))
|
||||
if (file.ContainsIgnoreCase("[CO]") &&
|
||||
(file.ContainsIgnoreCase(Title) || file.ContainsIgnoreCase(Artist)))
|
||||
CoverFileName = file;
|
||||
}
|
||||
}
|
||||
@@ -283,11 +284,12 @@ namespace VocaluxeLib.Songs
|
||||
if (BackgroundFileName == "")
|
||||
{
|
||||
List<string> files = CHelper.ListFiles(Folder, "*.jpg");
|
||||
files.AddRange(CHelper.ListFiles(Folder, "*.jpeg"));
|
||||
files.AddRange(CHelper.ListFiles(Folder, "*.png"));
|
||||
foreach (String file in files)
|
||||
{
|
||||
if (Regex.IsMatch(file, @".[BG].", RegexOptions.IgnoreCase) &&
|
||||
(Regex.IsMatch(file, @"" + Regex.Escape(Title), RegexOptions.IgnoreCase) || Regex.IsMatch(file, @"" + Regex.Escape(Artist), RegexOptions.IgnoreCase)))
|
||||
if (file.ContainsIgnoreCase("[BG]") &&
|
||||
(file.ContainsIgnoreCase(Title) || file.ContainsIgnoreCase(Artist)))
|
||||
BackgroundFileName = file;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
_Song.Languages.Clear();
|
||||
_Song.Genres.Clear();
|
||||
_Song._Comment.Clear();
|
||||
_Song._Comment = "";
|
||||
|
||||
var headerFlags = new EHeaderFlags();
|
||||
StreamReader sr = null;
|
||||
@@ -196,10 +196,9 @@ namespace VocaluxeLib.Songs
|
||||
_LogWarning("Invalid language");
|
||||
break;
|
||||
case "COMMENT":
|
||||
if (value.Length > 1)
|
||||
_Song._Comment.Add(value);
|
||||
else
|
||||
_LogWarning("Invalid comment");
|
||||
if (!String.IsNullOrEmpty(_Song._Comment))
|
||||
_Song._Comment += "\r\n";
|
||||
_Song._Comment += value;
|
||||
break;
|
||||
case "GAP":
|
||||
if (CHelper.TryParse(value, out _Song.Gap))
|
||||
|
||||
Reference in new issue
Block a user