From 2c245acaadbf933901b532572eaddec706c40100 Mon Sep 17 00:00:00 2001 From: Difegue Date: Sun, 3 Oct 2021 18:02:00 +0200 Subject: [PATCH 1/7] Setup action workflow --- Sources/MpcNET/MpcNET.csproj | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sources/MpcNET/MpcNET.csproj b/Sources/MpcNET/MpcNET.csproj index 1d64adf..4116083 100644 --- a/Sources/MpcNET/MpcNET.csproj +++ b/Sources/MpcNET/MpcNET.csproj @@ -13,6 +13,17 @@ 0.0.1.0 0.0.1.0 Debug;Release;Release-Stable + TVC-16 + Difegue + Pure .NET Client Library for Music Player Daemon Servers. + 2021 Difegue + https://github.com/Difegue/MpcNET + icon.png + README.md + https://github.com/Difegue/MpcNET + mpd;client;mpcNET + D:\Projects\LibMpcNETNuGet\LICENSE + True @@ -43,10 +54,23 @@ + + + True + + + + + + + True + + + From 61b6e33b7919d30473619c8d576f53f2d2a68a71 Mon Sep 17 00:00:00 2001 From: Difegue Date: Sun, 3 Oct 2021 18:08:47 +0200 Subject: [PATCH 2/7] Clean up --- README.md | 5 +- .../MpcNET/Commands/Database/FindCommand.cs | 72 ---------------- .../MpcNET/Commands/Playlist/AddCommand.cs | 48 ----------- .../MpcNET/Commands/Playlist/AddIdCommand.cs | 48 ----------- .../MpcNET/Commands/Playlist/ClearCommand.cs | 37 -------- .../MpcNET/Commands/Playlist/DeleteCommand.cs | 48 ----------- .../Commands/Playlist/DeleteIdCommand.cs | 48 ----------- .../MpcNET/Commands/Playlist/MoveIdCommand.cs | 52 ------------ .../Commands/Playlist/PlaylistCommand.cs | 41 --------- .../Commands/Playlist/PlaylistIdCommand.cs | 49 ----------- .../Commands/Playlist/PlaylistInfoCommand.cs | 38 --------- Sources/MpcNET/IMpcConnectionReporter.cs | 80 ------------------ Sources/MpcNET/MpcNET.csproj | 6 +- Sources/MpcNET/icon.png => icon.png | Bin 14 files changed, 8 insertions(+), 564 deletions(-) delete mode 100644 Sources/MpcNET/Commands/Database/FindCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/AddCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/AddIdCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/ClearCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/DeleteCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/DeleteIdCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/MoveIdCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/PlaylistCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/PlaylistIdCommand.cs delete mode 100644 Sources/MpcNET/Commands/Playlist/PlaylistInfoCommand.cs delete mode 100644 Sources/MpcNET/IMpcConnectionReporter.cs rename Sources/MpcNET/icon.png => icon.png (100%) diff --git a/README.md b/README.md index a014b9d..da53e03 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ - + MpcNET =========== -Pure .NET Client Library for [**Music Player Daemon**](https://www.musicpd.org/) Servers. +Pure .NET Client Library for [**Music Player Daemon**](https://www.musicpd.org/) Servers. +The heart and soul of [Stylophone](https://github.com/Difegue/Stylophone). ## Usage ### Connection diff --git a/Sources/MpcNET/Commands/Database/FindCommand.cs b/Sources/MpcNET/Commands/Database/FindCommand.cs deleted file mode 100644 index 954c14e..0000000 --- a/Sources/MpcNET/Commands/Database/FindCommand.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Database -{ - using System.Collections.Generic; - using System.Linq; - using MpcNET.Tags; - using MpcNET.Types; - - /// - /// Finds songs in the database that is exactly "searchText". - /// https://www.musicpd.org/doc/protocol/database.html. - /// - public class FindCommand : IMpcCommand> - { - private readonly List> filters; - - /// - /// Initializes a new instance of the class. - /// - /// The tag. - /// The search text. - public FindCommand(ITag tag, string searchText) - { - this.filters = new List>(); - this.filters.Add(new KeyValuePair(tag, searchText)); - } - - /// - /// Initializes a new instance of the class. - /// - /// List of key/value filters - public FindCommand(List> filters) - { - this.filters = filters; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => - string.Join(" ", - "find", - string.Join(" ", - this.filters - .Select(x => string.Join(" ", - x.Key.Value, escape(x.Value))) - .ToArray())); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public IEnumerable Deserialize(IReadOnlyList> response) - { - return MpdFile.CreateList(response); - } - - private string escape(string value) => string.Format("\"{0}\"", value.Replace("\\", "\\\\").Replace("\"", "\\\"")); - } - // TODO: rescan -} diff --git a/Sources/MpcNET/Commands/Playlist/AddCommand.cs b/Sources/MpcNET/Commands/Playlist/AddCommand.cs deleted file mode 100644 index 27c3766..0000000 --- a/Sources/MpcNET/Commands/Playlist/AddCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Adds the file URI to the playlist (directories add recursively). URI can also be a single file. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class AddCommand : IMpcCommand - { - private readonly string uri; - - /// - /// Initializes a new instance of the class. - /// - /// The URI. - public AddCommand(string uri) - { - this.uri = uri; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "add", $"\"{this.uri}\""); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} diff --git a/Sources/MpcNET/Commands/Playlist/AddIdCommand.cs b/Sources/MpcNET/Commands/Playlist/AddIdCommand.cs deleted file mode 100644 index 0643ca3..0000000 --- a/Sources/MpcNET/Commands/Playlist/AddIdCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Adds a song to the playlist (non-recursive) and returns the song id. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class AddIdCommand : IMpcCommand - { - private readonly string uri; - - /// - /// Initializes a new instance of the class. - /// - /// The URI. - public AddIdCommand(string uri) - { - this.uri = uri; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "addid", $"\"{this.uri}\""); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/ClearCommand.cs b/Sources/MpcNET/Commands/Playlist/ClearCommand.cs deleted file mode 100644 index a9ef8a4..0000000 --- a/Sources/MpcNET/Commands/Playlist/ClearCommand.cs +++ /dev/null @@ -1,37 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Clears the current playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class ClearCommand : IMpcCommand - { - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => "clear"; - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/DeleteCommand.cs b/Sources/MpcNET/Commands/Playlist/DeleteCommand.cs deleted file mode 100644 index 0f19bed..0000000 --- a/Sources/MpcNET/Commands/Playlist/DeleteCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Deletes a song from the playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class DeleteCommand : IMpcCommand - { - private readonly int position; - - /// - /// Initializes a new instance of the class. - /// - /// The position. - public DeleteCommand(int position) - { - this.position = position; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "delete", this.position); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/DeleteIdCommand.cs b/Sources/MpcNET/Commands/Playlist/DeleteIdCommand.cs deleted file mode 100644 index ea4a4bd..0000000 --- a/Sources/MpcNET/Commands/Playlist/DeleteIdCommand.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Deletes the song SONGID from the playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class DeleteIdCommand : IMpcCommand - { - private readonly int songId; - - /// - /// Initializes a new instance of the class. - /// - /// The song identifier. - public DeleteIdCommand(int songId) - { - this.songId = songId; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "deleteid", this.songId); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/MoveIdCommand.cs b/Sources/MpcNET/Commands/Playlist/MoveIdCommand.cs deleted file mode 100644 index bdfdb10..0000000 --- a/Sources/MpcNET/Commands/Playlist/MoveIdCommand.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - - /// - /// Moves the song with FROM (songid) to TO (playlist index) in the playlist. - /// If TO is negative, it is relative to the current song in the playlist (if there is one) - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class MoveIdCommand : IMpcCommand - { - private readonly int from; - private readonly int to; - - /// - /// Initializes a new instance of the class. - /// - /// From (songid) - /// To (playlist index) - public MoveIdCommand(int from, int to) - { - this.from = from; - this.to = to; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", "moveid", from, to); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public string Deserialize(IReadOnlyList> response) - { - return string.Join(", ", response); - } - } -} diff --git a/Sources/MpcNET/Commands/Playlist/PlaylistCommand.cs b/Sources/MpcNET/Commands/Playlist/PlaylistCommand.cs deleted file mode 100644 index 4ce6fe8..0000000 --- a/Sources/MpcNET/Commands/Playlist/PlaylistCommand.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - using System.Linq; - using MpcNET.Types; - - /// - /// Displays the current playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class PlaylistCommand : IMpcCommand> - { - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => "playlist"; - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public IEnumerable Deserialize(IReadOnlyList> response) - { - var results = response.Select(line => MpdFile.Create(line.Value, int.Parse(line.Key))); - - return results; - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/PlaylistIdCommand.cs b/Sources/MpcNET/Commands/Playlist/PlaylistIdCommand.cs deleted file mode 100644 index 6716e5e..0000000 --- a/Sources/MpcNET/Commands/Playlist/PlaylistIdCommand.cs +++ /dev/null @@ -1,49 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - using MpcNET.Types; - - /// - /// Displays song ID in the playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class PlaylistIdCommand : IMpcCommand> - { - private readonly int songId; - - /// - /// Initializes a new instance of the class. - /// - /// The song identifier. - public PlaylistIdCommand(int songId) - { - this.songId = songId; - } - - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => string.Join(" ", new[] { "playlistid" }, this.songId); - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public IEnumerable Deserialize(IReadOnlyList> response) - { - return MpdFile.CreateList(response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/Commands/Playlist/PlaylistInfoCommand.cs b/Sources/MpcNET/Commands/Playlist/PlaylistInfoCommand.cs deleted file mode 100644 index c1aecea..0000000 --- a/Sources/MpcNET/Commands/Playlist/PlaylistInfoCommand.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- -namespace MpcNET.Commands.Playlist -{ - using System.Collections.Generic; - using MpcNET.Types; - - /// - /// Displays a list of all songs in the playlist. - /// https://www.musicpd.org/doc/protocol/queue.html. - /// - public class PlaylistInfoCommand : IMpcCommand> - { - /// - /// Serializes the command. - /// - /// - /// The serialize command. - /// - public string Serialize() => "playlistinfo"; - - /// - /// Deserializes the specified response text pairs. - /// - /// The response. - /// - /// The deserialized response. - /// - public IEnumerable Deserialize(IReadOnlyList> response) - { - return MpdFile.CreateList(response); - } - } -} \ No newline at end of file diff --git a/Sources/MpcNET/IMpcConnectionReporter.cs b/Sources/MpcNET/IMpcConnectionReporter.cs deleted file mode 100644 index 59d67f7..0000000 --- a/Sources/MpcNET/IMpcConnectionReporter.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) MpcNET. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// -// -------------------------------------------------------------------------------------------------------------------- - -namespace MpcNET -{ - using System; - using Sundew.Base.Reporting; - - /// - /// Interface for implementing an observer for . - /// - public interface IMpcConnectionReporter : IReporter - { - /// - /// Called when connecting. - /// - /// if set to true [is reconnect]. - /// The connect attempt. - void Connecting(bool isReconnect, int connectAttempt); - - /// - /// Called when connection is accepted. - /// - /// if set to true [is reconnect]. - /// The connect attempt. - void ConnectionAccepted(bool isReconnect, int connectAttempt); - - /// - /// Called when connected. - /// - /// if set to true [is reconnect]. - /// The connect attempt. - /// The connection information. - void Connected(bool isReconnect, int connectAttempt, string connectionInfo); - - /// - /// Called when sending command. - /// - /// The command. - void Sending(string command); - - /// - /// Called when send exception occured. - /// - /// The command text. - /// The send attempt. - /// The exception. - void SendException(string commandText, int sendAttempt, Exception exception); - - /// - /// Called when send is retried. - /// - /// The command. - /// The send attempt. - void RetrySend(string command, int sendAttempt); - - /// - /// Called when response is read. - /// - /// The response line. - /// The command text. - void ReadResponse(string responseLine, string commandText); - - /// - /// Called when disconnecting. - /// - /// if set to true the disconnect was explicitly called. - void Disconnecting(bool isExplicitDisconnect); - - /// - /// Called when disconnected. - /// - /// if set to true the disconnect was explicitly called. - void Disconnected(bool isExplicitDisconnect); - } -} \ No newline at end of file diff --git a/Sources/MpcNET/MpcNET.csproj b/Sources/MpcNET/MpcNET.csproj index 4116083..3e9840c 100644 --- a/Sources/MpcNET/MpcNET.csproj +++ b/Sources/MpcNET/MpcNET.csproj @@ -22,7 +22,7 @@ README.md https://github.com/Difegue/MpcNET mpd;client;mpcNET - D:\Projects\LibMpcNETNuGet\LICENSE + MIT True @@ -55,6 +55,10 @@ + + True + + True diff --git a/Sources/MpcNET/icon.png b/icon.png similarity index 100% rename from Sources/MpcNET/icon.png rename to icon.png From c0d2ac48f6b2eaf935ed3c60b6228da1f6876515 Mon Sep 17 00:00:00 2001 From: Difegue Date: Sun, 3 Oct 2021 20:28:04 +0200 Subject: [PATCH 3/7] Add nupkg build and upload to github packages for nightlies --- .github/workflows/build-and-test.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 91140dc..0fde867 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -10,15 +10,12 @@ jobs: build: - strategy: - matrix: - configuration: [Debug, Release] - runs-on: windows-latest # For a list of available runner types, refer to # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on env: - Solution_Name: MpcNET + Solution_Name: MpcNET + Configuration: Release steps: - name: Checkout @@ -35,11 +32,18 @@ jobs: working-directory: ./Sources run: | msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration - msbuild $env:Uap_Project_Directory /t:Restore /p:Configuration=$env:Configuration - env: - Configuration: ${{ matrix.configuration }} + + # Build package and upload to github packages + - name: Build package + working-directory: ./Sources + run: | + dotnet nuget add source --username Difegue --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Difegue/index.json" + dotnet build $env:Solution_Name --configuration $env:Configuration + dotnet pack --configuration $env:Configuration -o ./ + dotnet nuget push *.nupkg --api-key ${{ secrets.PRIVATE_TOKEN }} --source "github" # Execute all unit tests in the solution - name: Execute unit tests working-directory: ./Sources run: dotnet test + From 588bc92c0095762481911040319703111e849346 Mon Sep 17 00:00:00 2001 From: Difegue Date: Sun, 3 Oct 2021 20:57:28 +0200 Subject: [PATCH 4/7] Add workflow to upload to nuget.org on release + add some examples to README --- .github/workflows/build-and-test.yml | 5 +- .github/workflows/release.yml | 39 ++++++++++++++ .gitignore | 1 + README.md | 76 +++++++++++++++++++++++++++- 4 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 0fde867..b681806 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -10,8 +10,7 @@ jobs: build: - runs-on: windows-latest # For a list of available runner types, refer to - # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on + runs-on: windows-latest env: Solution_Name: MpcNET @@ -40,7 +39,7 @@ jobs: dotnet nuget add source --username Difegue --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Difegue/index.json" dotnet build $env:Solution_Name --configuration $env:Configuration dotnet pack --configuration $env:Configuration -o ./ - dotnet nuget push *.nupkg --api-key ${{ secrets.PRIVATE_TOKEN }} --source "github" + dotnet nuget push *.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github" # Execute all unit tests in the solution - name: Execute unit tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d15a5a9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: New Version Release + +on: + release: + types: [published] + +jobs: + + build: + + runs-on: windows-latest + + env: + Solution_Name: MpcNET + Configuration: Release + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.0.2 + + # Restore the application + - name: Restore the application + working-directory: ./Sources + run: | + msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration + + # Build package and upload to github packages + - name: Build package + working-directory: ./Sources + run: | + dotnet build $env:Solution_Name --configuration $env:Configuration + dotnet pack --configuration $env:Configuration -o ./ + dotnet nuget push *.nupkg --api-key ${{ secrets.NUGET_API }} --source "nuget.org" diff --git a/.gitignore b/.gitignore index 588c486..bcf0f84 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ Sources/.DS_Store Sources/Stylophone.iOS/bin Sources/Stylophone.iOS/obj .DS_Store +/Sources/MpcNET.1.0.0.nupkg diff --git a/README.md b/README.md index da53e03..7d52bb5 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ var mpdEndpoint = new IPEndPoint(IPAddress.Loopback, 6600); ```` Then create a Client and Connect to MPD. ````C# -var client = new Mpc(mpdEndpoint); +var client = new MpcConnection(mpdEndpoint); var connected = await client.ConnectAsync(); ```` The `ConnectAsync()` method is returning a bool to indicate if the connection was successfully. However, this can be queried directly on the Client also: @@ -28,6 +28,78 @@ To disconnect the Client use the follow method: ````C# await client.DisconnectAsync(); ```` +or just dispose the client: +````C# +client.Dispose(); +```` ### Send Command -## API Content \ No newline at end of file +````C# +using (var client = new MpcConnection(mpdEndpoint)) { + await client.ConnectAsync(); + + // Look in /Commands to see everything that implements IMpcCommand + var request = await client.SendAsync(new IMpcCommand>(parameters)); + + if (!request.IsResponseValid) { + var mpdError = request.Response?.Result?.MpdError; + if (mpdError != null && mpdError != "") + Console.WriteLine($"Error: {mpdError}"); + else + Console.WriteLine($"Invalid server response: {response}."); + + } else { + List response = request.Response.Content; + // do stuff + } +} +```` + +### Command Lists + +````C# +var commandList = new CommandList(); + +commandList.Add(new IMpcCommand(firstCommandArgument); +commandList.Add(new IMpcCommand(secondCommandArgument); +commandList.Add(new IMpcCommand(thirdCommandArgument); + +using (var client = new MpcConnection(mpdEndpoint)) { + await client.ConnectAsync(); + var request = await client.SendAsync(commandList); + + // Response string contains responses of all the commands, split by commas + string response = request.Response?.Content; +} + +```` + +### Binary Responses + +````C# +// Get albumart from MPD +List data = new List(); + +using (var client = new MpcConnection(mpdEndpoint)) +{ + long totalBinarySize = 9999; + long currentSize = 0; + + do + { + var albumReq = await client.SendAsync(new AlbumArtCommand(f.Path, currentSize)); + if (!albumReq.IsResponseValid) break; + + var response = albumReq.Response.Content; + if (response.Binary == 0) break; // MPD isn't giving us any more data, let's roll with what we have. + + totalBinarySize = response.Size; + currentSize += response.Binary; + data.AddRange(response.Data); + + Debug.WriteLine($"Downloading albumart: {currentSize}/{totalBinarySize}"); + } while (currentSize < totalBinarySize); +} + +```` + From 312a73dc660fd82935577b1b6c19d238e81afc38 Mon Sep 17 00:00:00 2001 From: Difegue Date: Sun, 3 Oct 2021 21:12:36 +0200 Subject: [PATCH 5/7] Add MinVer for nuget package versioning --- Sources/MpcNET/MpcNET.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/MpcNET/MpcNET.csproj b/Sources/MpcNET/MpcNET.csproj index 3e9840c..770612d 100644 --- a/Sources/MpcNET/MpcNET.csproj +++ b/Sources/MpcNET/MpcNET.csproj @@ -66,6 +66,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + From 154c4b8b1871cd2ea8b376ebca65fa94bb79d48e Mon Sep 17 00:00:00 2001 From: Difegue Date: Sun, 3 Oct 2021 21:16:52 +0200 Subject: [PATCH 6/7] Disable tests on Actions for now --- .github/workflows/build-and-test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b681806..885ebf2 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -31,18 +31,18 @@ jobs: working-directory: ./Sources run: | msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration - + # Build package and upload to github packages - name: Build package working-directory: ./Sources run: | dotnet nuget add source --username Difegue --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Difegue/index.json" dotnet build $env:Solution_Name --configuration $env:Configuration - dotnet pack --configuration $env:Configuration -o ./ + dotnet pack --configuration $env:Configuration -o ./ dotnet nuget push *.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source "github" # Execute all unit tests in the solution - - name: Execute unit tests - working-directory: ./Sources - run: dotnet test + #- name: Execute unit tests + # working-directory: ./Sources + # run: dotnet test From a6b575ecd8c2eac290b9395114429ba7a9cd0a66 Mon Sep 17 00:00:00 2001 From: Difegue Date: Sun, 3 Oct 2021 21:28:12 +0200 Subject: [PATCH 7/7] Add links to readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7d52bb5..f6f8d33 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,10 @@ MpcNET Pure .NET Client Library for [**Music Player Daemon**](https://www.musicpd.org/) Servers. The heart and soul of [Stylophone](https://github.com/Difegue/Stylophone). +[**Nightly Packages**](https://github.com/Difegue/MpcNET/packages/) - [**Stable Versions**](https://www.nuget.org/packages/MpcNET/) + ## Usage + ### Connection To create a client for MPD, you must first create a `IPEndPoint` for the Server with the right IP and Port. ````C#