From f19d9ec1e506773e4829b4fd77a8b3a346b54e13 Mon Sep 17 00:00:00 2001 From: Harlan_H <370256750@qq.com> Date: Sun, 20 Aug 2023 17:00:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E8=AF=BB=E5=8F=96=E6=97=B6=E4=B8=8B=E8=BD=BD=E9=80=9F?= =?UTF-8?q?=E7=8E=87=E4=B8=BA0=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=BA=9B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extensions/HttpClientExtension.cs | 25 +++++++++++++++++++ .../Utils/HandleImageStream.cs | 5 +++- .../ViewModels/MainWindowViewModel.cs | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/M3u8Downloader_H.Common/Extensions/HttpClientExtension.cs b/M3u8Downloader_H.Common/Extensions/HttpClientExtension.cs index b3933da..ccecc15 100644 --- a/M3u8Downloader_H.Common/Extensions/HttpClientExtension.cs +++ b/M3u8Downloader_H.Common/Extensions/HttpClientExtension.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Net.Http; +using System.Text; using System.Threading; using System.Threading.Tasks; @@ -80,5 +81,29 @@ public static async Task GetStringAsync(this HttpClient httpClient,Uri u return await httpClient.GetStringAsync(request, cancellationToken); } + + public static async Task PostStringAsync(this HttpClient httpClient, Uri uri, string payload, IEnumerable>? headers = default, CancellationToken cancellationToken = default) + { + using HttpRequestMessage request = new(HttpMethod.Post, uri); + request.AddHeaders(headers); + request.Content = new StringContent(payload, Encoding.UTF8, "application/x-www-form-urlencoded"); + + HttpResponseMessage response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); + response.EnsureSuccessStatusCode(); + + return await response.Content.ReadAsStringAsync(cancellationToken); + } + + public static async Task PostJsonAsync(this HttpClient httpClient, Uri uri, string payload, IEnumerable>? headers = default, CancellationToken cancellationToken = default) + { + using HttpRequestMessage request = new(HttpMethod.Post, uri); + request.AddHeaders(headers); + request.Content = new StringContent(payload, Encoding.UTF8, "application/json"); + + HttpResponseMessage response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); + response.EnsureSuccessStatusCode(); + + return await response.Content.ReadAsStringAsync(cancellationToken); + } } } diff --git a/M3u8Downloader_H.Core/Utils/HandleImageStream.cs b/M3u8Downloader_H.Core/Utils/HandleImageStream.cs index 188ce15..f88e5c6 100644 --- a/M3u8Downloader_H.Core/Utils/HandleImageStream.cs +++ b/M3u8Downloader_H.Core/Utils/HandleImageStream.cs @@ -114,7 +114,10 @@ public override void Write(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count) { - return stream.Read(buffer, offset, count); + int bytesRead = stream.Read(buffer, offset, count); + _position += bytesRead; + _downloadrate?.Report(bytesRead); + return bytesRead; } } } diff --git a/M3u8Downloader_H/ViewModels/MainWindowViewModel.cs b/M3u8Downloader_H/ViewModels/MainWindowViewModel.cs index be82cf9..e035501 100644 --- a/M3u8Downloader_H/ViewModels/MainWindowViewModel.cs +++ b/M3u8Downloader_H/ViewModels/MainWindowViewModel.cs @@ -158,7 +158,7 @@ private void ProcessDownload(Uri uri, string? name,string? method,string? key,st : string.IsNullOrWhiteSpace(settingsService.PluginKey) ? uri.GetHostName() : settingsService.PluginKey; - DownloadViewModel download = DownloadViewModel.CreateDownloadViewModel(uri, tmpVideoName,method,key,iv, headers, fileFullPath, pluginService[tmpPluginKey]); + DownloadViewModel download = DownloadViewModel.CreateDownloadViewModel(uri, tmpVideoName,method,key,iv, headers ?? settingsService.Headers?.ToDictionary(), fileFullPath, pluginService[tmpPluginKey]); if (download is null) return; EnqueueDownload(download); From db8bd4b2dd74b3d802b7d83d22a5ae96eade1e29 Mon Sep 17 00:00:00 2001 From: Harlan_H <370256750@qq.com> Date: Sun, 20 Aug 2023 17:01:18 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=88=B03.13.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- M3u8Downloader_H.Core/M3u8Downloader_H.Core.csproj | 4 ++-- M3u8Downloader_H.M3U8/M3u8Downloader_H.M3U8.csproj | 4 ++-- .../M3u8Downloader_H.PluginManager.csproj | 2 +- M3u8Downloader_H/M3u8Downloader_H.csproj | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/M3u8Downloader_H.Core/M3u8Downloader_H.Core.csproj b/M3u8Downloader_H.Core/M3u8Downloader_H.Core.csproj index 77743d1..3ebf3c1 100644 --- a/M3u8Downloader_H.Core/M3u8Downloader_H.Core.csproj +++ b/M3u8Downloader_H.Core/M3u8Downloader_H.Core.csproj @@ -3,9 +3,9 @@ net6.0 enable - 3.13.4.0 + 3.13.5.0 Harlan - 3.13.4.0 + 3.13.5.0 diff --git a/M3u8Downloader_H.M3U8/M3u8Downloader_H.M3U8.csproj b/M3u8Downloader_H.M3U8/M3u8Downloader_H.M3U8.csproj index 563210f..11181ab 100644 --- a/M3u8Downloader_H.M3U8/M3u8Downloader_H.M3U8.csproj +++ b/M3u8Downloader_H.M3U8/M3u8Downloader_H.M3U8.csproj @@ -3,8 +3,8 @@ net6.0 enable - 3.13.4.0 - 3.13.4.0 + 3.13.5.0 + 3.13.5.0 diff --git a/M3u8Downloader_H.PluginManager/M3u8Downloader_H.PluginManager.csproj b/M3u8Downloader_H.PluginManager/M3u8Downloader_H.PluginManager.csproj index 371ae53..20e34c6 100644 --- a/M3u8Downloader_H.PluginManager/M3u8Downloader_H.PluginManager.csproj +++ b/M3u8Downloader_H.PluginManager/M3u8Downloader_H.PluginManager.csproj @@ -5,7 +5,7 @@ net6.0-windows enable true - 3.13.4.0 + 3.13.5.0 icon.ico diff --git a/M3u8Downloader_H/M3u8Downloader_H.csproj b/M3u8Downloader_H/M3u8Downloader_H.csproj index ce858ce..18ba53c 100644 --- a/M3u8Downloader_H/M3u8Downloader_H.csproj +++ b/M3u8Downloader_H/M3u8Downloader_H.csproj @@ -7,8 +7,8 @@ true M3u8Downloader_H AnyCPU;x64 - 3.13.4.0 - 3.13.4.0 + 3.13.5.0 + 3.13.5.0 m3u8视频下载器 m3u8视频下载器 icon.ico From f2032abe124b18e8e8f19cc2a5e0d6df671f4be6 Mon Sep 17 00:00:00 2001 From: Harlan_H <370256750@qq.com> Date: Sun, 20 Aug 2023 17:03:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=B8=BA=E8=A1=A5=E4=B8=81=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=BA=93=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- M3u8Downloader_H.Common/M3u8Downloader_H.Common.csproj | 1 + .../M3u8Downloader_H.Plugin.Abstractions.csproj | 1 + M3u8Downloader_H.Plugin/M3u8Downloader_H.Plugin.csproj | 1 + 3 files changed, 3 insertions(+) diff --git a/M3u8Downloader_H.Common/M3u8Downloader_H.Common.csproj b/M3u8Downloader_H.Common/M3u8Downloader_H.Common.csproj index f7af7d4..78e9d98 100644 --- a/M3u8Downloader_H.Common/M3u8Downloader_H.Common.csproj +++ b/M3u8Downloader_H.Common/M3u8Downloader_H.Common.csproj @@ -4,6 +4,7 @@ net6.0 enable enable + 1.0.1.0 diff --git a/M3u8Downloader_H.Plugin.Abstractions/M3u8Downloader_H.Plugin.Abstractions.csproj b/M3u8Downloader_H.Plugin.Abstractions/M3u8Downloader_H.Plugin.Abstractions.csproj index 334c83d..e78dbc9 100644 --- a/M3u8Downloader_H.Plugin.Abstractions/M3u8Downloader_H.Plugin.Abstractions.csproj +++ b/M3u8Downloader_H.Plugin.Abstractions/M3u8Downloader_H.Plugin.Abstractions.csproj @@ -4,6 +4,7 @@ net6.0 enable enable + 1.0.1.0 diff --git a/M3u8Downloader_H.Plugin/M3u8Downloader_H.Plugin.csproj b/M3u8Downloader_H.Plugin/M3u8Downloader_H.Plugin.csproj index c280b5f..d345b02 100644 --- a/M3u8Downloader_H.Plugin/M3u8Downloader_H.Plugin.csproj +++ b/M3u8Downloader_H.Plugin/M3u8Downloader_H.Plugin.csproj @@ -4,6 +4,7 @@ net6.0 enable enable + 1.0.1.0