Skip to content

Commit 1e8f9de

Browse files
committed
Merge branch 'develop'
2 parents bd9bd20 + 61a178c commit 1e8f9de

File tree

66 files changed

+422
-526
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+422
-526
lines changed

.github/workflows/main.yml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ jobs:
2424
- name: Install .NET
2525
uses: actions/setup-dotnet@v3
2626
with:
27-
dotnet-version: 6.0.x
27+
dotnet-version: 9.0.x
2828

2929
- name: Publish
3030
run: |
3131
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/Publish --configuration Release
32-
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/PublishSingleFile -c Release --self-contained true -r win7-x64 -p:PublishSingleFile=true
32+
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/PublishSingleFile -c Release --self-contained true -r win-x64 -p:PublishSingleFile=true
3333
34-
- name: Download .NET 6 SDK And Copy .NET 6 SDK
34+
- name: Download .NET 9 SDK And Copy .NET 9 SDK
3535
run: |
36-
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/d0849e66-227d-40f7-8f7b-c3f7dfe51f43/37f8a04ab7ff94db7f20d3c598dc4d74/windowsdesktop-runtime-6.0.29-win-x64.exe' -OutFile 'dotnet-sdk-win-x64.exe'
37-
Copy-Item dotnet-sdk-win-x64.exe M3u8Downloader_H/bin/Publish -Recurse
36+
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/99bd07c2-c95c-44dc-9d47-36d3b18df240/bdf26c62f69c1b783687c1dce83ccf7a/dotnet-runtime-9.0.0-win-x64.exe' -OutFile 'dotnet-9.0-runtime-x64.exe'
37+
Copy-Item dotnet-9.0-runtime-x64.exe M3u8Downloader_H/bin/Publish -Recurse
3838
3939
- name: Upload artifacts normal
4040
uses: actions/upload-artifact@v3
@@ -71,12 +71,32 @@ jobs:
7171
Compress-Archive -Path M3u8Downloader_H/* -DestinationPath M3u8Downloader_H.zip -Force
7272
Compress-Archive -Path M3u8Downloader_H-SingleFile/* -DestinationPath M3u8Downloader_H-SingleFile.zip -Force
7373
shell: pwsh
74+
75+
- name: Get Releases Descript
76+
id : get_desc
77+
run: |
78+
curl -Lo changlog.md https://raw.githubusercontent.com/Harlan-H/M3u8Downloader_H/refs/heads/master/Changelog.md
79+
result=$(awk '/^# /{if (flag) exit; flag=1} flag && NF' changlog.md)
80+
echo "release_body<<EOF" >> $GITHUB_OUTPUT
81+
echo "$result" >> $GITHUB_OUTPUT
82+
echo "EOF" >> $GITHUB_OUTPUT
7483
7584
- name: Create release
7685
uses: softprops/action-gh-release@v1
7786
with:
7887
body: |
79-
- [更新日志](https://github.com/Harlan-H/M3u8Downloader_H/blob/master/Changelog.md)
88+
${{ steps.get_desc.outputs.release_body }}
89+
90+
#
91+
- [更多更新内容](https://github.com/Harlan-H/M3u8Downloader_H/blob/master/Changelog.md)
92+
93+
#
94+
| 名称 | 描述 |
95+
|-------|-------|
96+
| [m3u8Downloader_H.zip](https://github.com/Harlan-H/M3u8Downloader_H/releases/download/${{github.ref_name}}/M3u8Downloader_H.zip) | 需要运行库版本,程序文件夹中的dotnet-9.0-runtime-x64.exe |
97+
| [M3u8Downloader_H-SingleFile.zip](https://github.com/Harlan-H/M3u8Downloader_H/releases/download/${{github.ref_name}}/M3u8Downloader_H-SingleFile.zip) | 无需运行库版本,可能某些功能无法使用 |
98+
- 如果你是win7用户且程序双击没反应 那么就必须安装KB4457144 [跳转环境问题](https://github.com/Harlan-H/M3u8Downloader_H/wiki#%E7%8E%AF%E5%A2%83%E9%97%AE%E9%A2%98)
99+
80100
draft: false
81101
prerelease: false
82102
files: |

.github/workflows/manual.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: main
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tags:
7+
description: '版本号'
8+
required: true
9+
10+
jobs:
11+
package:
12+
runs-on: windows-latest
13+
14+
env:
15+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
16+
DOTNET_NOLOGO: true
17+
DOTNET_CLI_TELEMETRY_OPTOUT: true
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Install .NET
24+
uses: actions/setup-dotnet@v3
25+
with:
26+
dotnet-version: 9.0.x
27+
28+
- name: Publish
29+
run: |
30+
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/Publish --configuration Release
31+
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/PublishSingleFile -c Release --self-contained true -r win-x64 -p:PublishSingleFile=true
32+
33+
- name: Download .NET 9 SDK And Copy .NET 9 SDK
34+
run: |
35+
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/99bd07c2-c95c-44dc-9d47-36d3b18df240/bdf26c62f69c1b783687c1dce83ccf7a/dotnet-runtime-9.0.0-win-x64.exe' -OutFile 'dotnet-9.0-runtime-x64.exe'
36+
Copy-Item dotnet-9.0-runtime-x64.exe M3u8Downloader_H/bin/Publish -Recurse
37+
38+
- name: Upload artifacts normal
39+
uses: actions/upload-artifact@v3
40+
with:
41+
name: M3u8Downloader_H
42+
path: M3u8Downloader_H/bin/Publish
43+
44+
- name: Upload artifacts single file
45+
uses: actions/upload-artifact@v3
46+
with:
47+
name: M3u8Downloader_H-SingleFile
48+
path: M3u8Downloader_H/bin/PublishSingleFile
49+
50+
deploy:
51+
needs: package
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- name: Download artifacts normal
56+
uses: actions/download-artifact@v3
57+
with:
58+
name: M3u8Downloader_H
59+
path: M3u8Downloader_H
60+
61+
- name: Download artifacts single file
62+
uses: actions/download-artifact@v3
63+
with:
64+
name: M3u8Downloader_H-SingleFile
65+
path: M3u8Downloader_H-SingleFile
66+
67+
- name: Create package
68+
run: |
69+
Compress-Archive -Path M3u8Downloader_H/* -DestinationPath M3u8Downloader_H.zip -Force
70+
Compress-Archive -Path M3u8Downloader_H-SingleFile/* -DestinationPath M3u8Downloader_H-SingleFile.zip -Force
71+
shell: pwsh
72+
73+
- name: Get Releases Descript
74+
id : get_desc
75+
run: |
76+
curl -Lo changlog.md https://raw.githubusercontent.com/Harlan-H/M3u8Downloader_H/refs/heads/master/Changelog.md
77+
result=$(awk '/^# /{if (flag) exit; flag=1} flag && NF' changlog.md)
78+
echo "release_body<<EOF" >> $GITHUB_OUTPUT
79+
echo "$result" >> $GITHUB_OUTPUT
80+
echo "EOF" >> $GITHUB_OUTPUT
81+
82+
- name: Create release
83+
uses: softprops/action-gh-release@v1
84+
with:
85+
body: |
86+
${{ steps.get_desc.outputs.release_body }}
87+
88+
#
89+
- [更多更新内容](https://github.com/Harlan-H/M3u8Downloader_H/blob/master/Changelog.md)
90+
91+
#
92+
| 名称 | 描述 |
93+
|-------|-------|
94+
| [m3u8Downloader_H.zip](https://github.com/Harlan-H/M3u8Downloader_H/releases/download/${{ github.event.inputs.tags }}/M3u8Downloader_H.zip) | 需要运行库版本,程序文件夹中的dotnet-9.0-runtime-x64.exe |
95+
| [M3u8Downloader_H-SingleFile.zip](https://github.com/Harlan-H/M3u8Downloader_H/releases/download/${{ github.event.inputs.tags }}/M3u8Downloader_H-SingleFile.zip) | 无需运行库版本,可能某些功能无法使用 |
96+
- 如果你是win7用户且程序双击没反应 那么就必须安装KB4457144 [跳转环境问题](https://github.com/Harlan-H/M3u8Downloader_H/wiki#%E7%8E%AF%E5%A2%83%E9%97%AE%E9%A2%98)
97+
98+
draft: false
99+
prerelease: false
100+
files: |
101+
M3u8Downloader_H.zip
102+
M3u8Downloader_H-SingleFile.zip

Changelog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# 3.14.6 (2024/12/18)
2+
- .net6官方停止维护故升级.net9
3+
- 设置中增加关闭声音按钮
4+
- 设置中删除相同缓存按钮
5+
- 修改重复下载机制,改成同时判断路径和名称
6+
- 修改名称生成规则,由原先的随机改成链接地址hash以保证断点续传功能的正常使用
7+
- 修改api接口中的DownloadByContent实现方案,当传入m3u8文件内容时将直接解析,如果出现错误会通过接口返回
8+
- 因为api接口实现的改变删除一个方法
9+
- 代码优化,均升级成官方推荐代码
10+
- 日志中删除xx.ts下载成功的提示
11+
- 修复在某些情况下转到mp4会报错的问题
12+
- 下个版本将推出支持mp3,mp4,flv等长连接视频的下载方案,尽情期待
13+
114
# 3.14.5 (2024/07/06)
215
- 修复上次更新后导致缓存无法删除的bug
316

M3u8Downloader_H.Combiners/M3u8Downloader_H.Combiners.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

M3u8Downloader_H.Combiners/M3uCombinerClient.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,11 @@ protected async ValueTask ConverterToMp4(string m3u8FilePath, bool allowed_exten
8383
if (allowed_extensions)
8484
arguments.Add("-allowed_extensions").Add("ALL");
8585

86-
arguments.Add("-i").Add(m3u8FilePath);
87-
88-
arguments.Add("-f").Add(Settings.SelectedFormat);
89-
90-
arguments
91-
.Add("-c:a").Add("copy")
92-
.Add("-c:v").Add("copy");
86+
arguments.Add("-i").Add(m3u8FilePath)
87+
.Add("-f").Add(Settings.SelectedFormat)
88+
.Add("-c:a").Add("copy")
89+
.Add("-c:v").Add("copy")
90+
.Add("-bsf:a").Add("aac_adtstoasc");
9391

9492
var tmpOutputFile = Path.ChangeExtension(DownloadParams.VideoFullName, Settings.SelectedFormat);
9593
DownloadParams.ChangeVideoNameDelegate(tmpOutputFile);

M3u8Downloader_H.Combiners/M3uCombiners/CryptM3uCombiner.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44

55
namespace M3u8Downloader_H.Combiners.M3uCombiners
66
{
7-
internal class CryptM3uCombiner : M3uCombiner
7+
internal class CryptM3uCombiner(M3UFileInfo m3UFileInfo, string videoFullName) : M3uCombiner(videoFullName)
88
{
9-
private readonly M3UFileInfo m3UFileInfo;
10-
11-
public CryptM3uCombiner(M3UFileInfo m3UFileInfo, string videoFullName) : base(videoFullName)
12-
{
13-
this.m3UFileInfo = m3UFileInfo;
14-
}
15-
9+
private readonly M3UFileInfo m3UFileInfo = m3UFileInfo;
1610

1711
public override void Initialization(string videoName)
1812
{

M3u8Downloader_H.Combiners/M3uCombiners/M3uCombiner.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77

88
namespace M3u8Downloader_H.Combiners.M3uCombiners
99
{
10-
internal class M3uCombiner : IM3uCombiner
10+
internal class M3uCombiner(string dirPath) : IM3uCombiner
1111
{
12-
protected readonly string cacheFullPath;
12+
protected readonly string cacheFullPath = dirPath;
1313
protected FileStream videoFileStream = default!;
1414

1515
public IProgress<double> Progress { get; set; } = default!;
16-
public M3uCombiner(string dirPath)
17-
{
18-
cacheFullPath = dirPath;
19-
}
2016

2117
protected virtual Stream HandleData(string path) => File.OpenRead(path);
2218

M3u8Downloader_H.Combiners/VideoConverter/FFmpeg.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77

88
namespace M3u8Downloader_H.Core.VideoConverter
99
{
10-
internal class FFmpeg
10+
internal class FFmpeg(string filePath)
1111
{
12-
private readonly string _filePath;
13-
14-
public FFmpeg(string filePath) => _filePath = filePath;
12+
private readonly string _filePath = filePath;
1513

1614
public async ValueTask ExecuteAsync(
1715
string arguments,

M3u8Downloader_H.Combiners/VideoConverter/FFmpegProgressRouter.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,24 @@
1111

1212
namespace M3u8Downloader_H.Core.VideoConverter
1313
{
14-
internal class FFmpegProgressRouter : PipeTarget
14+
internal partial class FFmpegProgressRouter(IProgress<double> output) : PipeTarget
1515
{
1616
private readonly StringBuilder _buffer = new();
17-
private readonly IProgress<double> _output;
17+
private readonly IProgress<double> _output = output;
1818

1919
private TimeSpan? _totalDuration;
2020
private TimeSpan? _lastOffset;
2121

22-
public FFmpegProgressRouter(IProgress<double> output) => _output = output;
23-
2422
private TimeSpan? TryParseTotalDuration(string data)
2523
{
2624
return data
27-
.Pipe(s => Regex.Match(s, @"Duration:\s(\d\d:\d\d:\d\d.\d\d)").Groups[1].Value)
25+
.Pipe(s => Duration().Match(s).Groups[1].Value)
2826
.NullIfWhiteSpace()?
2927
.Pipe(s => TimeSpan.ParseExact(s, "c", CultureInfo.InvariantCulture));
3028
}
3129

3230
private TimeSpan? TryParseCurrentOffset(string data) => data
33-
.Pipe(s => Regex.Matches(s, @"time=(\d\d:\d\d:\d\d.\d\d)")
31+
.Pipe(s => Time().Matches(s)
3432
.Cast<Match>()
3533
.LastOrDefault()?
3634
.Groups[1]
@@ -73,5 +71,11 @@ public override async Task CopyFromAsync(Stream source, CancellationToken cancel
7371
HandleBuffer();
7472
}
7573
}
74+
75+
[GeneratedRegex(@"time=(\d\d:\d\d:\d\d.\d\d)")]
76+
private static partial Regex Time();
77+
78+
[GeneratedRegex(@"Duration:\s(\d\d:\d\d:\d\d.\d\d)")]
79+
private static partial Regex Duration();
7680
}
7781
}

M3u8Downloader_H.Common/M3u8Downloader_H.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<Authors>Harlan</Authors>

M3u8Downloader_H.Common/M3u8Infos/M3UFileInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public M3UFileInfo(M3UFileInfo m3UFileInfo)
3939
AllowCache = m3UFileInfo.AllowCache;
4040
PlaylistType = m3UFileInfo.PlaylistType;
4141
Key = m3UFileInfo.Key;
42-
Streams = m3UFileInfo.Streams.ToList();
43-
MediaFiles = m3UFileInfo.MediaFiles.ToList();
42+
Streams = [.. m3UFileInfo.Streams];
43+
MediaFiles = [.. m3UFileInfo.MediaFiles];
4444
}
4545

4646

M3u8Downloader_H.Common/Utils/JsonPathConverter.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ public class JsonPathConverter : JsonConverter
1414

1515
foreach (var prop in objectType.GetProperties().Where(p => p.CanRead && p.CanWrite))
1616
{
17-
var jsonPropertyAttr = prop.GetCustomAttributes(true).OfType<JsonPropertyAttribute>().FirstOrDefault();
18-
if (jsonPropertyAttr == null)
19-
{
20-
throw new JsonReaderException($"{nameof(JsonPropertyAttribute)} is mandatory when using {nameof(JsonPathConverter)}");
21-
}
17+
var jsonPropertyAttr = prop.GetCustomAttributes(true).OfType<JsonPropertyAttribute>().FirstOrDefault()
18+
?? throw new JsonReaderException($"{nameof(JsonPropertyAttribute)} is mandatory when using {nameof(JsonPathConverter)}");
2219

2320
var jsonPath = jsonPropertyAttr.PropertyName;
2421
var token = jObject.SelectToken(jsonPath!);

M3u8Downloader_H.Common/Utils/KV.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static KeyValuePair<string, string> Parse(string text, char separator = '
1111
return new KeyValuePair<string, string>();
1212

1313
var strArray = text.Split(
14-
new[] { separator }, 2, StringSplitOptions.RemoveEmptyEntries
14+
[separator], 2, StringSplitOptions.RemoveEmptyEntries
1515
);
1616

1717
if (strArray.Length == 2)

M3u8Downloader_H.Core/DownloadClient.cs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
namespace M3u8Downloader_H.Core
2121
{
22-
public class DownloadClient
22+
public class DownloadClient(HttpClient httpClient, Uri url, IEnumerable<KeyValuePair<string, string>>? header, ILog log, Type? pluginType)
2323
{
24-
private readonly HttpClient httpClient;
25-
private Uri _url;
26-
private readonly IEnumerable<KeyValuePair<string, string>>? _header;
27-
private readonly IPluginManager? pluginManager;
28-
private readonly ILog _log;
24+
private readonly HttpClient httpClient = httpClient;
25+
private Uri _url = url;
26+
private readonly IEnumerable<KeyValuePair<string, string>>? _header = header;
27+
private readonly PluginManger? pluginManager = PluginManger.CreatePluginMangaer(pluginType, httpClient, log);
28+
private readonly ILog _log = log;
2929
private M3u8FileInfoClient? m3U8FileInfoClient;
3030
private M3uDownloaderClient? m3UDownloaderClient;
3131
private M3uCombinerClient? m3UCombinerClient;
@@ -91,15 +91,6 @@ public M3uCombinerClient Merger
9191
}
9292
}
9393

94-
public DownloadClient(HttpClient httpClient,Uri url,IEnumerable<KeyValuePair<string,string>>? header, ILog log, Type? pluginType)
95-
{
96-
this.httpClient = httpClient;
97-
_url = url;
98-
_header = header;
99-
_log = log;
100-
pluginManager = PluginManger.CreatePluginMangaer(pluginType, httpClient, log);
101-
}
102-
10394
public async Task GetM3u8Uri(CancellationToken cancellationToken)
10495
{
10596
if(!M3U8UriManager.Completed)
@@ -112,9 +103,8 @@ public async Task GetM3U8FileInfo(CancellationToken cancellationToken)
112103
if (M3u8FileInfo is not null)
113104
return;
114105

115-
if (M3uContent is not null)
116-
M3u8FileInfo = M3uFileReader.GetM3u8FileInfo(_url, M3uContent);
117-
else if (_url.IsFile)
106+
107+
if (_url.IsFile)
118108
{
119109
string ext = Path.GetExtension(_url.OriginalString).Trim('.');
120110
M3u8FileInfo = M3uFileReader.GetM3u8FileInfo(ext, _url);

0 commit comments

Comments
 (0)