diff --git a/.github/workflows/nativeaot-test.yml b/.github/workflows/nativeaot-test.yml new file mode 100644 index 0000000..a085f35 --- /dev/null +++ b/.github/workflows/nativeaot-test.yml @@ -0,0 +1,35 @@ +name: NativeAOT Test +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test-aot: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Write Secret into file + uses: "DamianReeves/write-file-action@master" + with: + path: HyPlayer.NeteaseProvider.Tests/Secrets.cs + write-mode: overwrite + contents: | + ${{ secrets.NETEASE_LOGIN_SECRET }} + + - name: Restore + run: dotnet restore -r linux-x64 -p:TargetFramework=net9.0 + + - name: Publish with AOT + run: dotnet publish -c Release -f net9.0 -r linux-x64 --no-restore + + - name: Run AOT tests + run: ./HyPlayer.NeteaseProvider.Tests/bin/Release/net9.0/linux-x64/publish/HyPlayer.NeteaseProvider.Tests \ No newline at end of file diff --git a/.github/workflows/nuget-push.yml b/.github/workflows/nuget-push.yml index 45df766..f9bd04a 100644 --- a/.github/workflows/nuget-push.yml +++ b/.github/workflows/nuget-push.yml @@ -29,9 +29,7 @@ jobs: - name: Restore dependencies run: dotnet restore - name: Build - run: dotnet build --no-restore - - name: Test - run: dotnet test --no-build --verbosity normal + run: dotnet build --no-restore --configuration Release - name: Build NuGet Packages run: | dotnet pack HyPlayer.NeteaseApi/HyPlayer.NeteaseApi.csproj -c Release -o Packages/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..39566cd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,76 @@ +name: Test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + name: Test on ${{ matrix.os }} - .NET ${{ matrix.dotnet-version }} + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [windows-latest] + dotnet-version: ['9.0.x'] + fail-fast: false # Continue running other jobs if one fails + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET ${{ matrix.dotnet-version }} + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ matrix.dotnet-version }} + + - name: Write Secret into file + uses: "DamianReeves/write-file-action@master" + with: + path: HyPlayer.NeteaseProvider.Tests/Secrets.cs + write-mode: overwrite + contents: | + ${{ secrets.NETEASE_LOGIN_SECRET }} + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Run tests with coverage + run: dotnet test --configuration Release --no-build -- --coverage --report-trx --results-directory ./TestResults + + - name: Upload test results + if: always() # Run even if tests fail + uses: actions/upload-artifact@v4 + with: + name: test-results-${{ matrix.os }}-${{ matrix.dotnet-version }} + path: ./TestResults/*.trx + + - name: Upload coverage + if: always() + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ matrix.os }}-${{ matrix.dotnet-version }} + path: ./TestResults/*.coverage + + publish-results: + name: Publish Test Results + needs: test + runs-on: ubuntu-latest + if: always() + + steps: + - name: Download all test results + uses: actions/download-artifact@v4 + with: + pattern: test-results-* + path: ./TestResults + + - name: Publish test results + uses: EnricoMi/publish-unit-test-result-action@v2 + with: + files: ./TestResults/**/*.trx \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9d7aa13..b365e90 100644 --- a/.gitignore +++ b/.gitignore @@ -681,4 +681,6 @@ fabric.properties ### VisualStudio Patch ### # Additional files built by Visual Studio -# End of https://www.toptal.com/developers/gitignore/api/rider,csharp,dotnetcore,visualstudio \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/rider,csharp,dotnetcore,visualstudio + +*.g.cs \ No newline at end of file diff --git a/.idea/.idea.HyPlayer.NeteaseProvider/.idea/vcs.xml b/.idea/.idea.HyPlayer.NeteaseProvider/.idea/vcs.xml index 35eb1dd..031351a 100644 --- a/.idea/.idea.HyPlayer.NeteaseProvider/.idea/vcs.xml +++ b/.idea/.idea.HyPlayer.NeteaseProvider/.idea/vcs.xml @@ -2,5 +2,11 @@ + + + + + + \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumApi.cs index 2ac147e..23806fa 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Album; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumDetailDynamicApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumDetailDynamicApi.cs index 58d1018..6ef4ab6 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumDetailDynamicApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumDetailDynamicApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Album; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumSublistApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumSublistApi.cs index c582296..b6ee17a 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumSublistApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumSublistApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Album; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumSubscribeApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumSubscribeApi.cs index 5de8dee..68b4144 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumSubscribeApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Album/AlbumSubscribeApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Album; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistAlbumsApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistAlbumsApi.cs index e35a1c1..2184108 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistAlbumsApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistAlbumsApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Artist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistDetailApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistDetailApi.cs index b84011f..695071f 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistDetailApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistDetailApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Artist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; @@ -53,14 +53,15 @@ public class ArtistDetailDto [JsonPropertyName("name")] public string? Name { get; set; } [JsonPropertyName("alias")] public string[]? Alias { get; set; } [JsonPropertyName("followed")] public bool Followed { get; set; } - [JsonPropertyName("cover")] public string? PicUrl { get; set; } - [JsonPropertyName("avatar")] public string? Img1v1Url { get; set; } + [JsonPropertyName("picUrl")] public string? PicUrl { get; set; } + [JsonPropertyName("img1v1Url")] public string? Img1v1Url { get; set; } [JsonPropertyName("briefDesc")] public string? BriefDesc { get; set; } [JsonPropertyName("trans")] public string? Translation { get; set; } [JsonPropertyName("musicSize")] public int MusicSize { get; set; } [JsonPropertyName("albumSize")] public int AlbumSize { get; set; } [JsonPropertyName("mvSize")] public int MvSize { get; set; } [JsonPropertyName("transNames")] public string[]? TransNames { get; set; } + [JsonPropertyName("accountId")] public string? AccountId { get; set; } } } diff --git a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistSongsApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistSongsApi.cs index 01137cc..2c361b7 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistSongsApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistSongsApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Artist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistSublistApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistSublistApi.cs index aa8d344..359221b 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistSublistApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistSublistApi.cs @@ -3,6 +3,7 @@ using HyPlayer.NeteaseApi.Bases.ApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistTopSongApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistTopSongApi.cs index 7ed8d18..1ca9cc7 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistTopSongApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistTopSongApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Artist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistVideoApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistVideoApi.cs index 45e9247..fac3188 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistVideoApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Artist/ArtistVideoApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Artist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json; using System.Text.Json.Serialization; @@ -40,7 +40,7 @@ public override Task MapRequest(ApiHandlerOption option) ArtistId = Request.ArtistId, Tab = Request.Tab, Order = Request.Order, - Page = JsonSerializer.Serialize(page) + Page = JsonSerializer.Serialize(page, ApiHandlerOption.JsonSerializerOptionsOnlyTypeInfo) }; } diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudDeleteApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudDeleteApi.cs index 4a003cc..99884a1 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudDeleteApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudDeleteApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudGetApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudGetApi.cs index 436861d..bf31243 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudGetApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudGetApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudPubApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudPubApi.cs index a99604f..df41cad 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudPubApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudPubApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadCheck.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadCheck.cs index b70d68e..c82ddaf 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadCheck.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadCheck.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadCoverTokenAllocApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadCoverTokenAllocApi.cs index 7afa6ce..84e7e93 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadCoverTokenAllocApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadCoverTokenAllocApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadInfoApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadInfoApi.cs index f528b47..d0bdb4e 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadInfoApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadInfoApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadTokenAllocApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadTokenAllocApi.cs index cc2d4e5..7c361e3 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadTokenAllocApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/CloudUploadTokenAllocApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.RawApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/NeteaseUploadLoadBalancerGetApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/NeteaseUploadLoadBalancerGetApi.cs index 00934b1..3e8866d 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/NeteaseUploadLoadBalancerGetApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/NeteaseUploadLoadBalancerGetApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.RawApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/UserCloudApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/UserCloudApi.cs index 5eee195..2e4c556 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/UserCloudApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/UserCloudApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Cloud/UserCloudDelete.cs b/HyPlayer.NeteaseApi/ApiContracts/Cloud/UserCloudDelete.cs index 20ce480..2fe306d 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Cloud/UserCloudDelete.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Cloud/UserCloudDelete.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts @@ -16,7 +16,7 @@ public static partial class NeteaseApis namespace HyPlayer.NeteaseApi.ApiContracts.Cloud { - public class UserCloudDeleteApi : EApiContractBase { public override string IdentifyRoute => "/user/cloud/del"; @@ -36,6 +36,10 @@ public override Task MapRequest(ApiHandlerOption option) public override string ApiPath { get; protected set; } = "/api/cloud/del"; } + + public class UserCloudDeleteRequest : IdOrIdListListRequest + { + } public class UserCloudDeleteResponse : CodedResponseBase { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentFloorApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentFloorApi.cs index 71f1112..bb6d636 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentFloorApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentFloorApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Comment; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Extensions; using HyPlayer.NeteaseApi.Models; using HyPlayer.NeteaseApi.Models.ResponseModels; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentLikeApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentLikeApi.cs index 23a272f..cf3706d 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentLikeApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentLikeApi.cs @@ -4,6 +4,7 @@ using HyPlayer.NeteaseApi.Extensions; using HyPlayer.NeteaseApi.Models; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentsApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentsApi.cs index 4177a3c..cae7a9f 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentsApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Comment/CommentsApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Comment; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Extensions; using HyPlayer.NeteaseApi.Models; using HyPlayer.NeteaseApi.Models.ResponseModels; diff --git a/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelDetailApi.cs b/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelDetailApi.cs index 660eff0..4aa29ef 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelDetailApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelDetailApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.DjChannel; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelProgramsApi.cs b/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelProgramsApi.cs index 3cb1e7b..d2049df 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelProgramsApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelProgramsApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.DjChannel; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelSubscribedApi.cs b/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelSubscribedApi.cs index dd6bd3a..9d02236 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelSubscribedApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/DjChannel/DjChannelSubscribedApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.DjChannel; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherEndApi.cs b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherEndApi.cs index e503773..ad57ac8 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherEndApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherEndApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.ListenTogether.Dual; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherHeartbeatApi.cs b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherHeartbeatApi.cs index 81e338f..acfb4f4 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherHeartbeatApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherHeartbeatApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.ListenTogether.Dual; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherInvitationAcceptApi.cs b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherInvitationAcceptApi.cs index aa0ea94..c589865 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherInvitationAcceptApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherInvitationAcceptApi.cs @@ -1,7 +1,7 @@ -using HyPlayer.NeteaseApi.ApiContracts.Category; +using HyPlayer.NeteaseApi.ApiContracts.ListenTogether; using HyPlayer.NeteaseApi.ApiContracts.ListenTogether.Dual; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts @@ -13,7 +13,7 @@ public static partial class NeteaseApis } -namespace HyPlayer.NeteaseApi.ApiContracts.Category +namespace HyPlayer.NeteaseApi.ApiContracts.ListenTogether { public class ListenTogetherInvitationAcceptApi : EApiContractBase diff --git a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherPlayCommandApi.cs b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherPlayCommandApi.cs index 7f5b432..6f2543c 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherPlayCommandApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherPlayCommandApi.cs @@ -1,7 +1,7 @@ -using HyPlayer.NeteaseApi.ApiContracts.Category; +using HyPlayer.NeteaseApi.ApiContracts.ListenTogether; using HyPlayer.NeteaseApi.ApiContracts.ListenTogether.Dual; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json; using System.Text.Json.Serialization; @@ -14,7 +14,7 @@ public static partial class NeteaseApis } -namespace HyPlayer.NeteaseApi.ApiContracts.Category +namespace HyPlayer.NeteaseApi.ApiContracts.ListenTogether { public class ListenTogetherPlayCommandApi : EApiContractBase @@ -56,7 +56,7 @@ public override Task MapRequest(ApiHandlerOption option) FormerSongId = Request.FormerSongId, TargetSongId = Request.TargetSongId, ClientSeq = Request.ClientSeq - }) + }, ApiHandlerOption.JsonSerializerOptionsOnlyTypeInfo) }; return Task.CompletedTask; } diff --git a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherRoomCheckApi.cs b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherRoomCheckApi.cs index c9a1532..39b956f 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherRoomCheckApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherRoomCheckApi.cs @@ -1,6 +1,6 @@ -using HyPlayer.NeteaseApi.ApiContracts.Category; +using HyPlayer.NeteaseApi.ApiContracts.ListenTogether; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts @@ -13,7 +13,7 @@ public static partial class NeteaseApis } -namespace HyPlayer.NeteaseApi.ApiContracts.Category +namespace HyPlayer.NeteaseApi.ApiContracts.ListenTogether { public class ListenTogetherRoomCheckApi : EApiContractBase diff --git a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherRoomCreate.cs b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherRoomCreate.cs index e83c059..ae762ec 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherRoomCreate.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherRoomCreate.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.ListenTogether.Dual; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherStatusApi.cs b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherStatusApi.cs index d993866..d6065a2 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherStatusApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherStatusApi.cs @@ -1,7 +1,7 @@ -using HyPlayer.NeteaseApi.ApiContracts.Category; +using HyPlayer.NeteaseApi.ApiContracts.ListenTogether; using HyPlayer.NeteaseApi.ApiContracts.ListenTogether.Dual; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts @@ -14,7 +14,7 @@ public static partial class NeteaseApis } -namespace HyPlayer.NeteaseApi.ApiContracts.Category +namespace HyPlayer.NeteaseApi.ApiContracts.ListenTogether { public class ListenTogetherStatusApi : EApiContractBase diff --git a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherSyncListCommandApi.cs b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherSyncListCommandApi.cs index 877ab4d..f1cd89e 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherSyncListCommandApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherSyncListCommandApi.cs @@ -1,6 +1,6 @@ -using HyPlayer.NeteaseApi.ApiContracts.Category; +using HyPlayer.NeteaseApi.ApiContracts.ListenTogether; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json; using System.Text.Json.Serialization; @@ -13,7 +13,7 @@ public static partial class NeteaseApis } -namespace HyPlayer.NeteaseApi.ApiContracts.Category +namespace HyPlayer.NeteaseApi.ApiContracts.ListenTogether { public class ListenTogetherSyncListReportApi : EApiContractBase @@ -66,7 +66,8 @@ public override Task MapRequest(ApiHandlerOption option) }; var playlistParamJson = JsonSerializer.Serialize(playlistParam, new JsonSerializerOptions(JsonSerializerDefaults.Web) { - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + TypeInfoResolver = NeteaseApiContractJsonContext.Default }); ActualRequest = new ListenTogetherSyncListReportActualRequest() { diff --git a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherSyncListGetApi.cs b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherSyncListGetApi.cs index 2740ad5..a22c51e 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherSyncListGetApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/ListenTogether/Dual/ListenTogetherSyncListGetApi.cs @@ -1,6 +1,6 @@ -using HyPlayer.NeteaseApi.ApiContracts.Category; +using HyPlayer.NeteaseApi.ApiContracts.ListenTogether; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts @@ -13,7 +13,7 @@ public static partial class NeteaseApis } -namespace HyPlayer.NeteaseApi.ApiContracts.Category +namespace HyPlayer.NeteaseApi.ApiContracts.ListenTogether { public class ListenTogetherSyncListGetApi : EApiContractBase diff --git a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginCellphoneApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginCellphoneApi.cs index e8528c6..7a6fc9d 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginCellphoneApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginCellphoneApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Login; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Extensions; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginEmailApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginEmailApi.cs index ccc0920..a69d217 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginEmailApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginEmailApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Login; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Extensions; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginQrCodeCheck.cs b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginQrCodeCheck.cs index 2d76754..f8c2af7 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginQrCodeCheck.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginQrCodeCheck.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Login; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginQrCodeUnikey.cs b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginQrCodeUnikey.cs index 61b1c92..520d451 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginQrCodeUnikey.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginQrCodeUnikey.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Login; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginStatusApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginStatusApi.cs index 1b9ee8b..372a38b 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Login/LoginStatusApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Login/LoginStatusApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Login; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/AiDjContentRcmdInfo.cs b/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/AiDjContentRcmdInfo.cs index b823259..0340154 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/AiDjContentRcmdInfo.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/AiDjContentRcmdInfo.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.PersonalFM; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json; using System.Text.Json.Serialization; @@ -52,7 +52,7 @@ public override Task MapRequest(ApiHandlerOption option) ActualRequest = new AiDjContentRcmdInfoActualRequest { - ExtInfo = JsonSerializer.Serialize(extInfo) + ExtInfo = JsonSerializer.Serialize(extInfo, ApiHandlerOption.JsonSerializerOptionsOnlyTypeInfo) }; return Task.CompletedTask; } @@ -86,7 +86,6 @@ public class AiDjContentRcmdInfoResource public class AiDjContentRcmdAudioSong : AiDjContentRcmdInfoResource { - [JsonPropertyName("type")] public string? Type { get; set; } [JsonPropertyName("value")] public AiDjContentRcmdAudioSongValue? Value { get; set; } public class AiDjContentRcmdAudioSongValue @@ -101,7 +100,6 @@ public class AiDjContentRcmdAudioResource : AiDjContentRcmdInfoResource { [JsonPropertyName("value")] public AiDjContentRcmdAudioResourceValue? Value { get; set; } - [JsonPropertyName("type")] public string? Type { get; set; } public class AiDjContentRcmdAudioResourceValue { @@ -130,7 +128,8 @@ public class AiDjContentRcmdInfoActualRequest : EApiActualRequestBase [JsonPropertyName("extInfo")] public string? ExtInfo { get; set; } } - class AiDjActualRequestExtInfo + [JsonContextSerializable(typeof(AiDjActualRequestExtInfo))] + public class AiDjActualRequestExtInfo { [JsonPropertyName("lastRequestTimestamp")] public long LastRequestTimestamp { get; set; } @@ -139,7 +138,7 @@ class AiDjActualRequestExtInfo [JsonPropertyName("listenedTs")] public bool ListenedTs { get; set; } [JsonPropertyName("noAidjToAidj")] public bool NoAidjToAidj { get; set; } - internal class LbsInfo + public class LbsInfo { [JsonPropertyName("lat")] public float Latitude { get; set; } [JsonPropertyName("lon")] public float Longitude { get; set; } diff --git a/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/AiDjSkip.cs b/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/AiDjSkip.cs index b3b78b3..497efc7 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/AiDjSkip.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/AiDjSkip.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.PersonalFM; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/PersonalFMApi.cs b/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/PersonalFMApi.cs index c1fc7eb..1bbafc8 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/PersonalFMApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/PersonalFMApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.PersonalFM; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/PersonalFmTrashApi.cs b/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/PersonalFmTrashApi.cs index 9fe6e02..993596f 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/PersonalFmTrashApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/PersonalFM/PersonalFmTrashApi.cs @@ -2,6 +2,7 @@ using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Bases.ApiContractBases; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/LikelistApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/LikelistApi.cs index 837d92e..ca0f928 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/LikelistApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/LikelistApi.cs @@ -2,6 +2,7 @@ using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Bases.ApiContractBases; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistCategoryListApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistCategoryListApi.cs index 3e214de..03b44fb 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistCategoryListApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistCategoryListApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Playlist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistCreateApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistCreateApi.cs index 50ef8b1..4fa94d0 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistCreateApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistCreateApi.cs @@ -1,7 +1,9 @@ using HyPlayer.NeteaseApi.ApiContracts.Playlist; using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistDeleteApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistDeleteApi.cs index 8735f84..43d8bfc 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistDeleteApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistDeleteApi.cs @@ -2,6 +2,7 @@ using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Bases.ApiContractBases; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistDetailApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistDetailApi.cs index 5045b50..662ba33 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistDetailApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistDetailApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Playlist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistPrivacyApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistPrivacyApi.cs index 6c4d572..31b4e9b 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistPrivacyApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistPrivacyApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Playlist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistSubscribeApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistSubscribeApi.cs index 6aed2ac..d2c583d 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistSubscribeApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistSubscribeApi.cs @@ -2,6 +2,7 @@ using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Bases.ApiContractBases; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistTracksEditApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistTracksEditApi.cs index 52f0d73..a67fabc 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistTracksEditApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistTracksEditApi.cs @@ -2,6 +2,7 @@ using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Bases.ApiContractBases; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistTracksGetApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistTracksGetApi.cs index e4cc4e7..18c69b9 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistTracksGetApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaylistTracksGetApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Playlist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaymodeIntelligenceListApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaymodeIntelligenceListApi.cs index 806358a..58d625e 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaymodeIntelligenceListApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/PlaymodeIntelligenceListApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Playlist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Playlist/ToplistApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Playlist/ToplistApi.cs index 2da1980..a62e6ba 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Playlist/ToplistApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Playlist/ToplistApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Playlist; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.RawApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendPlaylistsApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendPlaylistsApi.cs index 71195c2..cc841b1 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendPlaylistsApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendPlaylistsApi.cs @@ -3,6 +3,7 @@ using HyPlayer.NeteaseApi.Bases.ApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendResourceApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendResourceApi.cs index f32f8b4..25152de 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendResourceApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendResourceApi.cs @@ -3,6 +3,7 @@ using HyPlayer.NeteaseApi.Bases.ApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendSongs.cs b/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendSongs.cs index 7911a71..519f39e 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendSongs.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Recommend/RecommendSongs.cs @@ -3,6 +3,7 @@ using HyPlayer.NeteaseApi.Bases.ApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Recommend/SearchApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Recommend/SearchApi.cs index 3abb12b..e0ca1c3 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Recommend/SearchApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Recommend/SearchApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Recommend; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Recommend/SearchSuggestionApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Recommend/SearchSuggestionApi.cs index 1aeb5ad..9eb28bb 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Recommend/SearchSuggestionApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Recommend/SearchSuggestionApi.cs @@ -2,6 +2,7 @@ using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Bases.ApiContractBases; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Song/LikeApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Song/LikeApi.cs index 9b87a56..f0f1c90 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Song/LikeApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Song/LikeApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Song; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Song/LyricApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Song/LyricApi.cs index 9fbf586..f4ae73a 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Song/LyricApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Song/LyricApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Song; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Song/MusicFirstListenInfoApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Song/MusicFirstListenInfoApi.cs index a513309..2e0edef 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Song/MusicFirstListenInfoApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Song/MusicFirstListenInfoApi.cs @@ -2,6 +2,7 @@ using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Bases.ApiContractBases; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { diff --git a/HyPlayer.NeteaseApi/ApiContracts/Song/SongChorusApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Song/SongChorusApi.cs index cdeb47c..05d30ce 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Song/SongChorusApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Song/SongChorusApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Song; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Song/SongDetailApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Song/SongDetailApi.cs index 07e4c6f..40894e0 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Song/SongDetailApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Song/SongDetailApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Song; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Song/SongUrlApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Song/SongUrlApi.cs index f5939c9..571def5 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Song/SongUrlApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Song/SongUrlApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Song; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Song/SongWikiSummaryApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Song/SongWikiSummaryApi.cs index 2c9a8a3..fc5c025 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Song/SongWikiSummaryApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Song/SongWikiSummaryApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Song; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/User/UserDetailApi.cs b/HyPlayer.NeteaseApi/ApiContracts/User/UserDetailApi.cs index 893ac1d..139c0ee 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/User/UserDetailApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/User/UserDetailApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.User; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/User/UserPlaylistApi.cs b/HyPlayer.NeteaseApi/ApiContracts/User/UserPlaylistApi.cs index 65d5a83..960587a 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/User/UserPlaylistApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/User/UserPlaylistApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.User; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; @@ -18,7 +18,7 @@ public static partial class NeteaseApis namespace HyPlayer.NeteaseApi.ApiContracts.User { - public class UserPlaylistApi : WeApiContractBase { public override string IdentifyRoute => "/user/playlist"; @@ -36,6 +36,8 @@ public override Task MapRequest(ApiHandlerOption option) }; return Task.CompletedTask; } + + public override string ApiPath { get; protected set; } = "/api/user/playlist"; } public class UserPlaylistRequest : RequestBase @@ -48,7 +50,7 @@ public class UserPlaylistRequest : RequestBase /// /// 获取数目 /// - public int Limit { get; set; } = 30; + public int Limit { get; set; } = 1000; /// /// 起始位置 @@ -61,11 +63,10 @@ public class UserPlaylistResponse : CodedResponseBase [JsonPropertyName("playlist")] public PlaylistDto[]? Playlists { get; set; } } - public class UserPlaylistActualRequest : WeApiActualRequestBase + public class UserPlaylistActualRequest : EApiActualRequestBase { [JsonPropertyName("uid")] public string? Uid { get; set; } - [JsonPropertyName("limit")] public int Limit { get; set; } = 30; + [JsonPropertyName("limit")] public int Limit { get; set; } = 1000; [JsonPropertyName("offset")] public int Offset { get; set; } - [JsonPropertyName("includeVideo")] public bool IncludeVideo => true; } } \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/ApiContracts/User/UserRecordApi.cs b/HyPlayer.NeteaseApi/ApiContracts/User/UserRecordApi.cs index da7d9d6..6ec11f2 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/User/UserRecordApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/User/UserRecordApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.User; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; @@ -52,11 +52,13 @@ public enum UserRecordType WeekData = 1 } + [JsonContextSerializable(typeof(UserRecordWeekResponse))] public class UserRecordWeekResponse : UserRecordResponse { [JsonPropertyName("weekData")] public UserRecordResponseItem[]? WeekData { get; set; } } + [JsonContextSerializable(typeof(UserRecordAllResponse))] public class UserRecordAllResponse : UserRecordResponse { [JsonPropertyName("allData")] public UserRecordResponseItem[]? AllData { get; set; } diff --git a/HyPlayer.NeteaseApi/ApiContracts/Utils/BatchApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Utils/BatchApi.cs index 08efc4b..59b9892 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Utils/BatchApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Utils/BatchApi.cs @@ -1,6 +1,6 @@ -using HyPlayer.NeteaseApi.ApiContracts.Category; +using HyPlayer.NeteaseApi.ApiContracts.Utils; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Extensions; using HyPlayer.NeteaseApi.Extensions.JsonSerializer; using System.Collections; @@ -14,7 +14,7 @@ public static partial class NeteaseApis } -namespace HyPlayer.NeteaseApi.ApiContracts.Category +namespace HyPlayer.NeteaseApi.ApiContracts.Utils { public class BatchApi : EApiContractBase { @@ -50,10 +50,10 @@ public override async Task> ProcessRespo { if (kvp.Key == "code") { - if (kvp.Value.Value != "200") + if (kvp.Value?.Value != "200") { return Results.CreateError( - new ErrorResultBase(int.Parse(kvp.Value.Value ?? "500"), "返回值不为 200")); + new ErrorResultBase(int.Parse(kvp.Value?.Value ?? "500"), "返回值不为 200")); } continue; } @@ -136,7 +136,7 @@ public bool Remove(string key) public bool TryGetValue(string key, out JsonObjectStringWrapper value) { - return _backingDictionary.TryGetValue(key, out value); + return _backingDictionary.TryGetValue(key, out value!); } public JsonObjectStringWrapper this[string key] diff --git a/HyPlayer.NeteaseApi/ApiContracts/Utils/LoginAnnounceDeviceApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Utils/LoginAnnounceDeviceApi.cs new file mode 100644 index 0000000..b4acb49 --- /dev/null +++ b/HyPlayer.NeteaseApi/ApiContracts/Utils/LoginAnnounceDeviceApi.cs @@ -0,0 +1,66 @@ +using HyPlayer.NeteaseApi.ApiContracts.Utils; +using HyPlayer.NeteaseApi.Bases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; +using HyPlayer.NeteaseApi.Extensions; +using System.Text.Json.Serialization; + +namespace HyPlayer.NeteaseApi.ApiContracts +{ + + public static partial class NeteaseApis + { + public static LoginAnnounceDeviceApi LoginAnnounceDeviceApi => new(); + } +} + + +namespace HyPlayer.NeteaseApi.ApiContracts.Utils +{ + + public class LoginAnnounceDeviceApi : EApiContractBase + { + public override string IdentifyRoute => "/login/anon/device"; + public override string Url { get; protected set; } = "https://interface.music.163.com/eapi/login/anon/device"; + public override HttpMethod Method => HttpMethod.Post; + public override Task MapRequest(ApiHandlerOption option) + { + Request ??= new LoginAnnounceDeviceRequest(); + option.Cookies["deviceId"] = NeteaseUtils.GetDeviceId(Request.Imei, Request.Mac, Request.AndroidId, Request.LocalId); + option.Cookies["mobilename"] = Request.DeviceName; + option.Cookies["os"] = Request.OS; + option.Cookies["channel"] = Request.Channel; + option.Cookies["deviceType"] = Request.DeviceType; + return Task.CompletedTask; + } + + public override string ApiPath { get; protected set; } = "/api/login/anon/device"; + } + + public class LoginAnnounceDeviceRequest : RequestBase + { + + public string? Imei { get; set; } + public string Mac { get; set; } = "02:00:00:00:00:00"; + public string? AndroidId { get; set; } + public string? LocalId { get; set; } + public string DeviceName { get; set; } = "car"; + public string OS { get; set; } = "andrcar"; + public string Channel { get; set; } = "release"; + public string DeviceType { get; set; } = "andrcar"; + + } + + public class LoginAnnounceDeviceResponse : CodedResponseBase + { + public class LoginAnnounceDeviceResponseData + { + [JsonPropertyName("userId")] public string? Id { get; set; } + } + [JsonPropertyName("data")] public LoginAnnounceDeviceResponseData? Data { get; set; } + } + + public class LoginAnnounceDeviceActualRequest : EApiActualRequestBase + { + + } +} \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/ApiContracts/Utils/PasswordUrlDecodeApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Utils/PasswordUrlDecodeApi.cs index 5b41b9f..23cb9e2 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Utils/PasswordUrlDecodeApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Utils/PasswordUrlDecodeApi.cs @@ -1,6 +1,6 @@ -using HyPlayer.NeteaseApi.ApiContracts.Category; +using HyPlayer.NeteaseApi.ApiContracts.Utils; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts @@ -13,7 +13,7 @@ public static partial class NeteaseApis } -namespace HyPlayer.NeteaseApi.ApiContracts.Category +namespace HyPlayer.NeteaseApi.ApiContracts.Utils { public class PasswordUrlDecodeApi : EApiContractBase diff --git a/HyPlayer.NeteaseApi/ApiContracts/User/RegisterAnonymousApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Utils/RegisterAnonymousApi.cs similarity index 73% rename from HyPlayer.NeteaseApi/ApiContracts/User/RegisterAnonymousApi.cs rename to HyPlayer.NeteaseApi/ApiContracts/Utils/RegisterAnonymousApi.cs index e449170..420838b 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/User/RegisterAnonymousApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Utils/RegisterAnonymousApi.cs @@ -1,24 +1,25 @@ -using HyPlayer.NeteaseApi.ApiContracts.Category; +using HyPlayer.NeteaseApi.ApiContracts.Utils; using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Bases.ApiContractBases; using System.Security.Cryptography; using System.Text; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.ApiContracts { public static partial class NeteaseApis { - public static RegisterAnounymousApi RegisterAnounymousApi => new(); + public static RegisterAnonymousApi RegisterAnonymousApi => new(); } } -namespace HyPlayer.NeteaseApi.ApiContracts.Category +namespace HyPlayer.NeteaseApi.ApiContracts.Utils { - public class RegisterAnounymousApi : WeApiContractBase + public class RegisterAnonymousApi : WeApiContractBase { public override string IdentifyRoute => "/register/anonimous"; public override string Url { get; protected set; } = "https://music.163.com/weapi/register/anonimous"; @@ -26,7 +27,7 @@ public class RegisterAnounymousApi : WeApiContractBase() { - ["songId"] = Request.SongId - }); + ["songId"] = Request.SongId! + }, ApiHandlerOption.JsonSerializerOptionsOnlyTypeInfo); } } diff --git a/HyPlayer.NeteaseApi/ApiContracts/Video/MlogUrlApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Video/MlogUrlApi.cs index 88cbca9..958eb15 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Video/MlogUrlApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Video/MlogUrlApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Video; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiContracts/Video/VideoDetailApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Video/VideoDetailApi.cs index dfc62ee..2135f39 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Video/VideoDetailApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Video/VideoDetailApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Video; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using HyPlayer.NeteaseApi.Models.ResponseModels; using System.Text.Json.Serialization; diff --git a/HyPlayer.NeteaseApi/ApiContracts/Video/VideoUrlApi.cs b/HyPlayer.NeteaseApi/ApiContracts/Video/VideoUrlApi.cs index fbd96f5..baa9da3 100644 --- a/HyPlayer.NeteaseApi/ApiContracts/Video/VideoUrlApi.cs +++ b/HyPlayer.NeteaseApi/ApiContracts/Video/VideoUrlApi.cs @@ -1,6 +1,6 @@ using HyPlayer.NeteaseApi.ApiContracts.Video; using HyPlayer.NeteaseApi.Bases; -using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; using System.Text.Json.Serialization; namespace HyPlayer.NeteaseApi.ApiContracts diff --git a/HyPlayer.NeteaseApi/ApiHandlerOption.cs b/HyPlayer.NeteaseApi/ApiHandlerOption.cs index 0b27016..1b0c39f 100644 --- a/HyPlayer.NeteaseApi/ApiHandlerOption.cs +++ b/HyPlayer.NeteaseApi/ApiHandlerOption.cs @@ -1,7 +1,9 @@ using HyPlayer.NeteaseApi.Extensions.JsonSerializer; using System.Net; +using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.ApiContracts; namespace HyPlayer.NeteaseApi; @@ -30,7 +32,20 @@ public class ApiHandlerOption NumberHandling = JsonNumberHandling.WriteAsString | JsonNumberHandling.AllowReadingFromString, AllowTrailingCommas = true, - Converters = { new NumberToStringConverter(), new JsonBooleanConverter(), new JsonObjectStringConverter() } + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + Converters = { new NumberToStringConverter(), new JsonBooleanConverter(), new JsonObjectStringConverter() }, + TypeInfoResolver = NeteaseApiContractJsonContext.Default + + }; + public static readonly JsonSerializerOptions JsonSerializerOptionsOnlyTypeInfo = + new(JsonSerializerOptions.Default) + { + TypeInfoResolver = NeteaseApiContractJsonContext.Default + }; + public static readonly JsonSerializerOptions JsonSerializerOptionsWebOnlyTypeInfo = + new(JsonSerializerOptions.Web) + { + TypeInfoResolver = NeteaseApiContractJsonContext.Default }; } @@ -40,6 +55,7 @@ public class AdditionalParameters public Dictionary Headers { get; set; } = []; public Dictionary EApiHeaders { get; set; } = []; public Dictionary DataTokens { get; set; } = []; + public OpenAPIConfigData? OpenAPIConfig { get; set; } = null; public bool HasValue() { if (Cookies.Count > 0 || @@ -48,4 +64,26 @@ public bool HasValue() DataTokens.Count > 0) return true; return false; } + + + public class OpenAPIConfigData + { + public string? AppId { get; set; } + public string? AppSecret { get; set; } + public string? RsaPrivateKey { get; set; } + public DeviceInfoData? DeviceInfo { get; set; } + + public class DeviceInfoData + { + public string? Channel { get; set; } + public string? DeviceId { get; set; } + public string? DeviceType { get; set; } + public string? AppVer { get; set; } + public string? OS { get; set; } + public string? OSVer { get; set; } + public string? Brand { get; set; } + public string? Model { get; set; } + public string? ClientIp { get; set; } + } + } } \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Bases/ActualRequestBase.cs b/HyPlayer.NeteaseApi/Bases/ActualRequestBase.cs deleted file mode 100644 index f3ae5d0..0000000 --- a/HyPlayer.NeteaseApi/Bases/ActualRequestBase.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace HyPlayer.NeteaseApi.Bases; - -public class ActualRequestBase -{ - -} \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Bases/ApiContractBases/ActualRequestBase.cs b/HyPlayer.NeteaseApi/Bases/ApiContractBases/ActualRequestBase.cs new file mode 100644 index 0000000..4a4e979 --- /dev/null +++ b/HyPlayer.NeteaseApi/Bases/ApiContractBases/ActualRequestBase.cs @@ -0,0 +1,6 @@ +namespace HyPlayer.NeteaseApi.Bases.ApiContractBases; + +public class ActualRequestBase +{ + +} \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Bases/ApiContractBase.cs b/HyPlayer.NeteaseApi/Bases/ApiContractBases/ApiContractBase.cs similarity index 97% rename from HyPlayer.NeteaseApi/Bases/ApiContractBase.cs rename to HyPlayer.NeteaseApi/Bases/ApiContractBases/ApiContractBase.cs index 82e1c37..8811e0c 100644 --- a/HyPlayer.NeteaseApi/Bases/ApiContractBase.cs +++ b/HyPlayer.NeteaseApi/Bases/ApiContractBases/ApiContractBase.cs @@ -1,3 +1,4 @@ +using HyPlayer.NeteaseApi.Bases.ApiContractBases; using HyPlayer.NeteaseApi.Extensions; namespace HyPlayer.NeteaseApi.Bases; diff --git a/HyPlayer.NeteaseApi/Bases/CodedResponseBase.cs b/HyPlayer.NeteaseApi/Bases/ApiContractBases/CodedResponseBase.cs similarity index 100% rename from HyPlayer.NeteaseApi/Bases/CodedResponseBase.cs rename to HyPlayer.NeteaseApi/Bases/ApiContractBases/CodedResponseBase.cs diff --git a/HyPlayer.NeteaseApi/Bases/ErrorResultBase.cs b/HyPlayer.NeteaseApi/Bases/ApiContractBases/ErrorResultBase.cs similarity index 100% rename from HyPlayer.NeteaseApi/Bases/ErrorResultBase.cs rename to HyPlayer.NeteaseApi/Bases/ApiContractBases/ErrorResultBase.cs diff --git a/HyPlayer.NeteaseApi/Bases/ExceptionedErrorBase.cs b/HyPlayer.NeteaseApi/Bases/ApiContractBases/ExceptionedErrorBase.cs similarity index 100% rename from HyPlayer.NeteaseApi/Bases/ExceptionedErrorBase.cs rename to HyPlayer.NeteaseApi/Bases/ApiContractBases/ExceptionedErrorBase.cs diff --git a/HyPlayer.NeteaseApi/Bases/IdOrIdListRequest.cs b/HyPlayer.NeteaseApi/Bases/ApiContractBases/IdOrIdListRequest.cs similarity index 100% rename from HyPlayer.NeteaseApi/Bases/IdOrIdListRequest.cs rename to HyPlayer.NeteaseApi/Bases/ApiContractBases/IdOrIdListRequest.cs diff --git a/HyPlayer.NeteaseApi/Bases/RequestBase.cs b/HyPlayer.NeteaseApi/Bases/ApiContractBases/RequestBase.cs similarity index 100% rename from HyPlayer.NeteaseApi/Bases/RequestBase.cs rename to HyPlayer.NeteaseApi/Bases/ApiContractBases/RequestBase.cs diff --git a/HyPlayer.NeteaseApi/Bases/ResponseBase.cs b/HyPlayer.NeteaseApi/Bases/ApiContractBases/ResponseBase.cs similarity index 100% rename from HyPlayer.NeteaseApi/Bases/ResponseBase.cs rename to HyPlayer.NeteaseApi/Bases/ApiContractBases/ResponseBase.cs diff --git a/HyPlayer.NeteaseApi/Bases/EApiActualRequestBase.cs b/HyPlayer.NeteaseApi/Bases/EApiContractBases/EApiActualRequestBase.cs similarity index 71% rename from HyPlayer.NeteaseApi/Bases/EApiActualRequestBase.cs rename to HyPlayer.NeteaseApi/Bases/EApiContractBases/EApiActualRequestBase.cs index d4ac365..c98ac8a 100644 --- a/HyPlayer.NeteaseApi/Bases/EApiActualRequestBase.cs +++ b/HyPlayer.NeteaseApi/Bases/EApiContractBases/EApiActualRequestBase.cs @@ -1,6 +1,7 @@ -using System.Text.Json.Serialization; +using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using System.Text.Json.Serialization; -namespace HyPlayer.NeteaseApi.Bases; +namespace HyPlayer.NeteaseApi.Bases.EApiContractBases; public class EApiActualRequestBase : ActualRequestBase { diff --git a/HyPlayer.NeteaseApi/Bases/ApiContractBases/EApiContractBase.cs b/HyPlayer.NeteaseApi/Bases/EApiContractBases/EApiContractBase.cs similarity index 98% rename from HyPlayer.NeteaseApi/Bases/ApiContractBases/EApiContractBase.cs rename to HyPlayer.NeteaseApi/Bases/EApiContractBases/EApiContractBase.cs index ab7e8cf..a9088a7 100644 --- a/HyPlayer.NeteaseApi/Bases/ApiContractBases/EApiContractBase.cs +++ b/HyPlayer.NeteaseApi/Bases/EApiContractBases/EApiContractBase.cs @@ -5,7 +5,7 @@ using System.Text.Json; using System.Text.RegularExpressions; -namespace HyPlayer.NeteaseApi.Bases.ApiContractBases; +namespace HyPlayer.NeteaseApi.Bases.EApiContractBases; public abstract class EApiContractBase : @@ -169,6 +169,7 @@ public override async Task> ProcessResp } else { + forceDecrypt = true; goto decryptApi; } } @@ -230,6 +231,8 @@ public string GetRequestJson(ApiHandlerOption option) public string GetRequestJson(TActualRequestMessageModel actualRequest, ApiHandlerOption option) { + if (actualRequest is null) + return "{}"; var json = JsonSerializer.Serialize(actualRequest, option.JsonSerializerOptions); if (actualRequest is CacheKeyEApiActualRequest) { @@ -266,7 +269,7 @@ public string GetRequestJson(TActualRequestMessageMo #endif return ret; } - catch + catch { return null; } diff --git a/HyPlayer.NeteaseApi/Bases/IBatchableApi.cs b/HyPlayer.NeteaseApi/Bases/EApiContractBases/IBatchableApi.cs similarity index 88% rename from HyPlayer.NeteaseApi/Bases/IBatchableApi.cs rename to HyPlayer.NeteaseApi/Bases/EApiContractBases/IBatchableApi.cs index 0bb6758..3933c98 100644 --- a/HyPlayer.NeteaseApi/Bases/IBatchableApi.cs +++ b/HyPlayer.NeteaseApi/Bases/EApiContractBases/IBatchableApi.cs @@ -1,4 +1,4 @@ -namespace HyPlayer.NeteaseApi.Bases; +namespace HyPlayer.NeteaseApi.Bases.EApiContractBases; public interface IBatchableApi { diff --git a/HyPlayer.NeteaseApi/Bases/LinuxApiActualRequestBase.cs b/HyPlayer.NeteaseApi/Bases/LinuxApiActualRequestBase.cs deleted file mode 100644 index 2a94514..0000000 --- a/HyPlayer.NeteaseApi/Bases/LinuxApiActualRequestBase.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace HyPlayer.NeteaseApi.Bases; - -public class LinuxApiActualRequestBase : ActualRequestBase -{ - -} \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Bases/LinuxApiContractBases/LinuxApiActualRequestBase.cs b/HyPlayer.NeteaseApi/Bases/LinuxApiContractBases/LinuxApiActualRequestBase.cs new file mode 100644 index 0000000..df6f109 --- /dev/null +++ b/HyPlayer.NeteaseApi/Bases/LinuxApiContractBases/LinuxApiActualRequestBase.cs @@ -0,0 +1,8 @@ +using HyPlayer.NeteaseApi.Bases.ApiContractBases; + +namespace HyPlayer.NeteaseApi.Bases.LinuxApiContractBases; + +public class LinuxApiActualRequestBase : ActualRequestBase +{ + +} \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Bases/ApiContractBases/LinuxApiContractBase.cs b/HyPlayer.NeteaseApi/Bases/LinuxApiContractBases/LinuxApiContractBase.cs similarity index 99% rename from HyPlayer.NeteaseApi/Bases/ApiContractBases/LinuxApiContractBase.cs rename to HyPlayer.NeteaseApi/Bases/LinuxApiContractBases/LinuxApiContractBase.cs index c899cf5..2ab926e 100644 --- a/HyPlayer.NeteaseApi/Bases/ApiContractBases/LinuxApiContractBase.cs +++ b/HyPlayer.NeteaseApi/Bases/LinuxApiContractBases/LinuxApiContractBase.cs @@ -4,7 +4,7 @@ using System.Text.Json; using System.Text.RegularExpressions; -namespace HyPlayer.NeteaseApi.Bases.ApiContractBases; +namespace HyPlayer.NeteaseApi.Bases.LinuxApiContractBases; public abstract class LinuxApiContractBase : ApiContractBase diff --git a/HyPlayer.NeteaseApi/Bases/RawApiActualRequestBase.cs b/HyPlayer.NeteaseApi/Bases/RawApiContractBases/RawApiActualRequestBase.cs similarity index 90% rename from HyPlayer.NeteaseApi/Bases/RawApiActualRequestBase.cs rename to HyPlayer.NeteaseApi/Bases/RawApiContractBases/RawApiActualRequestBase.cs index e47853a..3c89195 100644 --- a/HyPlayer.NeteaseApi/Bases/RawApiActualRequestBase.cs +++ b/HyPlayer.NeteaseApi/Bases/RawApiContractBases/RawApiActualRequestBase.cs @@ -1,6 +1,7 @@ -using System.Collections; +using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using System.Collections; -namespace HyPlayer.NeteaseApi.Bases; +namespace HyPlayer.NeteaseApi.Bases.RawApiContractBases; public abstract class RawApiActualRequestBase : ActualRequestBase, IDictionary { @@ -62,7 +63,7 @@ public bool Remove(string key) public bool TryGetValue(string key, out string value) { - return _backingDictionary.TryGetValue(key, out value); + return _backingDictionary.TryGetValue(key, out value!); } public string this[string key] diff --git a/HyPlayer.NeteaseApi/Bases/ApiContractBases/RawApiContractBase.cs b/HyPlayer.NeteaseApi/Bases/RawApiContractBases/RawApiContractBase.cs similarity index 98% rename from HyPlayer.NeteaseApi/Bases/ApiContractBases/RawApiContractBase.cs rename to HyPlayer.NeteaseApi/Bases/RawApiContractBases/RawApiContractBase.cs index e85c6d9..cfe2ae4 100644 --- a/HyPlayer.NeteaseApi/Bases/ApiContractBases/RawApiContractBase.cs +++ b/HyPlayer.NeteaseApi/Bases/RawApiContractBases/RawApiContractBase.cs @@ -2,7 +2,7 @@ using System.Text; using System.Text.Json; -namespace HyPlayer.NeteaseApi.Bases.ApiContractBases; +namespace HyPlayer.NeteaseApi.Bases.RawApiContractBases; public abstract class RawApiContractBase : ApiContractBase diff --git a/HyPlayer.NeteaseApi/Bases/WeApiActualRequestBase.cs b/HyPlayer.NeteaseApi/Bases/WeApiActualRequestBase.cs deleted file mode 100644 index 228e9b7..0000000 --- a/HyPlayer.NeteaseApi/Bases/WeApiActualRequestBase.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Text.Json.Serialization; - -namespace HyPlayer.NeteaseApi.Bases; - -public class WeApiActualRequestBase : ActualRequestBase -{ - [JsonPropertyName("csrf_token")] - public string? CsrfToken { get; set; } -} \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Bases/WeApiContractBases/WeApiActualRequestBase.cs b/HyPlayer.NeteaseApi/Bases/WeApiContractBases/WeApiActualRequestBase.cs new file mode 100644 index 0000000..5a1a690 --- /dev/null +++ b/HyPlayer.NeteaseApi/Bases/WeApiContractBases/WeApiActualRequestBase.cs @@ -0,0 +1,10 @@ +using HyPlayer.NeteaseApi.Bases.ApiContractBases; +using System.Text.Json.Serialization; + +namespace HyPlayer.NeteaseApi.Bases.WeApiContractBases; + +public class WeApiActualRequestBase : ActualRequestBase +{ + [JsonPropertyName("csrf_token")] + public string? CsrfToken { get; set; } +} \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Bases/ApiContractBases/WeApiContractBase.cs b/HyPlayer.NeteaseApi/Bases/WeApiContractBases/WeApiContractBase.cs similarity index 97% rename from HyPlayer.NeteaseApi/Bases/ApiContractBases/WeApiContractBase.cs rename to HyPlayer.NeteaseApi/Bases/WeApiContractBases/WeApiContractBase.cs index 4e4c521..00b87be 100644 --- a/HyPlayer.NeteaseApi/Bases/ApiContractBases/WeApiContractBase.cs +++ b/HyPlayer.NeteaseApi/Bases/WeApiContractBases/WeApiContractBase.cs @@ -1,9 +1,11 @@ -using HyPlayer.NeteaseApi.Extensions; +using HyPlayer.NeteaseApi.Bases.EApiContractBases; +using HyPlayer.NeteaseApi.Extensions; using System.Numerics; using System.Security.Cryptography; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; +using HyPlayer.NeteaseApi.Bases.WeApiContractBases; namespace HyPlayer.NeteaseApi.Bases.ApiContractBases; @@ -73,7 +75,8 @@ public override Task GenerateRequestMessageAsync() { { "params", paramsData }, @@ -134,8 +137,8 @@ public override async Task> ProcessResp private static byte[] RsaEncrypt(byte[] buffer, RSAParameters key) { return GetByteArrayBigEndian(BigInteger.ModPow(GetBigIntegerBigEndian(buffer), - GetBigIntegerBigEndian(key.Exponent), - GetBigIntegerBigEndian(key.Modulus))); + GetBigIntegerBigEndian(key.Exponent!), + GetBigIntegerBigEndian(key.Modulus!))); static byte[] GetByteArrayBigEndian(BigInteger value) { diff --git a/HyPlayer.NeteaseApi/Extensions/DictionaryExtension.cs b/HyPlayer.NeteaseApi/Extensions/DictionaryExtension.cs index 4f3518d..55d289d 100644 --- a/HyPlayer.NeteaseApi/Extensions/DictionaryExtension.cs +++ b/HyPlayer.NeteaseApi/Extensions/DictionaryExtension.cs @@ -2,7 +2,7 @@ public static class DictionaryExtension { - public static TValue? GetValueOrDefault(this Dictionary dictionary, TKey key, TValue? defaultValue = default) + public static TValue? GetValueOrDefault(this Dictionary dictionary, TKey key, TValue? defaultValue = default) where TKey : notnull { return dictionary.TryGetValue(key, out var value) ? value : defaultValue; } diff --git a/HyPlayer.NeteaseApi/Extensions/JsonSerializer/JsonBooleanConverter.cs b/HyPlayer.NeteaseApi/Extensions/JsonSerializer/JsonBooleanConverter.cs index ef975d8..f9427e8 100644 --- a/HyPlayer.NeteaseApi/Extensions/JsonSerializer/JsonBooleanConverter.cs +++ b/HyPlayer.NeteaseApi/Extensions/JsonSerializer/JsonBooleanConverter.cs @@ -23,9 +23,32 @@ public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSer throw new JsonException("Unexpected token type within BooleanConverter"); } } + public override bool ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case JsonTokenType.String: + return !(reader.GetString() == "false" || string.IsNullOrWhiteSpace(reader.GetString())); + case JsonTokenType.Number: + return reader.GetInt32() > 0; + case JsonTokenType.None: + case JsonTokenType.False: + case JsonTokenType.Null: + return false; + case JsonTokenType.True: + return true; + default: + throw new JsonException("Unexpected token type within BooleanConverter"); + } + } public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) { writer.WriteBooleanValue(value); } + + public override void WriteAsPropertyName(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) + { + writer.WritePropertyName(value.ToString()); + } } \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Extensions/JsonSerializer/JsonObjectStringConverter.cs b/HyPlayer.NeteaseApi/Extensions/JsonSerializer/JsonObjectStringConverter.cs index b4e7139..213cd05 100644 --- a/HyPlayer.NeteaseApi/Extensions/JsonSerializer/JsonObjectStringConverter.cs +++ b/HyPlayer.NeteaseApi/Extensions/JsonSerializer/JsonObjectStringConverter.cs @@ -33,6 +33,33 @@ public class JsonObjectStringConverter : JsonConverter throw new JsonException($"Unexpected token type: {reader.TokenType}"); } + public override JsonObjectStringWrapper ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType == JsonTokenType.String) + { + var value = reader.GetString(); + return new JsonObjectStringWrapper(value); + } + + if (reader.TokenType == JsonTokenType.StartObject) + { + var json = JsonDocument.ParseValue(ref reader).RootElement; + return new JsonObjectStringWrapper(json.ToString()); + } + + if (reader.TokenType == JsonTokenType.Null) + { + return new JsonObjectStringWrapper(null); + } + + if (reader.TokenType == JsonTokenType.Number) + { + return new JsonObjectStringWrapper(reader.GetInt64().ToString()); + } + + throw new JsonException($"Unexpected token type: {reader.TokenType}"); + } + public override void Write(Utf8JsonWriter writer, JsonObjectStringWrapper value, JsonSerializerOptions options) { if (value.Value == null) @@ -44,6 +71,17 @@ public override void Write(Utf8JsonWriter writer, JsonObjectStringWrapper value, writer.WriteStringValue(value.Value); } } + public override void WriteAsPropertyName(Utf8JsonWriter writer, JsonObjectStringWrapper value, JsonSerializerOptions options) + { + if (value.Value == null) + { + writer.WriteNullValue(); + } + else + { + writer.WritePropertyName(value.Value); + } + } } public class JsonObjectStringWrapper(string? value) diff --git a/HyPlayer.NeteaseApi/Extensions/JsonSerializer/NeteaseJsonSerializeContext.tt b/HyPlayer.NeteaseApi/Extensions/JsonSerializer/NeteaseJsonSerializeContext.tt new file mode 100644 index 0000000..2ec1b2c --- /dev/null +++ b/HyPlayer.NeteaseApi/Extensions/JsonSerializer/NeteaseJsonSerializeContext.tt @@ -0,0 +1,91 @@ +<#@ template debug="false" hostspecific="true" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Text.RegularExpressions" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ output extension="g.cs" #> +<# + var templateDirectory = Path.GetDirectoryName(Host.TemplateFile)!; + var folderPath = Path.GetFullPath(Path.Combine(templateDirectory, "../../ApiContracts")); + + var types = new HashSet(); + + // Predefined + // Dictionary + types.Add("System.Collections.Generic.Dictionary"); + types.Add("System.Collections.Generic.Dictionary"); + types.Add("System.String"); + types.Add("HyPlayer.NeteaseApi.Bases.ErrorResultBase"); + types.Add("HyPlayer.NeteaseApi.Bases.IdOrIdListListRequest"); + types.Add("HyPlayer.NeteaseApi.Bases.EApiContractBases.EApiActualRequestBase"); + types.Add("HyPlayer.NeteaseApi.Bases.EApiContractBases.CacheKeyEApiActualRequest"); + types.Add("HyPlayer.NeteaseApi.Bases.IdOrIdListListRequest"); + types.Add("HyPlayer.NeteaseApi.Bases.RawApiContractBases.RawApiActualRequestBase"); + types.Add("HyPlayer.NeteaseApi.Bases.WeApiContractBases.WeApiActualRequestBase"); + + + + if (Directory.Exists(folderPath)) + { + var files = Directory.EnumerateFiles(folderPath, "*.cs", SearchOption.AllDirectories); + + foreach (var file in files) + { + var fileContent = File.ReadAllText(file); + var nsMatch = Regex.Match(fileContent, @"namespace\s+HyPlayer\.NeteaseApi\.ApiContracts\.([\w\.]*)"); + if (!nsMatch.Success) continue; + + var subNamespace = nsMatch.Groups[1].Value; + var fullNamespace = string.IsNullOrEmpty(subNamespace) + ? "HyPlayer.NeteaseApi.ApiContracts" + : $"HyPlayer.NeteaseApi.ApiContracts.{subNamespace.TrimEnd('.')}"; + + + var typeMatches = Regex.Matches(fileContent, @"ApiContractBase\s*<\s*([\w\.]+)\s*,\s*([\w\.]+)\s*,\s*([\w\.]+)\s*,\s*([\w\.]+)\s*>"); + + foreach (Match m in typeMatches) + { + var requestType = m.Groups[4].Value; + var responseType = m.Groups[2].Value; + + types.Add(requestType.Contains(".") ? requestType : $"{fullNamespace}.{requestType}"); + types.Add(responseType.Contains(".") ? responseType : $"{fullNamespace}.{responseType}"); + } + + + // public class (.*?) : RequestBase + var requestMatches = Regex.Matches(fileContent, @"public\s+class\s+([\w]+)\s*:\s*(?:Coded)?ResponseBase"); + foreach (Match m in requestMatches) + { + var requestType = m.Groups[1].Value; + types.Add(requestType.Contains(".") ? requestType : $"{fullNamespace}.{requestType}"); + } + + + var manualSerializable = Regex.Matches(fileContent, @"\[\s*JsonContextSerializable\s*\(\s*typeof\s*\(\s*([\w\.]+)\s*\)\s*\)\s*\]"); + foreach (Match m in manualSerializable) + { + var requestType = m.Groups[1].Value; + types.Add(requestType.Contains(".") ? requestType : $"{fullNamespace}.{requestType}"); + } + } + } +#> +using System.Text.Json.Serialization; + +namespace HyPlayer.NeteaseApi.ApiContracts; + +<# foreach (var type in types) { #> +[JsonSerializable(typeof(<#= type #>))] +<# } #> +[JsonSourceGenerationOptions(WriteIndented = true)] +public partial class NeteaseApiContractJsonContext : JsonSerializerContext +{ +} + +[AttributeUsage(AttributeTargets.Class)] +public class JsonContextSerializable(Type type) : Attribute +{ + public Type Type { get; } = type; +} \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Extensions/JsonSerializer/NumberToStringConverter.cs b/HyPlayer.NeteaseApi/Extensions/JsonSerializer/NumberToStringConverter.cs index 5336d73..844b4b5 100644 --- a/HyPlayer.NeteaseApi/Extensions/JsonSerializer/NumberToStringConverter.cs +++ b/HyPlayer.NeteaseApi/Extensions/JsonSerializer/NumberToStringConverter.cs @@ -28,9 +28,25 @@ public class NumberToStringConverter : JsonConverter throw new JsonException("Unexpected token type within NumberToStringConverter"); } } + public override string ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType == JsonTokenType.PropertyName) + { + return reader.GetString()!; + } + else + { + throw new JsonException("Unexpected token type within NumberToStringConverter"); + } + } public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) { writer.WriteStringValue(value); } + + public override void WriteAsPropertyName(Utf8JsonWriter writer, string value, JsonSerializerOptions options) + { + writer.WritePropertyName(value); + } } \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/Extensions/NeteaseUtils.cs b/HyPlayer.NeteaseApi/Extensions/NeteaseUtils.cs index 29866a6..69198f0 100644 --- a/HyPlayer.NeteaseApi/Extensions/NeteaseUtils.cs +++ b/HyPlayer.NeteaseApi/Extensions/NeteaseUtils.cs @@ -36,4 +36,17 @@ public static string GetCacheKey(string input) var result = encryptor.TransformFinalBlock(buffer, 0, buffer.Length); return Convert.ToBase64String(result); } + + public static string GetDeviceId(string? imei = null, string? mac = null, string? androidId = null, string? localId = null) + { + if (string.IsNullOrEmpty(imei)) imei = "null"; + if (string.IsNullOrEmpty(mac)) imei = "02:00:00:00:00:00"; + if (string.IsNullOrEmpty(androidId)) androidId = Guid.NewGuid().ToString("N").Substring(0, 16); + if (string.IsNullOrEmpty(localId)) localId = "null"; + + var input = $"{imei}\t{mac}\t{androidId}\t{localId}"; + var bytes = Encoding.UTF8.GetBytes(input); + var base64 = Convert.ToBase64String(bytes); + return Uri.EscapeDataString(base64); + } } \ No newline at end of file diff --git a/HyPlayer.NeteaseApi/HyPlayer.NeteaseApi.csproj b/HyPlayer.NeteaseApi/HyPlayer.NeteaseApi.csproj index 8f3c35a..ddba30e 100644 --- a/HyPlayer.NeteaseApi/HyPlayer.NeteaseApi.csproj +++ b/HyPlayer.NeteaseApi/HyPlayer.NeteaseApi.csproj @@ -1,7 +1,6 @@  - netstandard2.0 enable enable default @@ -14,10 +13,15 @@ git 0.1.0 0.1.0 + netstandard2.0;net9.0;net10.0 + IL2026;IL3050 + true + AnyCPU;x64 - + + @@ -30,10 +34,31 @@ + + + + + True + True + NeteaseJsonSerializeContext.tt + + + True + True + NeteaseJsonSerializeContext.tt + + + + + + + TextTemplatingFileGenerator + NeteaseJsonSerializeContext.g.cs + diff --git a/HyPlayer.NeteaseApi/NeteaseCloudMusicApiHandler.cs b/HyPlayer.NeteaseApi/NeteaseCloudMusicApiHandler.cs index 7dc6e86..4447284 100644 --- a/HyPlayer.NeteaseApi/NeteaseCloudMusicApiHandler.cs +++ b/HyPlayer.NeteaseApi/NeteaseCloudMusicApiHandler.cs @@ -1,4 +1,5 @@ using HyPlayer.NeteaseApi.Bases; +using HyPlayer.NeteaseApi.Bases.ApiContractBases; using HyPlayer.NeteaseApi.Extensions; using System.Net; @@ -35,6 +36,7 @@ public async Task> RequestAsync - net8.0 + net9.0 enable enable - false + true + preview + Exe + win-x64 + true + true + true - - - + + diff --git a/HyPlayer.NeteaseProvider.Tests/NeteaseApisTests.cs b/HyPlayer.NeteaseProvider.Tests/NeteaseApisTests.cs index 80011a3..803a1a4 100644 --- a/HyPlayer.NeteaseProvider.Tests/NeteaseApisTests.cs +++ b/HyPlayer.NeteaseProvider.Tests/NeteaseApisTests.cs @@ -1,10 +1,9 @@ #region -using FluentAssertions; +using AwesomeAssertions; using HyPlayer.NeteaseApi.ApiContracts; using HyPlayer.NeteaseApi.ApiContracts.Album; using HyPlayer.NeteaseApi.ApiContracts.Artist; -using HyPlayer.NeteaseApi.ApiContracts.Category; using HyPlayer.NeteaseApi.ApiContracts.Cloud; using HyPlayer.NeteaseApi.ApiContracts.Comment; using HyPlayer.NeteaseApi.ApiContracts.DjChannel; @@ -14,6 +13,7 @@ using HyPlayer.NeteaseApi.ApiContracts.Recommend; using HyPlayer.NeteaseApi.ApiContracts.Song; using HyPlayer.NeteaseApi.ApiContracts.User; +using HyPlayer.NeteaseApi.ApiContracts.Utils; using HyPlayer.NeteaseApi.ApiContracts.Video; using HyPlayer.NeteaseApi.Bases; using HyPlayer.NeteaseApi.Models; @@ -326,7 +326,7 @@ public async Task ListenFirstInfo_Should_BeNormal(string songId) } // [Test] - public async Task LoginCellphone_Should_LoginWithInfo(string phone, string password) + private async Task LoginCellphone_Should_LoginWithInfo(string phone, string password) { var result = await _provider.RequestAsync(NeteaseApis.LoginCellphoneApi, @@ -347,7 +347,7 @@ await _provider.RequestAsync(NeteaseApis.LoginCellphoneApi, } //[Test] - public async Task LoginEmail_Should_LoginWithInfo(string email, string password) + private async Task LoginEmail_Should_LoginWithInfo(string email, string password) { var result = await _provider.RequestAsync(NeteaseApis.LoginEmailApi, new LoginEmailRequest @@ -368,9 +368,9 @@ public async Task LoginEmail_Should_LoginWithInfo(string email, string password) // [Test] // [DependsOn(nameof(LoginQrCodeUnikey_Should_BeNormal))] - public async Task LoginQrCodeCheck_Should_BeNormal() + private async Task LoginQrCodeCheck_Should_BeNormal() { - var unikey = TestContext.Current!.ObjectBag["unikey"] as string; + var unikey = TestContext.Current!.StateBag["unikey"] as string; var result = await _provider.RequestAsync(NeteaseApis.LoginQrCodeCheckApi, new LoginQrCodeCheckRequest { Unikey = unikey! @@ -380,12 +380,12 @@ public async Task LoginQrCodeCheck_Should_BeNormal() } // [Test] - public async Task LoginQrCodeUnikey_Should_BeNormal() + private async Task LoginQrCodeUnikey_Should_BeNormal() { var result = await _provider.RequestAsync(NeteaseApis.LoginQrCodeUnikeyApi, new LoginQrCodeUnikeyRequest()); result.Match(s => s.Code.Should().Be(200), e => throw e); - TestContext.Current!.ObjectBag["unikey"] = result.Value?.Unikey; + TestContext.Current!.StateBag["unikey"] = result.Value?.Unikey; } // LoginStatusApi @@ -777,7 +777,7 @@ public async Task UserDetail_Should_BeNormal(string id) // [Arguments("8645419738", UserRecordType.WeekData)] // TODO: uncomment this line when the test account's weekly listen record accumulates public async Task UserRecordApi_Should_BeNormal(string id, UserRecordType type) { - var result = + var result = await _provider .RequestAsync(NeteaseApis.UserRecordApi, new UserRecordRequest diff --git a/HyPlayer.NeteaseProvider/HyPlayer.NeteaseProvider.csproj b/HyPlayer.NeteaseProvider/HyPlayer.NeteaseProvider.csproj index afcbf2a..2625eb7 100644 --- a/HyPlayer.NeteaseProvider/HyPlayer.NeteaseProvider.csproj +++ b/HyPlayer.NeteaseProvider/HyPlayer.NeteaseProvider.csproj @@ -14,7 +14,8 @@ git 0.0.11 0.0.11 - netstandard2.0 + netstandard2.0;net9.0 + true diff --git a/HyPlayer.NeteaseProvider/Mappers/RadioChannelToNeteaseRadioChannelMapper.cs b/HyPlayer.NeteaseProvider/Mappers/RadioChannelToNeteaseRadioChannelMapper.cs index 47e0abb..0910d64 100644 --- a/HyPlayer.NeteaseProvider/Mappers/RadioChannelToNeteaseRadioChannelMapper.cs +++ b/HyPlayer.NeteaseProvider/Mappers/RadioChannelToNeteaseRadioChannelMapper.cs @@ -11,7 +11,7 @@ public static NeteaseRadioChannel MapToNeteaseRadioChannel(this DjRadioChannelDt return new NeteaseRadioChannel { ActualId = radioChannel.Id, - Name = radioChannel.Name, + Name = radioChannel.Name ?? "", Description = radioChannel.Description, }; } diff --git a/HyPlayer.NeteaseProvider/Mappers/VideoItemToNeteaseVideoMapper.cs b/HyPlayer.NeteaseProvider/Mappers/VideoItemToNeteaseVideoMapper.cs index 67906f1..02e4a80 100644 --- a/HyPlayer.NeteaseProvider/Mappers/VideoItemToNeteaseVideoMapper.cs +++ b/HyPlayer.NeteaseProvider/Mappers/VideoItemToNeteaseVideoMapper.cs @@ -12,7 +12,7 @@ public static NeteaseVideo MapToNeteaseVideo(this VideoDto videoItem) return new NeteaseVideo { ActualId = videoItem.Id, - Name = videoItem.Title, + Name = videoItem.Title ?? "", }; } } \ No newline at end of file diff --git a/HyPlayer.NeteaseProvider/Models/NeteaseArtistSubContainer.cs b/HyPlayer.NeteaseProvider/Models/NeteaseArtistSubContainer.cs index e29ab58..3c061da 100644 --- a/HyPlayer.NeteaseProvider/Models/NeteaseArtistSubContainer.cs +++ b/HyPlayer.NeteaseProvider/Models/NeteaseArtistSubContainer.cs @@ -34,7 +34,7 @@ public class NeteaseArtistSubContainer : LinerContainerBase, IProgressiveLoading }); return result.Match( success => - success.Songs.Select(song => (ProvidableItemBase)song.MapToNeteaseMusic()).ToList(), + success.Songs?.Select(song => (ProvidableItemBase)song.MapToNeteaseMusic()).ToList() ?? [], error => new List() ); case "tim": @@ -49,7 +49,7 @@ public class NeteaseArtistSubContainer : LinerContainerBase, IProgressiveLoading }); return resTime.Match( success => - success.Songs.Select(song => (ProvidableItemBase)song.MapToNeteaseMusic()).ToList(), + success.Songs?.Select(song => (ProvidableItemBase)song.MapToNeteaseMusic()).ToList() ?? [], error => new List() ); case "alb": diff --git a/HyPlayer.NeteaseProvider/Models/NeteaseImageResource.cs b/HyPlayer.NeteaseProvider/Models/NeteaseImageResource.cs index eb677eb..81fce7a 100644 --- a/HyPlayer.NeteaseProvider/Models/NeteaseImageResource.cs +++ b/HyPlayer.NeteaseProvider/Models/NeteaseImageResource.cs @@ -7,12 +7,12 @@ public class NeteaseImageResource : ImageResourceBase { public override Task GetResourceAsync(ResourceQualityTag? qualityTag = null, CancellationToken ctk = default) { - return Task.FromResult(new NeteaseImageResourceResult + return Task.FromResult(new NeteaseImageResourceResult { ExternalException = null, ResourceStatus = ResourceStatus.Success, - Uri = new Uri(Uri, $"?{qualityTag?.ToString()}") - } as ResourceResultBase); + Uri = new Uri(Uri!, $"?{qualityTag}") + }); } } public class NeteaseImageResourceResult : ResourceResultBase, IResourceResultOf diff --git a/HyPlayer.NeteaseProvider/Models/NeteaseSearchContainer.cs b/HyPlayer.NeteaseProvider/Models/NeteaseSearchContainer.cs index 7093a8f..9b2b517 100644 --- a/HyPlayer.NeteaseProvider/Models/NeteaseSearchContainer.cs +++ b/HyPlayer.NeteaseProvider/Models/NeteaseSearchContainer.cs @@ -94,7 +94,7 @@ public NeteaseSearchContainer() Offset = start }, ctk); return albumResult.Match(success => (success.Result?.Count > start + count, success.Result?.Items - ?.Select(t => (ProvidableItemBase)t.MapToNeteaseAlbum()) + ?.Select(ProvidableItemBase (t) => t.MapToNeteaseAlbum()!) .ToList() ?? new()), _ => (false, new())); case NeteaseResourceType.Artist: @@ -130,7 +130,6 @@ public NeteaseSearchContainer() ?.Select(t => (ProvidableItemBase)t.MapToNeteaseRadioChannel()) .ToList() ?? new()), _ => (false, new())); - break; case NeteaseResourceType.Video: case NeteaseResourceType.MLog: var videoResult = await NeteaseProvider.Instance @@ -148,8 +147,7 @@ public NeteaseSearchContainer() ?.Select(t => (ProvidableItemBase)t.MapToNeteaseVideo()) .ToList() ?? new()), _ => (false, new())); - - break; + case NeteaseResourceType.User: var userResult = await NeteaseProvider.Instance .RequestAsync (ProvidableItemBase)t.MapToNeteaseUser()) .ToList() ?? new()), _ => (false, new())); - break; case NeteaseResourceType.Lyric: var lyricResult = await NeteaseProvider.Instance .RequestAsync (ProvidableItemBase)t.MapNeteaseLyricSearchItem()) .ToList() ?? new()), _ => (false, new())); - break; default: throw new NotImplementedException(); } diff --git a/HyPlayer.NeteaseProvider/NeteaseProvider.cs b/HyPlayer.NeteaseProvider/NeteaseProvider.cs index 7371bb5..baa20f4 100644 --- a/HyPlayer.NeteaseProvider/NeteaseProvider.cs +++ b/HyPlayer.NeteaseProvider/NeteaseProvider.cs @@ -5,6 +5,7 @@ using HyPlayer.NeteaseApi.ApiContracts.Recommend; using HyPlayer.NeteaseApi.ApiContracts.Song; using HyPlayer.NeteaseApi.Bases; +using HyPlayer.NeteaseApi.Bases.ApiContractBases; using HyPlayer.NeteaseProvider.Constants; using HyPlayer.NeteaseProvider.Mappers; using HyPlayer.NeteaseProvider.Models; @@ -236,7 +237,7 @@ public async Task LoginCellphoneAsync(string cellphone, string password, b Time = response.SongUrls[0].Time, MusicType = response.SongUrls[0].Type, Level = response.SongUrls[0].Level, - Uri = new Uri(response.SongUrls[0].Url) + Uri = new Uri(response.SongUrls[0].Url ?? string.Empty) }; } diff --git a/global.json b/global.json index f4fd385..d77dcfd 100644 --- a/global.json +++ b/global.json @@ -2,6 +2,9 @@ "sdk": { "version": "9.0.0", "rollForward": "latestMajor", - "allowPrerelease": true + "allowPrerelease": false + }, + "test": { + "runner": "Microsoft.Testing.Platform" } } \ No newline at end of file