-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement extended playlist information type
- Loading branch information
1 parent
8e2f473
commit 119e1f4
Showing
3 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/Lavalink4NET.Integrations.Lavasrc/ExtendedPlaylistInformation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
namespace Lavalink4NET.Integrations.Lavasrc; | ||
|
||
using System.Collections.Immutable; | ||
using System.Text.Json.Nodes; | ||
using Lavalink4NET.Rest.Entities.Tracks; | ||
|
||
public readonly record struct ExtendedPlaylistInformation(PlaylistInformation Playlist) | ||
{ | ||
public string Name => Playlist.Name; | ||
|
||
public ExtendedLavalinkTrack? SelectedTrack | ||
{ | ||
get | ||
{ | ||
return Playlist.SelectedTrack is null | ||
? null | ||
: new ExtendedLavalinkTrack(Playlist.SelectedTrack); | ||
} | ||
} | ||
|
||
public IImmutableDictionary<string, JsonNode> AdditionalInformation => Playlist.AdditionalInformation; | ||
|
||
public PlaylistType? Type | ||
{ | ||
get | ||
{ | ||
var playlistType = AdditionalInformation["type"]?.ToString(); | ||
|
||
return playlistType switch | ||
{ | ||
"album" => PlaylistType.Album, | ||
"playlist" => PlaylistType.Playlist, | ||
"artist" => PlaylistType.Artist, | ||
"recommendations" => PlaylistType.Recommendations, | ||
_ => null | ||
}; | ||
} | ||
} | ||
|
||
public Uri? Uri | ||
{ | ||
get | ||
{ | ||
var uri = AdditionalInformation["url"]?.ToString(); | ||
return uri is null ? null : new Uri(uri); | ||
} | ||
} | ||
|
||
public Uri? ArtworkUri | ||
{ | ||
get | ||
{ | ||
var artworkUri = AdditionalInformation["artworkUrl"]?.ToString(); | ||
return artworkUri is null ? null : new Uri(artworkUri); | ||
} | ||
} | ||
|
||
public string? Author => AdditionalInformation["author"]?.ToString(); | ||
|
||
public int? TotalTracks => AdditionalInformation["totalTracks"]?.GetValue<int>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Lavalink4NET.Integrations.Lavasrc; | ||
|
||
public enum PlaylistType : byte | ||
{ | ||
Album, | ||
Playlist, | ||
Artist, | ||
Recommendations, | ||
} |