1
0
Fork 0
mirror of https://github.com/fiso64/slsk-batchdl.git synced 2024-12-22 22:42:41 +00:00
slsk-batchdl/README.md

280 lines
18 KiB
Markdown
Raw Permalink Normal View History

2023-03-24 23:42:01 +00:00
# slsk-batchdl
2024-05-25 19:47:43 +00:00
A batch downloader for Soulseek built with Soulseek.NET. Accepts CSV files and Spotify or YouTube urls.
2023-03-24 23:42:01 +00:00
2024-04-27 19:46:35 +00:00
## Examples
2024-05-05 19:39:18 +00:00
Download tracks from a csv file:
2023-03-24 23:42:01 +00:00
```
2024-05-23 19:24:51 +00:00
sldl test.csv
2024-05-17 18:58:36 +00:00
```
<details>
<summary>CSV details</summary>
2024-05-05 19:39:18 +00:00
The names of the columns in the csv should be: `Artist`, `Title`, `Album`, `Length`. Some alternatives are also accepted. You can use `--print tracks` before downloading to check if everything has been parsed correctly. Only the title or album column is required, but additional info may improve search results.
2024-05-17 18:58:36 +00:00
</details>
2024-05-05 19:39:18 +00:00
<br>
Download spotify likes while skipping songs that already exist in the output folder:
2023-06-12 15:04:49 +00:00
```
2024-05-23 19:24:51 +00:00
sldl spotify-likes --skip-existing
2023-06-12 15:04:49 +00:00
```
2024-05-17 18:58:36 +00:00
<details>
<summary>Spotify details</summary>
2023-11-15 21:45:51 +00:00
To download private playlists or liked songs you will need to provide a client id and secret, which you can get here https://developer.spotify.com/dashboard/applications. Create an app and add `http://localhost:48721/callback` as a redirect url in its settings.
2024-05-05 19:39:18 +00:00
2024-05-17 18:58:36 +00:00
</details>
2024-05-05 19:39:18 +00:00
<br>
Download from a youtube playlist with fallback to yt-dlp in case it is not found on soulseek, and retrieve deleted video titles from wayback machine:
2023-06-12 15:04:49 +00:00
```
2024-05-25 10:12:27 +00:00
sldl "https://www.youtube.com/playlist?list=PLI_eFW8NAFzYAXZ5DrU6E6mQ_XfhaLBUX" --get-deleted --yt-dlp
2023-06-12 15:04:49 +00:00
```
2024-05-17 18:58:36 +00:00
<details>
<summary>YouTube details</summary>
2024-05-05 19:39:18 +00:00
Playlists are retrieved using the YoutubeExplode library which unfortunately doesn't always return all videos. You can use the official API by providing a key with `--youtube-key`. Get it here https://console.cloud.google.com. Create a new project, click "Enable Api" and search for "youtube data", then follow the prompts.
2024-06-09 13:27:28 +00:00
Also note that due the high number of music videos in the above example playlist, it may be better to remove all text in parentheses and disable song duration checking: `--regex "[\[\(].*?[\]\)]" --pref-length-tol -1`.
2023-06-12 15:04:49 +00:00
2024-05-17 18:58:36 +00:00
</details>
2024-05-05 19:39:18 +00:00
<br>
Search & download a specific song, preferring lossless:
2023-06-12 15:04:49 +00:00
```
2024-05-23 19:24:51 +00:00
sldl "title=MC MENTAL @ HIS BEST,length=242" --pref-format "flac,wav"
2023-10-08 20:41:44 +00:00
```
2024-05-23 19:24:51 +00:00
<details>
<summary>String details</summary>
The shorthand `sldl "Artist - Title"` is equivalent to `sldl "artist=Artist,title=Title"`.
</details>
2024-03-12 22:50:22 +00:00
2024-05-05 19:39:18 +00:00
<br>
Interactive album download:
2024-03-12 22:50:22 +00:00
```
2024-05-23 19:24:51 +00:00
sldl "album=Some Album" --interactive
```
<details>
<summary>Album details</summary>
The shorthand `sldl "Artist - Album" -a` is equivalent to `sldl "artist=Artist,album=Album"`. It's often helpful to restrict to folders which have two or more tracks: `--atc 2+`.
</details>
2023-10-08 20:41:44 +00:00
2024-05-05 19:39:18 +00:00
<br>
Print all songs by an artist which are not in your library:
2023-10-08 20:41:44 +00:00
```
2024-05-23 19:24:51 +00:00
sldl "artist=MC MENTAL" --aggregate --skip-existing --music-dir "path/to/music" --print tracks-full
2023-06-12 15:04:49 +00:00
```
2024-05-04 23:01:26 +00:00
## Download Modes
Depending on the provided input, the download behaviour changes:
2024-05-23 19:24:51 +00:00
- Normal download: The program will download a single file for every input entry.
2024-05-25 08:14:35 +00:00
- Album download: The program will search for the album and download an entire folder including non-audio files. Activated when the input is a link to a spotify or bandcamp album, when the input string or csv row has no track title, or when `-a`/`--album` is enabled.
2024-05-23 19:24:51 +00:00
- Aggregate download: With `-g`/`--aggregate`, the program will first perform an ordinary search for the input, then attempt to group the results into distinct songs and download one of each kind. This can be used to download an artist's entire discography (or simply printing it, like in the example above), finding remixes of a song, etc. Note that it is not 100% reliable, which is why `--min-users-aggregate` is set to 2 by default, i.e. any song that is shared by only one person will be ignored. Enable `--relax-filtering` to make the file filtering less aggressive.
2024-05-04 23:01:26 +00:00
2024-04-27 19:46:35 +00:00
## Options
2024-05-23 19:24:51 +00:00
Acronyms of two- and --three-word-arguments are also accepted, e.g. --twa
2023-06-12 15:04:49 +00:00
```
2024-05-23 19:24:51 +00:00
Usage: sldl <input> [OPTIONS]
2023-10-08 20:41:44 +00:00
2023-11-28 13:31:42 +00:00
<input> <input> is one of the following:
2023-10-08 20:41:44 +00:00
2024-03-12 22:50:22 +00:00
Spotify playlist url or 'spotify-likes': Download a spotify
2023-10-08 20:41:44 +00:00
playlist or your liked songs. --spotify-id and
--spotify-secret may be required in addition.
Youtube playlist url: Download songs from a youtube playlist.
Provide a --youtube-key to include unavailabe uploads.
Path to a local CSV file: Use a csv file containing track
info to download. The names of the columns should be Artist,
2024-05-04 22:38:47 +00:00
Title, Album, Length. Only the title or album column is
required, but extra info may improve search results.
2023-10-08 20:41:44 +00:00
2023-11-15 21:45:51 +00:00
Name of the track, album, or artist to search for:
Can either be any typical search string or a comma-separated
2024-03-12 22:50:22 +00:00
list like 'title=Song Name,artist=Artist Name,length=215'
2023-11-15 21:45:51 +00:00
Allowed properties are: title, artist, album, length (sec)
2024-03-12 22:50:22 +00:00
Specify artist and album only to download an album.
2023-10-08 20:41:44 +00:00
2023-03-24 23:42:01 +00:00
Options:
2023-06-12 15:04:49 +00:00
--user <username> Soulseek username
--pass <password> Soulseek password
2024-05-23 19:24:51 +00:00
-p --path <path> Download directory
2024-03-12 22:50:22 +00:00
-f --folder <name> Subfolder name. Set to '.' to output directly to the
download folder (default: playlist/csv name)
-n --number <maxtracks> Download the first n tracks of a playlist
-o --offset <offset> Skip a specified number of tracks
-r --reverse Download tracks in reverse order
2024-05-23 19:24:51 +00:00
--name-format <format> Name format for downloaded tracks, e.g "{artist} - {title}"
--fast-search Begin downloading as soon as a file satisfying the preferred
2024-06-04 12:12:56 +00:00
conditions is found. Higher chance to download wrong files.
2024-06-20 17:48:50 +00:00
--remove-from-source Remove downloaded tracks from source playlist or CSV file
(spotify and CSV only)
2024-03-12 22:50:22 +00:00
--m3u <option> Create an m3u8 playlist file
'none': Do not create a playlist file
'fails' (default): Write only failed downloads to the m3u
'all': Write successes + fails as comments
2023-11-15 21:45:51 +00:00
--spotify-id <id> spotify client ID
--spotify-secret <secret> spotify client secret
2023-10-08 20:41:44 +00:00
--youtube-key <key> Youtube data API key
2023-11-15 21:45:51 +00:00
--get-deleted Attempt to retrieve titles of deleted videos from wayback
machine. Requires yt-dlp.
2024-05-28 12:02:03 +00:00
--deleted-only Only retrieve & download deleted music. Combine with --print
tracks-full to display a list of all deleted titles & urls.
2023-10-08 20:41:44 +00:00
--time-format <format> Time format in Length column of the csv file (e.g h:m:s.ms
2023-11-15 21:45:51 +00:00
for durations like 1:04:35.123). Default: s
2023-10-08 20:41:44 +00:00
--yt-parse Enable if the csv file contains YouTube video titles and
2023-11-15 21:45:51 +00:00
channel names; attempt to parse them into title and artist
names.
2023-10-08 20:41:44 +00:00
--format <format> Accepted file format(s), comma-separated
2024-06-04 22:21:59 +00:00
--length-tol <sec> Length tolerance in seconds
2023-10-08 20:41:44 +00:00
--min-bitrate <rate> Minimum file bitrate
--max-bitrate <rate> Maximum file bitrate
2024-05-04 22:25:31 +00:00
--min-samplerate <rate> Minimum file sample rate
2023-10-08 20:41:44 +00:00
--max-samplerate <rate> Maximum file sample rate
2024-05-04 22:25:31 +00:00
--min-bitdepth <depth> Minimum bit depth
--max-bitdepth <depth> Maximum bit depth
2023-10-08 20:41:44 +00:00
--banned-users <list> Comma-separated list of users to ignore
2023-11-30 12:17:11 +00:00
2023-06-12 15:04:49 +00:00
--pref-format <format> Preferred file format(s), comma-separated (default: mp3)
2024-06-04 22:21:59 +00:00
--pref-length-tol <sec> Preferred length tolerance in seconds (default: 3)
2023-06-12 15:04:49 +00:00
--pref-min-bitrate <rate> Preferred minimum bitrate (default: 200)
2024-05-26 19:02:56 +00:00
--pref-max-bitrate <rate> Preferred maximum bitrate (default: 2500)
2024-05-04 22:25:31 +00:00
--pref-min-samplerate <rate> Preferred minimum sample rate
2024-05-25 19:47:43 +00:00
--pref-max-samplerate <rate> Preferred maximum sample rate (default: 48000)
2024-05-04 22:25:31 +00:00
--pref-min-bitdepth <depth> Preferred minimum bit depth
--pref-max-bitdepth <depth> Preferred maximum bit depth
2023-10-08 20:41:44 +00:00
--pref-banned-users <list> Comma-separated list of users to deprioritize
2024-05-05 19:39:18 +00:00
2024-05-23 19:24:51 +00:00
--strict-conditions Skip files with missing properties instead of accepting by
2024-04-27 19:46:35 +00:00
default; if --min-bitrate is set, ignores any files with
unknown bitrate.
2023-03-26 15:35:41 +00:00
2024-05-23 19:24:51 +00:00
-a --album Album download mode
-t --interactive When downloading albums: Allows to select the wanted album
2024-03-12 22:50:22 +00:00
--album-track-count <num> Specify the exact number of tracks in the album. Folders
with a different number of tracks will be ignored. Append
2024-04-27 19:46:35 +00:00
a '+' or '-' after the number for the inequalities >= and <=
2024-03-12 22:50:22 +00:00
--album-ignore-fails When downloading an album and one of the files fails, do not
skip to the next source and do not delete all successfully
downloaded files
2024-05-23 19:24:51 +00:00
--album-art <option> Retrieve additional images after downloading the album:
2024-03-12 22:50:22 +00:00
'largest': Download from the folder with the largest image
'most': Download from the folder containing the most images
2024-05-23 19:24:51 +00:00
--album-art-only Only download album art for the provided album
-g --aggregate Instead of downloading a single track matching the input,
find and download all distinct songs associated with the
provided artist, album, or track title.
--min-users-aggregate <num> Minimum number of users sharing a track before it is
downloaded in aggregate mode. Setting it to higher values
will significantly reduce false positives, but also cause it
to ignore rarer songs. Default: 2
--relax-filtering Slightly relax file filtering in aggregate mode to include
more results
2024-03-12 22:50:22 +00:00
2023-10-09 09:29:00 +00:00
-s --skip-existing Skip if a track matching file conditions is found in the
2023-06-12 15:04:49 +00:00
output folder or your music library (if provided)
2024-03-12 22:50:22 +00:00
--skip-mode <mode> 'name': Use only filenames to check if a track exists
'name-precise' (default): Use filenames and check conditions
'tag': Use file tags (slower)
'tag-precise': Use file tags and check file conditions
2024-05-23 19:24:51 +00:00
--music-dir <path> Specify to also skip downloading tracks found in a music
library. Use with --skip-existing
2023-06-12 15:04:49 +00:00
--skip-not-found Skip searching for tracks that weren't found on Soulseek
2024-03-12 22:50:22 +00:00
during the last run. Fails are read from the m3u file.
--no-remove-special-chars Do not remove special characters before searching
--remove-ft Remove 'feat.' and everything after before searching
--remove-brackets Remove square brackets and their contents before searching
--regex <regex> Remove a regexp from all track titles and artist names.
Optionally specify the replacement regex after a semicolon
--artist-maybe-wrong Performs an additional search without the artist name.
Useful for sources like SoundCloud where the "artist"
could just be an uploader. Note that when downloading a
YouTube playlist via url, this option is set automatically
2024-05-23 19:24:51 +00:00
on a per-track basis, so it is best kept off in that case.
2024-03-12 22:50:22 +00:00
-d --desperate Tries harder to find the desired track by searching for the
2024-05-05 19:39:18 +00:00
artist/album/title only, then filtering. (slower search)
2023-06-12 15:04:49 +00:00
--yt-dlp Use yt-dlp to download tracks that weren't found on
Soulseek. yt-dlp must be available from the command line.
2024-05-23 19:24:51 +00:00
--yt-dlp-argument <str> The command line arguments when running yt-dlp. Default:
"{id}" -f bestaudio/best -cix -o "{savepath}.%(ext)s"
Available vars are: {id}, {savedir}, {savepath} (w/o ext).
Note that with -x, yt-dlp will download webms in case
ffmpeg is unavailable.
2023-03-24 23:42:01 +00:00
2024-05-23 19:24:51 +00:00
-c --config <path> Set config file location
2024-03-12 22:50:22 +00:00
--search-timeout <ms> Max search time in ms (default: 5000)
2023-10-08 20:41:44 +00:00
--max-stale-time <ms> Max download time without progress in ms (default: 50000)
2023-11-28 13:31:42 +00:00
--concurrent-downloads <num> Max concurrent downloads (default: 2)
--searches-per-time <num> Max searches per time interval. Higher values may cause
30-minute bans. (default: 34)
2024-03-12 22:50:22 +00:00
--searches-renew-time <sec> Controls how often available searches are replenished.
2023-11-28 13:31:42 +00:00
Lower values may cause 30-minute bans. (default: 220)
2024-05-23 19:24:51 +00:00
--display-mode <option> Changes how searches and downloads are displayed:
2024-04-08 19:59:04 +00:00
'single' (default): Show transfer state and percentage
'double': Transfer state and a large progress bar
'simple': No download bars or changing percentages
2023-12-20 17:23:15 +00:00
--listen-port <port> Port for incoming connections (default: 50000)
2023-06-12 15:04:49 +00:00
2023-11-15 21:45:51 +00:00
--print <option> Print tracks or search results instead of downloading:
2024-03-12 22:50:22 +00:00
'tracks': Print all tracks to be downloaded
'tracks-full': Print extended information about all tracks
'results': Print search results satisfying file conditions
'results-full': Print search results including full paths
2024-04-08 19:59:04 +00:00
--debug Print extra debug info
```
2024-05-23 19:24:51 +00:00
2024-05-05 19:39:18 +00:00
### File conditions
2024-06-04 22:21:59 +00:00
Files not satisfying the conditions will not be downloaded. Files satisfying `pref-` conditions will be preferred; setting `--pref-format "flac,wav"` will make it download high quality files if they exist, and only download low quality files if there's nothing else. Conditions can also be supplied as a semicolon-delimited string to `--cond` and `--pref`, e.g `--cond "br>=320;f=mp3,ogg;sr<96000"`. See the start of `Program.cs` for the default file conditions.
2024-05-17 18:58:36 +00:00
2024-05-23 19:24:51 +00:00
**Important note**: Some info may be unavailable depending on the client used by the peer. For example, the default Soulseek client does not share the file bitrate. By default, if `--min-bitrate` is set, then files with unknown bitrate will still be downloaded. You can configure it to reject all files where one of the checked properties is unavailable by enabling `--strict-conditions`. (As a consequence, if `--min-bitrate` is also set then any files shared by users with the default client will be ignored)
2024-03-12 22:50:22 +00:00
2024-05-05 19:39:18 +00:00
### Name format
2024-05-31 10:26:55 +00:00
Variables enclosed in {} will be replaced by the corresponding file tag value. Available variables are: artist, sartist, artists, albumartist, albumartists, title, stitle, album, salbum, year, track, disc, filename, foldername. The variables sartist, stitle and salbum will be replaced by the source artist, title and album respectively (i.e what is shown in spotify/youtube/csv file) instead of the tag values of the downloaded file. Name format supports subdirectories as well as conditional expressions like `{tag1|tag2}` If tag1 is null, choose tag2. String literals enclosed in parentheses are ignored in the null check. Examples:
- `{artist} - {title}`: Always name it 'Artist - Title'. Because some files on Soulseek do not have tags, the second example is preferred:
- `{artist( - )title|filename}`: If artist and title is not null, name it 'Artist - Title', otherwise use the original filename.
2024-05-05 19:39:18 +00:00
2024-05-28 07:15:58 +00:00
### Quality vs Speed
2024-05-05 19:39:18 +00:00
The following options will make it go faster, but may decrease search result quality or cause instability:
- `--fast-search` skips waiting until the search completes and downloads as soon as a matching file is found
- `--concurrent-downloads` - set it to 4 or more
- `--max-stale-time` is set to 50 seconds by default, so it will wait a long time before giving up on a file
- `--searches-per-time` increase at the risk of ban, see the notes section for details.
2024-03-12 22:50:22 +00:00
2024-05-28 07:15:58 +00:00
### Quality vs Quantity
2024-06-09 13:27:28 +00:00
The options `--strict-title`, `--strict-artist` and `--strict-album` will filter any file that does not contain the title/artist/album in the filename (ignoring case, bounded by boundary chars). Another way to prevent false downloads is to set `--length-tol` to 3 or less to make it ignore any songs that differ from the input by more than 3 seconds. However, all 4 options are already enabled as 'preferred' conditions by default, meaning that such files will only be downloaded as a last resort even without enabling these. Hence it is only recommended to enable them if you need to minimize false downloads as much as possible.
2024-05-28 07:15:58 +00:00
2024-05-04 22:25:31 +00:00
## Configuration
2024-05-23 19:24:51 +00:00
Create a file named `sldl.conf` in the same directory as the executable and write your arguments there, e.g:
2024-06-09 13:27:28 +00:00
```
username = fakename
password = fakepass
pref-format = flac
fast-search = true
2023-05-25 19:55:02 +00:00
```
2024-04-27 19:46:35 +00:00
## Notes
2024-05-26 19:02:56 +00:00
- For macOS builds you can use publish.sh to build the app. Download dotnet from https://dotnet.microsoft.com/en-us/download/dotnet/6.0, then run `chmod +x publish.sh && sh publish.sh`. For intel macs, uncomment the x64 and comment the arm64 section in publish.sh.
2023-10-08 20:41:44 +00:00
- `--display single` and especially `double` can cause the printed lines to be duplicated or overwritten on some configurations. Use `simple` if that's an issue.
2024-05-07 12:40:46 +00:00
- The server will ban you for 30 minutes if too many searches are performed within a short timespan. The program has a search limiter which can be adjusted with `--searches-per-time` and `--searches-renew-time` (when limit is reached, the status of the downloads will be "Waiting"). By default it is configured to allow up to 34 searches every 220 seconds. These values were determined through experimentation as unfortunately I couldn't find any information regarding soulseek's rate limits, so they may be incorrect.