Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Harlan-H committed Aug 20, 2023
2 parents 470430f + f2032ab commit d81df78
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 9 deletions.
25 changes: 25 additions & 0 deletions M3u8Downloader_H.Common/Extensions/HttpClientExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -80,5 +81,29 @@ public static async Task<string> GetStringAsync(this HttpClient httpClient,Uri u

return await httpClient.GetStringAsync(request, cancellationToken);
}

public static async Task<string> PostStringAsync(this HttpClient httpClient, Uri uri, string payload, IEnumerable<KeyValuePair<string, string>>? 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<string> PostJsonAsync(this HttpClient httpClient, Uri uri, string payload, IEnumerable<KeyValuePair<string, string>>? 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);
}
}
}
1 change: 1 addition & 0 deletions M3u8Downloader_H.Common/M3u8Downloader_H.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.0.1.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
4 changes: 2 additions & 2 deletions M3u8Downloader_H.Core/M3u8Downloader_H.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>3.13.4.0</Version>
<Version>3.13.5.0</Version>
<Authors>Harlan</Authors>
<AssemblyVersion>3.13.4.0</AssemblyVersion>
<AssemblyVersion>3.13.5.0</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
5 changes: 4 additions & 1 deletion M3u8Downloader_H.Core/Utils/HandleImageStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
4 changes: 2 additions & 2 deletions M3u8Downloader_H.M3U8/M3u8Downloader_H.M3U8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<AssemblyVersion>3.13.4.0</AssemblyVersion>
<Version>3.13.4.0</Version>
<AssemblyVersion>3.13.5.0</AssemblyVersion>
<Version>3.13.5.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.0.1.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
1 change: 1 addition & 0 deletions M3u8Downloader_H.Plugin/M3u8Downloader_H.Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.0.1.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<Version>3.13.4.0</Version>
<Version>3.13.5.0</Version>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions M3u8Downloader_H/M3u8Downloader_H.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<UseWindowsForms>true</UseWindowsForms>
<RootNamespace>M3u8Downloader_H</RootNamespace>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyVersion>3.13.4.0</AssemblyVersion>
<Version>3.13.4.0</Version>
<AssemblyVersion>3.13.5.0</AssemblyVersion>
<Version>3.13.5.0</Version>
<PackageId>m3u8视频下载器</PackageId>
<Product>m3u8视频下载器</Product>
<ApplicationIcon>icon.ico</ApplicationIcon>
Expand Down
2 changes: 1 addition & 1 deletion M3u8Downloader_H/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d81df78

Please sign in to comment.