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

update help and readme

This commit is contained in:
fiso64 2024-08-30 16:39:04 +02:00
parent 2952b89042
commit ff7762cdce
3 changed files with 56 additions and 50 deletions

View file

@ -125,10 +125,10 @@ Usage: sldl <input> [OPTIONS]
``` ```
``` ```
Spotify Spotify
--spotify-id <id> spotify client ID --spotify-id <id> Spotify client ID
--spotify-secret <secret> spotify client secret --spotify-secret <secret> Spotify client secret
--spotify-token <token> spotify access token --spotify-token <token> Spotify access token
--spotify-refresh <token> spotify refresh token --spotify-refresh <token> Spotify refresh token
--remove-from-source Remove downloaded tracks from source playlist --remove-from-source Remove downloaded tracks from source playlist
``` ```
``` ```
@ -247,24 +247,28 @@ Tip: For playlists containing music videos, it may be better to remove all text
A playlist/album url or 'spotify-likes': Download a spotify playlist, album, or your A playlist/album url or 'spotify-likes': Download a spotify playlist, album, or your
liked songs. Credentials are required when downloading a private playlist or liked music. liked songs. Credentials are required when downloading a private playlist or liked music.
#### Using Credential/Application #### Using Credentials
Create a [Spotify application](https://developer.spotify.com/dashboard/applications) with a redirect url of `http://localhost:48721/callback`. Obtain an application **ID** and **Secret** from the created application dashboard. <details>
<summary>Click to expand</summary>
Create a Spotify application at https://developer.spotify.com/dashboard/applications with a redirect url http://localhost:48721/callback. Obtain an application ID and secret from the created application dashboard.
Start sldl with the obtained credentials and an authorized action to trigger the Spotify app login flow: Start sldl with the obtained credentials and an authorized action to trigger the Spotify app login flow:
```shell
sldl spotify-likes --number 1 --spotify-id 123456 --spotify-secret 123456 ...
``` ```
sldl will try to open a browser automatically but will fallback to logging the login flow URL to output. After login flow is complete sldl will output a **Token** and **Refresh Token** and finish running the current command. sldl spotify-likes --spotify-id 123456 --spotify-secret 123456 -n 1 --print-tracks
```
sldl will try to open a browser automatically but will fallback to logging the login flow URL to output. After login flow is complete sldl will output a token and refresh token and finish running the current command.
To skip requiring login flow every time `sldl` is used the **Token** and **Refresh Token** can be provided to sldl (hint: use `--config` and store this info in the config file to make commands less verbose): To skip requiring login flow every time sldl is used the token and refresh token can be provided to sldl (hint: store this info in the config file to make commands less verbose):
```shell ```
sldl spotify-likes --number 1 --spotify-id 123456 --spotify-secret 123456 --spotify-refresh 123456 --spotify-token 123456 ... sldl spotify-likes --spotify-id 123456 --spotify-secret 123456 --spotify-refresh 123456 --spotify-token 123456 -n 1 --pt
``` ```
`spotify-token` access is only valid for 1 hour. `spotify-refresh` will enable sldl to renew access every time it is run (and can be used without including `spotify-token`) spotify-token access is only valid for 1 hour. spotify-refresh will enable sldl to renew access every time it is run (and can be used without including spotify-token)
</details>
### Bandcamp ### Bandcamp
A bandcamp url: Download a single track, an album, or an artist's entire discography. A bandcamp url: Download a single track, an album, or an artist's entire discography.

View file

@ -29,22 +29,10 @@ namespace Extractors
bool needLogin = Config.input == "spotify-likes" || Config.removeTracksFromSource; bool needLogin = Config.input == "spotify-likes" || Config.removeTracksFromSource;
var tle = new TrackListEntry(); var tle = new TrackListEntry();
static void readSpotifyCreds()
{
Console.Write("Spotify client ID:");
Config.spotifyId = Console.ReadLine();
Console.Write("Spotify client secret:");
Config.spotifySecret = Console.ReadLine();
Console.Write("Spotify token:");
Config.spotifyToken = Console.ReadLine();
Console.Write("Spotify refresh token:");
Config.spotifyRefresh = Console.ReadLine();
Console.WriteLine();
}
if (needLogin && Config.spotifyToken.Length == 0 && (Config.spotifyId.Length == 0 || Config.spotifySecret.Length == 0)) if (needLogin && Config.spotifyToken.Length == 0 && (Config.spotifyId.Length == 0 || Config.spotifySecret.Length == 0))
{ {
readSpotifyCreds(); Console.WriteLine("Error: Credentials are required when downloading liked music or removing from source playlists.");
Environment.Exit(0);
} }
spotifyClient = new Spotify(Config.spotifyId, Config.spotifySecret, Config.spotifyToken, Config.spotifyRefresh); spotifyClient = new Spotify(Config.spotifyId, Config.spotifySecret, Config.spotifyToken, Config.spotifyRefresh);
@ -73,7 +61,8 @@ namespace Extractors
else if (Config.input.Contains("/artist/")) else if (Config.input.Contains("/artist/"))
{ {
Console.WriteLine("Loading spotify artist"); Console.WriteLine("Loading spotify artist");
throw new NotImplementedException("Spotify artist download currently not supported."); Console.WriteLine("Error: Spotify artist download currently not supported.");
Environment.Exit(0);
} }
else else
{ {
@ -93,19 +82,8 @@ namespace Extractors
} }
else if (!needLogin) else if (!needLogin)
{ {
Console.WriteLine("Spotify playlist not found. It may be set to private. Login? [Y/n]"); Console.WriteLine("Spotify playlist not found (it may be set to private, but no credentials have been provided).");
if (Console.ReadLine()?.ToLower().Trim() == "y") Environment.Exit(0);
{
readSpotifyCreds();
spotifyClient = new Spotify(Config.spotifyId, Config.spotifySecret);
await spotifyClient.Authorize(true, Config.removeTracksFromSource);
Console.WriteLine("Loading Spotify playlist");
(playlistName, playlistUri, tracks) = await spotifyClient.GetPlaylist(Config.input, max, off);
}
else
{
Environment.Exit(0);
}
} }
else throw; else throw;
} }
@ -242,11 +220,11 @@ namespace Extractors
if (_clientRefreshToken.Length != 0) if (_clientRefreshToken.Length != 0)
{ {
Console.WriteLine("Trying to renew access with refresh token..."); Console.WriteLine("Trying to renew access with refresh token...");
// var refreshRequest = new TokenSwapRefreshRequest( // var refreshRequest = new TokenSwapRefreshRequest(
// new Uri("http://localhost:48721/refresh"), // new Uri("http://localhost:48721/refresh"),
// _clientRefreshToken // _clientRefreshToken
// ); // );
var refreshRequest = new AuthorizationCodeRefreshRequest(_clientId, _clientSecret, _clientRefreshToken); var refreshRequest = new AuthorizationCodeRefreshRequest(_clientId, _clientSecret, _clientRefreshToken);
try try
{ {
var oauthClient = new OAuthClient(); var oauthClient = new OAuthClient();
@ -279,9 +257,11 @@ namespace Extractors
) )
); );
Console.WriteLine("Spotify token: " + tokenResponse.AccessToken); Console.WriteLine("spotify-token=" + tokenResponse.AccessToken);
_clientToken = tokenResponse.AccessToken; _clientToken = tokenResponse.AccessToken;
Console.WriteLine("Spotify refresh token: " + tokenResponse.RefreshToken); Console.WriteLine();
Console.WriteLine("spotify-refresh=" + tokenResponse.RefreshToken);
Console.WriteLine();
_clientRefreshToken = tokenResponse.RefreshToken; _clientRefreshToken = tokenResponse.RefreshToken;
_client = new SpotifyClient(tokenResponse.AccessToken); _client = new SpotifyClient(tokenResponse.AccessToken);

View file

@ -102,8 +102,10 @@ public static class Help
See --help ""search"". (default: 220) See --help ""search"". (default: 220)
Spotify Spotify
--spotify-id <id> spotify client ID --spotify-id <id> Spotify client ID
--spotify-secret <secret> spotify client secret --spotify-secret <secret> Spotify client secret
--spotify-token <token> Spotify access token
--spotify-refresh <token> Spotify refresh token
--remove-from-source Remove downloaded tracks from source playlist --remove-from-source Remove downloaded tracks from source playlist
YouTube YouTube
@ -219,6 +221,26 @@ public static class Help
The id and secret can be obtained at https://developer.spotify.com/dashboard/applications. The id and secret can be obtained at https://developer.spotify.com/dashboard/applications.
Create an app and add http://localhost:48721/callback as a redirect url in its settings. Create an app and add http://localhost:48721/callback as a redirect url in its settings.
Using Credentials
Create a Spotify application at https://developer.spotify.com/dashboard/applications with a
redirect url http://localhost:48721/callback. Obtain an application ID and secret from the
created application dashboard.
Start sldl with the obtained credentials and an authorized action to trigger the Spotify
app login flow:
sldl spotify-likes --spotify-id 123456 --spotify-secret 123456 -n 1 --print-tracks
sldl will try to open a browser automatically but will fallback to logging the login flow
URL to output. After login flow is complete sldl will output a token and refresh token and
finish running the current command.
To skip requiring login flow every time sldl is used the token and refresh token can be
provided to sldl (hint: store this info in the config file to make commands less verbose):
sldl spotify-likes --spotify-id 123456 --spotify-secret 123456 --spotify-refresh 123456 --spotify-token 123456 -n 1 --pt
spotify-token access is only valid for 1 hour. spotify-refresh will enable sldl to renew
access every time it is run (and can be used without including spotify-token).
Bandcamp Bandcamp
A bandcamp url: Download a single track, an album, or an artist's entire discography. A bandcamp url: Download a single track, an album, or an artist's entire discography.
Extracts the artist name, album name and sets --album-track-count=""n+"", where n is the Extracts the artist name, album name and sets --album-track-count=""n+"", where n is the