1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2025-01-08 06:22:43 +00:00

improve track str parser

This commit is contained in:
fiso64 2024-12-24 12:18:59 +01:00
parent 7c428f84d5
commit 55571f4156
4 changed files with 17 additions and 12 deletions

View file

@ -1088,7 +1088,7 @@ public class Config
case "--pref-strict-title":
setNullableFlag(ref preferredCond.StrictTitle, ref i);
break;
case "--psa":
case "--psar":
case "--pref-strict-artist":
setNullableFlag(ref preferredCond.StrictArtist, ref i);
break;
@ -1142,7 +1142,7 @@ public class Config
case "--strict-title":
setNullableFlag(ref necessaryCond.StrictTitle, ref i);
break;
case "--sa":
case "--sar":
case "--strict-artist":
setNullableFlag(ref necessaryCond.StrictArtist, ref i);
break;

View file

@ -131,11 +131,17 @@ namespace Extractors
setProperty(currentKey, currentVal.Trim());
other = other.Trim();
if (other.Length > 0)
if (other.Length > 0 && (isAlbum && track.Album.Length > 0 || !isAlbum && track.Title.Length > 0))
{
Printing.WriteLine($"Warning: Input part '{other}' provided without a property name " +
$"and album or title is already set. Ignoring.", ConsoleColor.DarkYellow);
}
else if (other.Length > 0)
{
string artist = "", album = "", title = "";
parts = other.Split(" - ", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 1 || parts.Length > 3)
parts = other.Split(" - ", 2, StringSplitOptions.TrimEntries);
if (parts.Length == 1 || track.Artist.Length > 0)
{
if (isAlbum)
album = other.Trim();
@ -151,12 +157,6 @@ namespace Extractors
else
title = parts[1];
}
else if (parts.Length == 3)
{
artist = parts[0];
album = parts[1];
title = parts[2];
}
if (track.Artist.Length == 0)
track.Artist = artist;

View file

@ -1372,6 +1372,7 @@ static partial class Program
.Replace("{uri}", track.URI)
.Replace("{length}", track.Length.ToString())
.Replace("{row}", (track.CsvOrListRow == -1 ? -1 : track.CsvOrListRow + 1).ToString())
.Replace("{line}", (track.CsvOrListRow == -1 ? -1 : track.CsvOrListRow + 1).ToString())
.Replace("{artist-maybe-wrong}", track.ArtistMaybeWrong.ToString())
.Replace("{type}", track.Type.ToString())
.Replace("{is-not-audio}", track.IsNotAudio.ToString())

View file

@ -94,6 +94,8 @@ public static class Printing
Console.WriteLine($" Title: {tracks[i].Title}");
if (!string.IsNullOrEmpty(tracks[i].Album) || tracks[i].Type == TrackType.Album)
Console.WriteLine($" Album: {tracks[i].Album}");
if (tracks[i].MinAlbumTrackCount != -1 || tracks[i].MaxAlbumTrackCount != -1)
Console.WriteLine($" Min,Max tracks: {tracks[i].MinAlbumTrackCount},{tracks[i].MaxAlbumTrackCount}");
if (tracks[i].Length > -1 || tracks[i].Type == TrackType.Normal)
Console.WriteLine($" Length: {tracks[i].Length}s");
if (!string.IsNullOrEmpty(tracks[i].DownloadPath))
@ -132,7 +134,9 @@ public static class Printing
}
Console.WriteLine();
}
Console.WriteLine();
if (i < number - 1)
Console.WriteLine();
}
}