mirror of
https://github.com/fiso64/slsk-batchdl.git
synced 2024-12-22 06:22:41 +00:00
fix album art download bug
This commit is contained in:
parent
4886744a67
commit
1828e3ff40
5 changed files with 29 additions and 11 deletions
|
@ -164,6 +164,9 @@ Usage: sldl <input> [OPTIONS]
|
|||
--max-samplerate <rate> Maximum file sample rate
|
||||
--min-bitdepth <depth> Minimum bit depth
|
||||
--max-bitdepth <depth> Maximum bit depth
|
||||
--strict-title File name must contain title
|
||||
--strict-artist File path must contain artist name
|
||||
--strict-album File path must contain album name
|
||||
--banned-users <list> Comma-separated list of users to ignore
|
||||
|
||||
--pref-format <formats> Preferred file format(s), comma-separated (default: mp3)
|
||||
|
|
|
@ -14,6 +14,7 @@ public class FileManager
|
|||
readonly TrackListEntry tle;
|
||||
readonly HashSet<Track> organized = new();
|
||||
public string? remoteCommonDir { get; private set; }
|
||||
public string? defaultFolderName { get; private set; }
|
||||
|
||||
public FileManager(TrackListEntry tle)
|
||||
{
|
||||
|
@ -37,9 +38,10 @@ public class FileManager
|
|||
|
||||
if (tle.source.Type == TrackType.Album && !string.IsNullOrEmpty(remoteCommonDir))
|
||||
{
|
||||
string dirname = Path.GetFileName(remoteCommonDir);
|
||||
string relpath = Path.GetRelativePath(remoteCommonDir, Utils.NormalizedPath(sourceFname));
|
||||
parent = Path.Join(parent, dirname, Path.GetDirectoryName(relpath));
|
||||
string dirname = defaultFolderName != null ? defaultFolderName : Path.GetFileName(remoteCommonDir);
|
||||
string normFname = Utils.NormalizedPath(sourceFname);
|
||||
string relpath = normFname.StartsWith(remoteCommonDir) ? Path.GetRelativePath(remoteCommonDir, normFname) : "";
|
||||
parent = Path.Join(parent, dirname, Path.GetDirectoryName(relpath) ?? "");
|
||||
}
|
||||
|
||||
return Path.Join(parent, name);
|
||||
|
@ -50,6 +52,11 @@ public class FileManager
|
|||
this.remoteCommonDir = remoteCommonDir != null ? Utils.NormalizedPath(remoteCommonDir) : null;
|
||||
}
|
||||
|
||||
public void SetDefaultFolderName(string? defaultFolderName)
|
||||
{
|
||||
this.defaultFolderName = defaultFolderName != null ? Utils.NormalizedPath(defaultFolderName) : null;
|
||||
}
|
||||
|
||||
public void OrganizeAlbum(List<Track> tracks, List<Track>? additionalImages, bool remainingOnly = true)
|
||||
{
|
||||
foreach (var track in tracks.Where(t => !t.IsNotAudio))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
// undocumented options
|
||||
// --login, --random-login, --no-modify-share-count, --unknown-error-retries
|
||||
// --invalid-replace-str, --cond, --pref, --strict-title, --strict-artist, --strict-album
|
||||
// --invalid-replace-str, --cond, --pref
|
||||
// --fast-search-delay, --fast-search-min-up-speed
|
||||
// --min-album-track-count, --max-album-track-count, --extract-max-track-count, --extract-min-track-count
|
||||
|
||||
|
@ -136,6 +136,9 @@ public static class Help
|
|||
--max-samplerate <rate> Maximum file sample rate
|
||||
--min-bitdepth <depth> Minimum bit depth
|
||||
--max-bitdepth <depth> Maximum bit depth
|
||||
--strict-title File name must contain title
|
||||
--strict-artist File path must contain artist name
|
||||
--strict-album File path must contain album name
|
||||
--banned-users <list> Comma-separated list of users to ignore
|
||||
|
||||
--pref-format <formats> Preferred file format(s), comma-separated (default: mp3)
|
||||
|
|
|
@ -540,7 +540,7 @@ static partial class Program
|
|||
if (Config.I.albumArtOnly || succeeded && Config.I.albumArtOption != AlbumArtOption.Default)
|
||||
{
|
||||
Console.WriteLine($"\nDownloading additional images:");
|
||||
additionalImages = await DownloadImages(tle.list, Config.I.albumArtOption, tracks, organizer);
|
||||
additionalImages = await DownloadImages(tle, tle.list, Config.I.albumArtOption, tracks);
|
||||
tracks?.AddRange(additionalImages);
|
||||
}
|
||||
|
||||
|
@ -616,12 +616,20 @@ static partial class Program
|
|||
}
|
||||
|
||||
|
||||
static async Task<List<Track>> DownloadImages(List<List<Track>> downloads, AlbumArtOption option, List<Track>? chosenAlbum, FileManager fileManager)
|
||||
static async Task<List<Track>> DownloadImages(TrackListEntry tle, List<List<Track>> downloads, AlbumArtOption option, List<Track>? chosenAlbum)
|
||||
{
|
||||
var downloadedImages = new List<Track>();
|
||||
long mSize = 0;
|
||||
int mCount = 0;
|
||||
|
||||
var fileManager = new FileManager(tle);
|
||||
|
||||
if (chosenAlbum != null)
|
||||
{
|
||||
string dir = Utils.GreatestCommonDirectorySlsk(chosenAlbum.Select(t => t.FirstDownload.Filename));
|
||||
fileManager.SetDefaultFolderName(Path.GetFileName(Utils.NormalizedPath(dir)));
|
||||
}
|
||||
|
||||
if (option == AlbumArtOption.Default)
|
||||
return downloadedImages;
|
||||
|
||||
|
@ -710,10 +718,7 @@ static partial class Program
|
|||
PrintAlbum(tracks);
|
||||
}
|
||||
|
||||
if (fileManager.remoteCommonDir == null)
|
||||
{
|
||||
fileManager.SetRemoteCommonDir(Utils.GreatestCommonDirectorySlsk(tracks.Select(t => t.FirstDownload.Filename)));
|
||||
}
|
||||
|
||||
bool allSucceeded = true;
|
||||
var semaphore = new SemaphoreSlim(1);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<PackageReference Include="SpotifyAPI.Web" Version="7.1.1" />
|
||||
<PackageReference Include="SpotifyAPI.Web.Auth" Version="7.1.1" />
|
||||
<PackageReference Include="TagLibSharp" Version="2.3.0" />
|
||||
<PackageReference Include="YoutubeExplode" Version="6.4.0" />
|
||||
<PackageReference Include="YoutubeExplode" Version="6.4.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue