mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-24 23:16:28 +00:00
Added AddToQueue
This commit is contained in:
parent
284d80ff6f
commit
307d69945e
@ -217,3 +217,21 @@ ErrorResponse error = _spotify.SetVolume(50);
|
|||||||
```csharp
|
```csharp
|
||||||
ErrorResponse error = _spotify.SetShuffle(false);
|
ErrorResponse error = _spotify.SetShuffle(false);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## AddToQueue
|
||||||
|
> Add an Item to the User's Playback Queue. BETA.
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
|Name|Description|Example|
|
||||||
|
|--------------|-------------------------|-------------------------|
|
||||||
|
|uri|The uri of the item to add to the queue. Must be a track or an episode uri.| `spotify:track:7zrCVKp6x0AtolOsn2iMif`
|
||||||
|
|[deviceId]| The id of the device this command is targeting. If not supplied, the user's currently active device is the target. | `"XXXX-XXXX-XXXX-XXXX"`
|
||||||
|
|
||||||
|
**Usage**
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
ErrorResponse error = _spotify.AddToQueue("spotify:track:7zrCVKp6x0AtolOsn2iMif");
|
||||||
|
```
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using SpotifyAPI.Web.Enums;
|
|
||||||
using SpotifyAPI.Web.Models;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using SpotifyAPI.Web.Enums;
|
||||||
|
using SpotifyAPI.Web.Models;
|
||||||
|
|
||||||
namespace SpotifyAPI.Web
|
namespace SpotifyAPI.Web
|
||||||
{
|
{
|
||||||
@ -16,9 +16,7 @@ namespace SpotifyAPI.Web
|
|||||||
{
|
{
|
||||||
private readonly SpotifyWebBuilder _builder;
|
private readonly SpotifyWebBuilder _builder;
|
||||||
|
|
||||||
public SpotifyWebAPI() : this(null)
|
public SpotifyWebAPI() : this(null) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpotifyWebAPI(ProxyConfig proxyConfig)
|
public SpotifyWebAPI(ProxyConfig proxyConfig)
|
||||||
{
|
{
|
||||||
@ -62,7 +60,6 @@ namespace SpotifyAPI.Web
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IClient WebClient { get; set; }
|
public IClient WebClient { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies after how many miliseconds should a failed request be retried.
|
/// Specifies after how many miliseconds should a failed request be retried.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -658,8 +655,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse Follow(FollowType followType, List<string> ids)
|
public ErrorResponse Follow(FollowType followType, List<string> ids)
|
||||||
{
|
{
|
||||||
JObject ob = new JObject
|
JObject ob = new JObject
|
||||||
{
|
{ { "ids", new JArray(ids) }
|
||||||
{"ids", new JArray(ids)}
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.Follow(followType), ob.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
|
return UploadData<ErrorResponse>(_builder.Follow(followType), ob.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -674,8 +670,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> FollowAsync(FollowType followType, List<string> ids)
|
public async Task<ErrorResponse> FollowAsync(FollowType followType, List<string> ids)
|
||||||
{
|
{
|
||||||
JObject ob = new JObject
|
JObject ob = new JObject
|
||||||
{
|
{ { "ids", new JArray(ids) }
|
||||||
{"ids", new JArray(ids)}
|
|
||||||
};
|
};
|
||||||
return await UploadDataAsync<ErrorResponse>(_builder.Follow(followType),
|
return await UploadDataAsync<ErrorResponse>(_builder.Follow(followType),
|
||||||
ob.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
ob.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
@ -715,8 +710,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse Unfollow(FollowType followType, List<string> ids)
|
public ErrorResponse Unfollow(FollowType followType, List<string> ids)
|
||||||
{
|
{
|
||||||
JObject ob = new JObject
|
JObject ob = new JObject
|
||||||
{
|
{ { "ids", new JArray(ids) }
|
||||||
{"ids", new JArray(ids)}
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
|
return UploadData<ErrorResponse>(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -731,8 +725,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> UnfollowAsync(FollowType followType, List<string> ids)
|
public async Task<ErrorResponse> UnfollowAsync(FollowType followType, List<string> ids)
|
||||||
{
|
{
|
||||||
JObject ob = new JObject
|
JObject ob = new JObject
|
||||||
{
|
{ { "ids", new JArray(ids) }
|
||||||
{"ids", new JArray(ids)}
|
|
||||||
};
|
};
|
||||||
return await UploadDataAsync<ErrorResponse>(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.Unfollow(followType), ob.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -777,8 +770,6 @@ namespace SpotifyAPI.Web
|
|||||||
return DownloadList<bool>(url);
|
return DownloadList<bool>(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check to see if the current user is following one or more artists or other Spotify users asynchronously.
|
/// Check to see if the current user is following one or more artists or other Spotify users asynchronously.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -835,8 +826,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse FollowPlaylist(string ownerId, string playlistId, bool showPublic = true)
|
public ErrorResponse FollowPlaylist(string ownerId, string playlistId, bool showPublic = true)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "public", showPublic }
|
||||||
{"public", showPublic}
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.FollowPlaylist(playlistId), body.ToString(Formatting.None), "PUT");
|
return UploadData<ErrorResponse>(_builder.FollowPlaylist(playlistId), body.ToString(Formatting.None), "PUT");
|
||||||
}
|
}
|
||||||
@ -857,8 +847,7 @@ namespace SpotifyAPI.Web
|
|||||||
public Task<ErrorResponse> FollowPlaylistAsync(string playlistId, bool showPublic = true)
|
public Task<ErrorResponse> FollowPlaylistAsync(string playlistId, bool showPublic = true)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "public", showPublic }
|
||||||
{"public", showPublic}
|
|
||||||
};
|
};
|
||||||
return UploadDataAsync<ErrorResponse>(_builder.FollowPlaylist(playlistId), body.ToString(Formatting.None), "PUT");
|
return UploadDataAsync<ErrorResponse>(_builder.FollowPlaylist(playlistId), body.ToString(Formatting.None), "PUT");
|
||||||
}
|
}
|
||||||
@ -1510,11 +1499,7 @@ namespace SpotifyAPI.Web
|
|||||||
public FullPlaylist CreatePlaylist(string userId, string playlistName, bool isPublic = true, bool isCollaborative = false, string playlistDescription = "")
|
public FullPlaylist CreatePlaylist(string userId, string playlistName, bool isPublic = true, bool isCollaborative = false, string playlistDescription = "")
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "name", playlistName }, { "public", isPublic }, { "collaborative", isCollaborative }, { "description", playlistDescription }
|
||||||
{"name", playlistName},
|
|
||||||
{"public", isPublic},
|
|
||||||
{"collaborative", isCollaborative},
|
|
||||||
{"description", playlistDescription}
|
|
||||||
};
|
};
|
||||||
return UploadData<FullPlaylist>(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None));
|
return UploadData<FullPlaylist>(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None));
|
||||||
}
|
}
|
||||||
@ -1539,11 +1524,7 @@ namespace SpotifyAPI.Web
|
|||||||
public Task<FullPlaylist> CreatePlaylistAsync(string userId, string playlistName, bool isPublic = true, bool isCollaborative = false, string playlistDescription = "")
|
public Task<FullPlaylist> CreatePlaylistAsync(string userId, string playlistName, bool isPublic = true, bool isCollaborative = false, string playlistDescription = "")
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "name", playlistName }, { "public", isPublic }, { "collaborative", isCollaborative }, { "description", playlistDescription }
|
||||||
{"name", playlistName},
|
|
||||||
{"public", isPublic},
|
|
||||||
{"collaborative", isCollaborative},
|
|
||||||
{"description", playlistDescription}
|
|
||||||
};
|
};
|
||||||
return UploadDataAsync<FullPlaylist>(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None));
|
return UploadDataAsync<FullPlaylist>(_builder.CreatePlaylist(userId, playlistName, isPublic), body.ToString(Formatting.None));
|
||||||
}
|
}
|
||||||
@ -1714,8 +1695,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse ReplacePlaylistTracks(string userId, string playlistId, List<string> uris)
|
public ErrorResponse ReplacePlaylistTracks(string userId, string playlistId, List<string> uris)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "uris", new JArray(uris.Take(100)) }
|
||||||
{"uris", new JArray(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
|
return UploadData<ErrorResponse>(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1731,8 +1711,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse ReplacePlaylistTracks(string playlistId, List<string> uris)
|
public ErrorResponse ReplacePlaylistTracks(string playlistId, List<string> uris)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "uris", new JArray(uris.Take(100)) }
|
||||||
{"uris", new JArray(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
|
return UploadData<ErrorResponse>(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT") ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1750,8 +1729,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> ReplacePlaylistTracksAsync(string userId, string playlistId, List<string> uris)
|
public async Task<ErrorResponse> ReplacePlaylistTracksAsync(string userId, string playlistId, List<string> uris)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "uris", new JArray(uris.Take(100)) }
|
||||||
{"uris", new JArray(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return await UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(userId, playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1767,8 +1745,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> ReplacePlaylistTracksAsync(string playlistId, List<string> uris)
|
public async Task<ErrorResponse> ReplacePlaylistTracksAsync(string playlistId, List<string> uris)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "uris", new JArray(uris.Take(100)) }
|
||||||
{"uris", new JArray(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return await UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.ReplacePlaylistTracks(playlistId), body.ToString(Formatting.None), "PUT").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1788,8 +1765,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse RemovePlaylistTracks(string userId, string playlistId, List<DeleteTrackUri> uris)
|
public ErrorResponse RemovePlaylistTracks(string userId, string playlistId, List<DeleteTrackUri> uris)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "tracks", JArray.FromObject(uris.Take(100)) }
|
||||||
{"tracks", JArray.FromObject(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
|
return UploadData<ErrorResponse>(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1807,8 +1783,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse RemovePlaylistTracks(string playlistId, List<DeleteTrackUri> uris)
|
public ErrorResponse RemovePlaylistTracks(string playlistId, List<DeleteTrackUri> uris)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "tracks", JArray.FromObject(uris.Take(100)) }
|
||||||
{"tracks", JArray.FromObject(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
|
return UploadData<ErrorResponse>(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE") ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1828,8 +1803,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> RemovePlaylistTracksAsync(string userId, string playlistId, List<DeleteTrackUri> uris)
|
public async Task<ErrorResponse> RemovePlaylistTracksAsync(string userId, string playlistId, List<DeleteTrackUri> uris)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "tracks", JArray.FromObject(uris.Take(100)) }
|
||||||
{"tracks", JArray.FromObject(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return await UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(userId, playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1847,8 +1821,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> RemovePlaylistTracksAsync(string playlistId, List<DeleteTrackUri> uris)
|
public async Task<ErrorResponse> RemovePlaylistTracksAsync(string playlistId, List<DeleteTrackUri> uris)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "tracks", JArray.FromObject(uris.Take(100)) }
|
||||||
{"tracks", JArray.FromObject(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return await UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.RemovePlaylistTracks(playlistId, uris), body.ToString(Formatting.None), "DELETE").ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1918,8 +1891,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse AddPlaylistTracks(string userId, string playlistId, List<string> uris, int? position = null)
|
public ErrorResponse AddPlaylistTracks(string userId, string playlistId, List<string> uris, int? position = null)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "uris", JArray.FromObject(uris.Take(100)) }
|
||||||
{"uris", JArray.FromObject(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse();
|
return UploadData<ErrorResponse>(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1935,8 +1907,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse AddPlaylistTracks(string playlistId, List<string> uris, int? position = null)
|
public ErrorResponse AddPlaylistTracks(string playlistId, List<string> uris, int? position = null)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "uris", JArray.FromObject(uris.Take(100)) }
|
||||||
{"uris", JArray.FromObject(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse();
|
return UploadData<ErrorResponse>(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1954,8 +1925,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> AddPlaylistTracksAsync(string userId, string playlistId, List<string> uris, int? position = null)
|
public async Task<ErrorResponse> AddPlaylistTracksAsync(string userId, string playlistId, List<string> uris, int? position = null)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "uris", JArray.FromObject(uris.Take(100)) }
|
||||||
{"uris", JArray.FromObject(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return await UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(userId, playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1971,8 +1941,7 @@ namespace SpotifyAPI.Web
|
|||||||
public async Task<ErrorResponse> AddPlaylistTracksAsync(string playlistId, List<string> uris, int? position = null)
|
public async Task<ErrorResponse> AddPlaylistTracksAsync(string playlistId, List<string> uris, int? position = null)
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "uris", JArray.FromObject(uris.Take(100)) }
|
||||||
{"uris", JArray.FromObject(uris.Take(100))}
|
|
||||||
};
|
};
|
||||||
return await UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false) ?? new ErrorResponse();
|
return await UploadDataAsync<ErrorResponse>(_builder.AddPlaylistTracks(playlistId, uris, position), body.ToString(Formatting.None)).ConfigureAwait(false) ?? new ErrorResponse();
|
||||||
}
|
}
|
||||||
@ -1992,7 +1961,6 @@ namespace SpotifyAPI.Web
|
|||||||
return AddPlaylistTracks(playlistId, new List<string> { uri }, position);
|
return AddPlaylistTracks(playlistId, new List<string> { uri }, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a track to a user’s playlist.
|
/// Add a track to a user’s playlist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -2049,10 +2017,7 @@ namespace SpotifyAPI.Web
|
|||||||
public Snapshot ReorderPlaylist(string userId, string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "")
|
public Snapshot ReorderPlaylist(string userId, string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "")
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "range_start", rangeStart }, { "range_length", rangeLength }, { "insert_before", insertBefore }
|
||||||
{"range_start", rangeStart},
|
|
||||||
{"range_length", rangeLength},
|
|
||||||
{"insert_before", insertBefore}
|
|
||||||
};
|
};
|
||||||
if (!string.IsNullOrEmpty(snapshotId))
|
if (!string.IsNullOrEmpty(snapshotId))
|
||||||
body.Add("snapshot_id", snapshotId);
|
body.Add("snapshot_id", snapshotId);
|
||||||
@ -2072,10 +2037,7 @@ namespace SpotifyAPI.Web
|
|||||||
public Snapshot ReorderPlaylist(string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "")
|
public Snapshot ReorderPlaylist(string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "")
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "range_start", rangeStart }, { "range_length", rangeLength }, { "insert_before", insertBefore }
|
||||||
{"range_start", rangeStart},
|
|
||||||
{"range_length", rangeLength},
|
|
||||||
{"insert_before", insertBefore}
|
|
||||||
};
|
};
|
||||||
if (!string.IsNullOrEmpty(snapshotId))
|
if (!string.IsNullOrEmpty(snapshotId))
|
||||||
body.Add("snapshot_id", snapshotId);
|
body.Add("snapshot_id", snapshotId);
|
||||||
@ -2097,11 +2059,7 @@ namespace SpotifyAPI.Web
|
|||||||
public Task<Snapshot> ReorderPlaylistAsync(string userId, string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "")
|
public Task<Snapshot> ReorderPlaylistAsync(string userId, string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "")
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "range_start", rangeStart }, { "range_length", rangeLength }, { "insert_before", insertBefore }, { "snapshot_id", snapshotId }
|
||||||
{"range_start", rangeStart},
|
|
||||||
{"range_length", rangeLength},
|
|
||||||
{"insert_before", insertBefore},
|
|
||||||
{"snapshot_id", snapshotId}
|
|
||||||
};
|
};
|
||||||
if (!string.IsNullOrEmpty(snapshotId))
|
if (!string.IsNullOrEmpty(snapshotId))
|
||||||
body.Add("snapshot_id", snapshotId);
|
body.Add("snapshot_id", snapshotId);
|
||||||
@ -2121,11 +2079,7 @@ namespace SpotifyAPI.Web
|
|||||||
public Task<Snapshot> ReorderPlaylistAsync(string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "")
|
public Task<Snapshot> ReorderPlaylistAsync(string playlistId, int rangeStart, int insertBefore, int rangeLength = 1, string snapshotId = "")
|
||||||
{
|
{
|
||||||
JObject body = new JObject
|
JObject body = new JObject
|
||||||
{
|
{ { "range_start", rangeStart }, { "range_length", rangeLength }, { "insert_before", insertBefore }, { "snapshot_id", snapshotId }
|
||||||
{"range_start", rangeStart},
|
|
||||||
{"range_length", rangeLength},
|
|
||||||
{"insert_before", insertBefore},
|
|
||||||
{"snapshot_id", snapshotId}
|
|
||||||
};
|
};
|
||||||
if (!string.IsNullOrEmpty(snapshotId))
|
if (!string.IsNullOrEmpty(snapshotId))
|
||||||
body.Add("snapshot_id", snapshotId);
|
body.Add("snapshot_id", snapshotId);
|
||||||
@ -2393,9 +2347,7 @@ namespace SpotifyAPI.Web
|
|||||||
public ErrorResponse TransferPlayback(List<string> deviceIds, bool play = false)
|
public ErrorResponse TransferPlayback(List<string> deviceIds, bool play = false)
|
||||||
{
|
{
|
||||||
JObject ob = new JObject
|
JObject ob = new JObject
|
||||||
{
|
{ { "play", play }, { "device_ids", new JArray(deviceIds) }
|
||||||
{ "play", play },
|
|
||||||
{ "device_ids", new JArray(deviceIds) }
|
|
||||||
};
|
};
|
||||||
return UploadData<ErrorResponse>(_builder.TransferPlayback(), ob.ToString(Formatting.None), "PUT");
|
return UploadData<ErrorResponse>(_builder.TransferPlayback(), ob.ToString(Formatting.None), "PUT");
|
||||||
}
|
}
|
||||||
@ -2413,9 +2365,7 @@ namespace SpotifyAPI.Web
|
|||||||
public Task<ErrorResponse> TransferPlaybackAsync(List<string> deviceIds, bool play = false)
|
public Task<ErrorResponse> TransferPlaybackAsync(List<string> deviceIds, bool play = false)
|
||||||
{
|
{
|
||||||
JObject ob = new JObject
|
JObject ob = new JObject
|
||||||
{
|
{ { "play", play }, { "device_ids", new JArray(deviceIds) }
|
||||||
{ "play", play },
|
|
||||||
{ "device_ids", new JArray(deviceIds) }
|
|
||||||
};
|
};
|
||||||
return UploadDataAsync<ErrorResponse>(_builder.TransferPlayback(), ob.ToString(Formatting.None), "PUT");
|
return UploadDataAsync<ErrorResponse>(_builder.TransferPlayback(), ob.ToString(Formatting.None), "PUT");
|
||||||
}
|
}
|
||||||
@ -2674,6 +2624,28 @@ namespace SpotifyAPI.Web
|
|||||||
return UploadDataAsync<ErrorResponse>(_builder.SetShuffle(shuffle, deviceId), string.Empty, "PUT");
|
return UploadDataAsync<ErrorResponse>(_builder.SetShuffle(shuffle, deviceId), string.Empty, "PUT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an Item to the User's Playback Queue. BETA
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uri">The uri of the item to add to the queue. Must be a track or an episode uri.</param>
|
||||||
|
/// <param name="deviceId">The id of the device this command is targeting. If not supplied, the user’s currently active device is the target.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ErrorResponse AddToQueue(string uri, string deviceId = "")
|
||||||
|
{
|
||||||
|
return UploadData<ErrorResponse>(_builder.AddToQueue(uri, deviceId), string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an Item to the User's Playback Queue. BETA
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uri">The uri of the item to add to the queue. Must be a track or an episode uri.</param>
|
||||||
|
/// <param name="deviceId">The id of the device this command is targeting. If not supplied, the user’s currently active device is the target.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<ErrorResponse> AddToQueueAsync(string uri, string deviceId = "")
|
||||||
|
{
|
||||||
|
return UploadDataAsync<ErrorResponse>(_builder.AddToQueue(uri, deviceId), string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Util
|
#region Util
|
||||||
@ -2826,8 +2798,7 @@ namespace SpotifyAPI.Web
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
Dictionary<string, string> headers = new Dictionary<string, string>
|
Dictionary<string, string> headers = new Dictionary<string, string>
|
||||||
{
|
{ { "Authorization", TokenType + " " + AccessToken },
|
||||||
{ "Authorization", TokenType + " " + AccessToken},
|
|
||||||
{ "Content-Type", "application/json" }
|
{ "Content-Type", "application/json" }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2855,8 +2826,7 @@ namespace SpotifyAPI.Web
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
Dictionary<string, string> headers = new Dictionary<string, string>
|
Dictionary<string, string> headers = new Dictionary<string, string>
|
||||||
{
|
{ { "Authorization", TokenType + " " + AccessToken },
|
||||||
{ "Authorization", TokenType + " " + AccessToken},
|
|
||||||
{ "Content-Type", "application/json" }
|
{ "Content-Type", "application/json" }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2891,7 +2861,6 @@ namespace SpotifyAPI.Web
|
|||||||
|
|
||||||
} while (UseAutoRetry && triesLeft > 0 && lastError != null && RetryErrorCodes.Contains(lastError.Status));
|
} while (UseAutoRetry && triesLeft > 0 && lastError != null && RetryErrorCodes.Contains(lastError.Status));
|
||||||
|
|
||||||
|
|
||||||
return response.Item2;
|
return response.Item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2943,11 +2912,10 @@ namespace SpotifyAPI.Web
|
|||||||
triesLeft -= 1;
|
triesLeft -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (UseAutoRetry
|
} while (UseAutoRetry &&
|
||||||
&& triesLeft > 0
|
triesLeft > 0 &&
|
||||||
&& (GetTooManyRequests(response.Item1) != -1
|
(GetTooManyRequests(response.Item1) != -1 ||
|
||||||
|| lastError != null && RetryErrorCodes.Contains(lastError.Status)));
|
lastError != null && RetryErrorCodes.Contains(lastError.Status)));
|
||||||
|
|
||||||
|
|
||||||
return response.Item2;
|
return response.Item2;
|
||||||
}
|
}
|
||||||
|
@ -81,9 +81,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetSeveralAlbums(List<string> ids, string market = "")
|
public string GetSeveralAlbums(List<string> ids, string market = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(market)
|
return string.IsNullOrEmpty(market) ?
|
||||||
? $"{APIBase}/albums?ids={string.Join(",", ids.Take(20))}"
|
$"{APIBase}/albums?ids={string.Join(",", ids.Take(20))}" :
|
||||||
: $"{APIBase}/albums?market={market}&ids={string.Join(",", ids.Take(20))}";
|
$"{APIBase}/albums?market={market}&ids={string.Join(",", ids.Take(20))}";
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Albums
|
#endregion Albums
|
||||||
@ -820,9 +820,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <remarks>AUTH NEEDED</remarks>
|
/// <remarks>AUTH NEEDED</remarks>
|
||||||
public string AddPlaylistTracks(string userId, string playlistId, List<string> uris, int? position = null)
|
public string AddPlaylistTracks(string userId, string playlistId, List<string> uris, int? position = null)
|
||||||
{
|
{
|
||||||
return position == null
|
return position == null ?
|
||||||
? $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks"
|
$"{APIBase}/users/{userId}/playlists/{playlistId}/tracks" :
|
||||||
: $"{APIBase}/users/{userId}/playlists/{playlistId}/tracks?position={position}";
|
$"{APIBase}/users/{userId}/playlists/{playlistId}/tracks?position={position}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -835,9 +835,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <remarks>AUTH NEEDED</remarks>
|
/// <remarks>AUTH NEEDED</remarks>
|
||||||
public string AddPlaylistTracks(string playlistId, List<string> uris, int? position = null)
|
public string AddPlaylistTracks(string playlistId, List<string> uris, int? position = null)
|
||||||
{
|
{
|
||||||
return position == null
|
return position == null ?
|
||||||
? $"{APIBase}/playlists/{playlistId}/tracks"
|
$"{APIBase}/playlists/{playlistId}/tracks" :
|
||||||
: $"{APIBase}/playlists/{playlistId}/tracks?position={position}";
|
$"{APIBase}/playlists/{playlistId}/tracks?position={position}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -922,9 +922,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetSeveralTracks(List<string> ids, string market = "")
|
public string GetSeveralTracks(List<string> ids, string market = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(market)
|
return string.IsNullOrEmpty(market) ?
|
||||||
? $"{APIBase}/tracks?ids={string.Join(",", ids.Take(50))}"
|
$"{APIBase}/tracks?ids={string.Join(",", ids.Take(50))}" :
|
||||||
: $"{APIBase}/tracks?market={market}&ids={string.Join(",", ids.Take(50))}";
|
$"{APIBase}/tracks?market={market}&ids={string.Join(",", ids.Take(50))}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1001,9 +1001,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetPlayingTrack(string market = "")
|
public string GetPlayingTrack(string market = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(market)
|
return string.IsNullOrEmpty(market) ?
|
||||||
? $"{APIBase}/me/player/currently-playing"
|
$"{APIBase}/me/player/currently-playing" :
|
||||||
: $"{APIBase}/me/player/currently-playing?market={market}";
|
$"{APIBase}/me/player/currently-playing?market={market}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1022,9 +1022,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string ResumePlayback(string deviceId = "")
|
public string ResumePlayback(string deviceId = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(deviceId)
|
return string.IsNullOrEmpty(deviceId) ?
|
||||||
? $"{APIBase}/me/player/play"
|
$"{APIBase}/me/player/play" :
|
||||||
: $"{APIBase}/me/player/play?device_id={deviceId}";
|
$"{APIBase}/me/player/play?device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1034,9 +1034,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string PausePlayback(string deviceId = "")
|
public string PausePlayback(string deviceId = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(deviceId)
|
return string.IsNullOrEmpty(deviceId) ?
|
||||||
? $"{APIBase}/me/player/pause"
|
$"{APIBase}/me/player/pause" :
|
||||||
: $"{APIBase}/me/player/pause?device_id={deviceId}";
|
$"{APIBase}/me/player/pause?device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1046,9 +1046,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SkipPlaybackToNext(string deviceId = "")
|
public string SkipPlaybackToNext(string deviceId = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(deviceId)
|
return string.IsNullOrEmpty(deviceId) ?
|
||||||
? $"{APIBase}/me/player/next"
|
$"{APIBase}/me/player/next" :
|
||||||
: $"{APIBase}/me/player/next?device_id={deviceId}";
|
$"{APIBase}/me/player/next?device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1060,9 +1060,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SkipPlaybackToPrevious(string deviceId = "")
|
public string SkipPlaybackToPrevious(string deviceId = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(deviceId)
|
return string.IsNullOrEmpty(deviceId) ?
|
||||||
? $"{APIBase}/me/player/previous"
|
$"{APIBase}/me/player/previous" :
|
||||||
: $"{APIBase}/me/player/previous?device_id={deviceId}";
|
$"{APIBase}/me/player/previous?device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1074,9 +1074,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SeekPlayback(int positionMs, string deviceId = "")
|
public string SeekPlayback(int positionMs, string deviceId = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(deviceId)
|
return string.IsNullOrEmpty(deviceId) ?
|
||||||
? $"{APIBase}/me/player/seek?position_ms={positionMs}"
|
$"{APIBase}/me/player/seek?position_ms={positionMs}" :
|
||||||
: $"{APIBase}/me/player/seek?position_ms={positionMs}&device_id={deviceId}";
|
$"{APIBase}/me/player/seek?position_ms={positionMs}&device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1087,9 +1087,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SetRepeatMode(RepeatState repeatState, string deviceId = "")
|
public string SetRepeatMode(RepeatState repeatState, string deviceId = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(deviceId)
|
return string.IsNullOrEmpty(deviceId) ?
|
||||||
? $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}"
|
$"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}" :
|
||||||
: $"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}&device_id={deviceId}";
|
$"{APIBase}/me/player/repeat?state={repeatState.GetStringAttribute()}&device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1100,9 +1100,9 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SetVolume(int volumePercent, string deviceId = "")
|
public string SetVolume(int volumePercent, string deviceId = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(deviceId)
|
return string.IsNullOrEmpty(deviceId) ?
|
||||||
? $"{APIBase}/me/player/volume?volume_percent={volumePercent}"
|
$"{APIBase}/me/player/volume?volume_percent={volumePercent}" :
|
||||||
: $"{APIBase}/me/player/volume?volume_percent={volumePercent}&device_id={deviceId}";
|
$"{APIBase}/me/player/volume?volume_percent={volumePercent}&device_id={deviceId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1113,9 +1113,22 @@ namespace SpotifyAPI.Web
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string SetShuffle(bool shuffle, string deviceId = "")
|
public string SetShuffle(bool shuffle, string deviceId = "")
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(deviceId)
|
return string.IsNullOrEmpty(deviceId) ?
|
||||||
? $"{APIBase}/me/player/shuffle?state={shuffle}"
|
$"{APIBase}/me/player/shuffle?state={shuffle}" :
|
||||||
: $"{APIBase}/me/player/shuffle?state={shuffle}&device_id={deviceId}";
|
$"{APIBase}/me/player/shuffle?state={shuffle}&device_id={deviceId}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an Item to the User's Playback Queue.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uri">The uri of the item to add to the queue. Must be a track or an episode uri.</param>
|
||||||
|
/// <param name="deviceId">The id of the device this command is targeting. If not supplied, the user’s currently active device is the target.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string AddToQueue(string uri, string deviceId = "")
|
||||||
|
{
|
||||||
|
return string.IsNullOrEmpty(deviceId) ?
|
||||||
|
$"{APIBase}/me/player/queue?uri={uri}" :
|
||||||
|
$"{APIBase}/me/player/queue?uri={uri}&device_id={deviceId}";
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user