From 9549c6d282a6d4e125e6f93ee1fb22a338a8db84 Mon Sep 17 00:00:00 2001 From: Linwenxuan Date: Sat, 24 Feb 2024 04:23:21 +0800 Subject: [PATCH] [Core] Refactored RecordDownloadService.cs and VideoDownloadService.cs --- .../OidbSvcTrpcTcp0x1026_200Response.cs | 36 ------------------- .../Service/Message/RecordDownloadService.cs | 7 ++-- .../Service/Message/VideoDownloadService.cs | 8 ++--- 3 files changed, 6 insertions(+), 45 deletions(-) delete mode 100644 Lagrange.Core/Internal/Packets/Service/Oidb/Response/OidbSvcTrpcTcp0x1026_200Response.cs diff --git a/Lagrange.Core/Internal/Packets/Service/Oidb/Response/OidbSvcTrpcTcp0x1026_200Response.cs b/Lagrange.Core/Internal/Packets/Service/Oidb/Response/OidbSvcTrpcTcp0x1026_200Response.cs deleted file mode 100644 index 71e5e7535..000000000 --- a/Lagrange.Core/Internal/Packets/Service/Oidb/Response/OidbSvcTrpcTcp0x1026_200Response.cs +++ /dev/null @@ -1,36 +0,0 @@ -using ProtoBuf; - -namespace Lagrange.Core.Internal.Packets.Service.Oidb.Response; - -// Resharper disable InconsistentNaming -#pragma warning disable CS8618 - -[ProtoContract] -internal class OidbSvcTrpcTcp0x1026_200Response -{ - [ProtoMember(3)] public OidbSvcTrpcTcp0x1026_100ResponseBody Body { get; set; } -} - -[ProtoContract] -internal class OidbSvcTrpcTcp0x1026_100ResponseBody -{ - [ProtoMember(1)] public string DownloadParams { get; set; } - - [ProtoMember(2)] public uint ExpireTime { get; set; } - - [ProtoMember(3)] public OidbSvcTrpcTcp0x1026_100ResponseBodyField3 Field3 { get; set; } -} - -[ProtoContract] -internal class OidbSvcTrpcTcp0x1026_100ResponseBodyField3 -{ - [ProtoMember(1)] public string Domain { get; set; } - - [ProtoMember(2)] public string Suffix { get; set; } - - [ProtoMember(3)] public uint Port { get; set; } - - // [ProtoMember(4)] - - // [ProtoMember(5)] -} \ No newline at end of file diff --git a/Lagrange.Core/Internal/Service/Message/RecordDownloadService.cs b/Lagrange.Core/Internal/Service/Message/RecordDownloadService.cs index dcfb31a0e..0ee092296 100644 --- a/Lagrange.Core/Internal/Service/Message/RecordDownloadService.cs +++ b/Lagrange.Core/Internal/Service/Message/RecordDownloadService.cs @@ -3,7 +3,6 @@ using Lagrange.Core.Internal.Event.Message; using Lagrange.Core.Internal.Packets.Service.Oidb; using Lagrange.Core.Internal.Packets.Service.Oidb.Common; -using Lagrange.Core.Internal.Packets.Service.Oidb.Response; using Lagrange.Core.Utility.Binary; using Lagrange.Core.Utility.Extension; using ProtoBuf; @@ -90,9 +89,9 @@ protected override bool Build(RecordDownloadEvent input, BotKeystore keystore, B protected override bool Parse(byte[] input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, out RecordDownloadEvent output, out List? extraEvents) { - var payload = Serializer.Deserialize>(input.AsSpan()); - var body = payload.Body.Body; - string url = $"https://{body.Field3.Domain}{body.Field3.Suffix}{body.DownloadParams}"; + var payload = Serializer.Deserialize>(input.AsSpan()); + var body = payload.Body.Download; + string url = $"https://{body.Info.Domain}{body.Info.UrlPath}{body.RKeyParam}"; output = RecordDownloadEvent.Result((int)payload.ErrorCode, url); extraEvents = null; diff --git a/Lagrange.Core/Internal/Service/Message/VideoDownloadService.cs b/Lagrange.Core/Internal/Service/Message/VideoDownloadService.cs index 9a5de3840..147a13d90 100644 --- a/Lagrange.Core/Internal/Service/Message/VideoDownloadService.cs +++ b/Lagrange.Core/Internal/Service/Message/VideoDownloadService.cs @@ -3,8 +3,6 @@ using Lagrange.Core.Internal.Event.Message; using Lagrange.Core.Internal.Packets.Service.Oidb; using Lagrange.Core.Internal.Packets.Service.Oidb.Common; -using Lagrange.Core.Internal.Packets.Service.Oidb.Request; -using Lagrange.Core.Internal.Packets.Service.Oidb.Response; using Lagrange.Core.Utility.Binary; using Lagrange.Core.Utility.Extension; using ProtoBuf; @@ -91,9 +89,9 @@ protected override bool Build(VideoDownloadEvent input, BotKeystore keystore, Bo protected override bool Parse(byte[] input, BotKeystore keystore, BotAppInfo appInfo, BotDeviceInfo device, out VideoDownloadEvent output, out List? extraEvents) { - var payload = Serializer.Deserialize>(input.AsSpan()); - var body = payload.Body.Body; - string url = $"https://{body.Field3.Domain}{body.Field3.Suffix}{body.DownloadParams}"; + var payload = Serializer.Deserialize>(input.AsSpan()); + var body = payload.Body.Download; + string url = $"https://{body.Info.Domain}{body.Info.UrlPath}{body.RKeyParam}"; output = VideoDownloadEvent.Result((int)payload.ErrorCode, url); extraEvents = null;