1
0
Fork 0
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:
fiso64 2024-09-28 14:42:21 +02:00
parent 4886744a67
commit 8a912dc55b
5 changed files with 15 additions and 10 deletions

View file

@ -164,6 +164,9 @@ Usage: sldl <input> [OPTIONS]
--max-samplerate <rate> Maximum file sample rate --max-samplerate <rate> Maximum file sample rate
--min-bitdepth <depth> Minimum bit depth --min-bitdepth <depth> Minimum bit depth
--max-bitdepth <depth> Maximum 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 --banned-users <list> Comma-separated list of users to ignore
--pref-format <formats> Preferred file format(s), comma-separated (default: mp3) --pref-format <formats> Preferred file format(s), comma-separated (default: mp3)

View file

@ -38,8 +38,9 @@ public class FileManager
if (tle.source.Type == TrackType.Album && !string.IsNullOrEmpty(remoteCommonDir)) if (tle.source.Type == TrackType.Album && !string.IsNullOrEmpty(remoteCommonDir))
{ {
string dirname = Path.GetFileName(remoteCommonDir); string dirname = Path.GetFileName(remoteCommonDir);
string relpath = Path.GetRelativePath(remoteCommonDir, Utils.NormalizedPath(sourceFname)); string normFname = Utils.NormalizedPath(sourceFname);
parent = Path.Join(parent, dirname, Path.GetDirectoryName(relpath)); string relpath = normFname.StartsWith(remoteCommonDir) ? Path.GetRelativePath(remoteCommonDir, normFname) : "";
parent = Path.Join(parent, dirname, Path.GetDirectoryName(relpath) ?? "");
} }
return Path.Join(parent, name); return Path.Join(parent, name);

View file

@ -1,7 +1,7 @@
 
// undocumented options // undocumented options
// --login, --random-login, --no-modify-share-count, --unknown-error-retries // --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 // --fast-search-delay, --fast-search-min-up-speed
// --min-album-track-count, --max-album-track-count, --extract-max-track-count, --extract-min-track-count // --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 --max-samplerate <rate> Maximum file sample rate
--min-bitdepth <depth> Minimum bit depth --min-bitdepth <depth> Minimum bit depth
--max-bitdepth <depth> Maximum 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 --banned-users <list> Comma-separated list of users to ignore
--pref-format <formats> Preferred file format(s), comma-separated (default: mp3) --pref-format <formats> Preferred file format(s), comma-separated (default: mp3)

View file

@ -540,7 +540,7 @@ static partial class Program
if (Config.I.albumArtOnly || succeeded && Config.I.albumArtOption != AlbumArtOption.Default) if (Config.I.albumArtOnly || succeeded && Config.I.albumArtOption != AlbumArtOption.Default)
{ {
Console.WriteLine($"\nDownloading additional images:"); 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); tracks?.AddRange(additionalImages);
} }
@ -616,8 +616,9 @@ 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 fileManager = new FileManager(tle);
var downloadedImages = new List<Track>(); var downloadedImages = new List<Track>();
long mSize = 0; long mSize = 0;
int mCount = 0; int mCount = 0;
@ -710,10 +711,7 @@ static partial class Program
PrintAlbum(tracks); PrintAlbum(tracks);
} }
if (fileManager.remoteCommonDir == null) fileManager.SetRemoteCommonDir(Utils.GreatestCommonDirectorySlsk(tracks.Select(t => t.FirstDownload.Filename)));
{
fileManager.SetRemoteCommonDir(Utils.GreatestCommonDirectorySlsk(tracks.Select(t => t.FirstDownload.Filename)));
}
bool allSucceeded = true; bool allSucceeded = true;
var semaphore = new SemaphoreSlim(1); var semaphore = new SemaphoreSlim(1);

View file

@ -27,7 +27,7 @@
<PackageReference Include="SpotifyAPI.Web" Version="7.1.1" /> <PackageReference Include="SpotifyAPI.Web" Version="7.1.1" />
<PackageReference Include="SpotifyAPI.Web.Auth" Version="7.1.1" /> <PackageReference Include="SpotifyAPI.Web.Auth" Version="7.1.1" />
<PackageReference Include="TagLibSharp" Version="2.3.0" /> <PackageReference Include="TagLibSharp" Version="2.3.0" />
<PackageReference Include="YoutubeExplode" Version="6.4.0" /> <PackageReference Include="YoutubeExplode" Version="6.4.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>