1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2024-12-22 14:32:40 +00:00

fix empty string bug

This commit is contained in:
fiso64 2023-04-19 15:55:20 +02:00
parent 43ae7a2754
commit c503deae6e

View file

@ -440,7 +440,7 @@ class Program
Track[] tmp = new Track[tracks.Count]; Track[] tmp = new Track[tracks.Count];
tracks.CopyTo(tmp); tracks.CopyTo(tmp);
var tracksStart = tmp.ToList(); var tracksStart = tmp.ToList();
createM3u |= m3uOnly; createM3u |= m3uOnly;
List<string> m3uLines = Enumerable.Repeat("", tracksStart.Count).ToList(); List<string> m3uLines = Enumerable.Repeat("", tracksStart.Count).ToList();
@ -1232,7 +1232,10 @@ class Program
public bool NameSatisfies(string fname, string tname) public bool NameSatisfies(string fname, string tname)
{ {
if (string.IsNullOrEmpty(tname))
return false;
tname = tname.Split('-', StringSplitOptions.RemoveEmptyEntries).Last(); tname = tname.Split('-', StringSplitOptions.RemoveEmptyEntries).Last();
foreach (var word in dangerWords) foreach (var word in dangerWords)
{ {
if (fname.Contains(word, StringComparison.OrdinalIgnoreCase) ^ tname.Contains(word, StringComparison.OrdinalIgnoreCase)) if (fname.Contains(word, StringComparison.OrdinalIgnoreCase) ^ tname.Contains(word, StringComparison.OrdinalIgnoreCase))
@ -1410,6 +1413,9 @@ class Program
{ {
string[] ignore = new string[] { " ", "_", "-", ".", "(", ")" }; string[] ignore = new string[] { " ", "_", "-", ".", "(", ")" };
string searchName = track.TrackTitle.Replace(ignore, ""); string searchName = track.TrackTitle.Replace(ignore, "");
if (string.IsNullOrEmpty(searchName))
searchName = track.TrackTitle;
searchName = RemoveInvalidChars(searchName, ""); searchName = RemoveInvalidChars(searchName, "");
var matchingFiles = collection var matchingFiles = collection