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 Dec 18, 2024
2 parents bd9bd20 + 61a178c commit 1e8f9de
Show file tree
Hide file tree
Showing 66 changed files with 422 additions and 526 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ jobs:
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 9.0.x

- name: Publish
run: |
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/Publish --configuration Release
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/PublishSingleFile -c Release --self-contained true -r win7-x64 -p:PublishSingleFile=true
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/PublishSingleFile -c Release --self-contained true -r win-x64 -p:PublishSingleFile=true
- name: Download .NET 6 SDK And Copy .NET 6 SDK
- name: Download .NET 9 SDK And Copy .NET 9 SDK
run: |
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'
Copy-Item dotnet-sdk-win-x64.exe M3u8Downloader_H/bin/Publish -Recurse
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'
Copy-Item dotnet-9.0-runtime-x64.exe M3u8Downloader_H/bin/Publish -Recurse
- name: Upload artifacts normal
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -71,12 +71,32 @@ jobs:
Compress-Archive -Path M3u8Downloader_H/* -DestinationPath M3u8Downloader_H.zip -Force
Compress-Archive -Path M3u8Downloader_H-SingleFile/* -DestinationPath M3u8Downloader_H-SingleFile.zip -Force
shell: pwsh

- name: Get Releases Descript
id : get_desc
run: |
curl -Lo changlog.md https://raw.githubusercontent.com/Harlan-H/M3u8Downloader_H/refs/heads/master/Changelog.md
result=$(awk '/^# /{if (flag) exit; flag=1} flag && NF' changlog.md)
echo "release_body<<EOF" >> $GITHUB_OUTPUT
echo "$result" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create release
uses: softprops/action-gh-release@v1
with:
body: |
- [更新日志](https://github.com/Harlan-H/M3u8Downloader_H/blob/master/Changelog.md)
${{ steps.get_desc.outputs.release_body }}
#
- [更多更新内容](https://github.com/Harlan-H/M3u8Downloader_H/blob/master/Changelog.md)
#
| 名称 | 描述 |
|-------|-------|
| [m3u8Downloader_H.zip](https://github.com/Harlan-H/M3u8Downloader_H/releases/download/${{github.ref_name}}/M3u8Downloader_H.zip) | 需要运行库版本,程序文件夹中的dotnet-9.0-runtime-x64.exe |
| [M3u8Downloader_H-SingleFile.zip](https://github.com/Harlan-H/M3u8Downloader_H/releases/download/${{github.ref_name}}/M3u8Downloader_H-SingleFile.zip) | 无需运行库版本,可能某些功能无法使用 |
- 如果你是win7用户且程序双击没反应 那么就必须安装KB4457144 [跳转环境问题](https://github.com/Harlan-H/M3u8Downloader_H/wiki#%E7%8E%AF%E5%A2%83%E9%97%AE%E9%A2%98)
draft: false
prerelease: false
files: |
Expand Down
102 changes: 102 additions & 0 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: main

on:
workflow_dispatch:
inputs:
tags:
description: '版本号'
required: true

jobs:
package:
runs-on: windows-latest

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x

- name: Publish
run: |
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/Publish --configuration Release
dotnet publish M3u8Downloader_H/ -o M3u8Downloader_H/bin/PublishSingleFile -c Release --self-contained true -r win-x64 -p:PublishSingleFile=true
- name: Download .NET 9 SDK And Copy .NET 9 SDK
run: |
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'
Copy-Item dotnet-9.0-runtime-x64.exe M3u8Downloader_H/bin/Publish -Recurse
- name: Upload artifacts normal
uses: actions/upload-artifact@v3
with:
name: M3u8Downloader_H
path: M3u8Downloader_H/bin/Publish

- name: Upload artifacts single file
uses: actions/upload-artifact@v3
with:
name: M3u8Downloader_H-SingleFile
path: M3u8Downloader_H/bin/PublishSingleFile

deploy:
needs: package
runs-on: ubuntu-latest

steps:
- name: Download artifacts normal
uses: actions/download-artifact@v3
with:
name: M3u8Downloader_H
path: M3u8Downloader_H

- name: Download artifacts single file
uses: actions/download-artifact@v3
with:
name: M3u8Downloader_H-SingleFile
path: M3u8Downloader_H-SingleFile

- name: Create package
run: |
Compress-Archive -Path M3u8Downloader_H/* -DestinationPath M3u8Downloader_H.zip -Force
Compress-Archive -Path M3u8Downloader_H-SingleFile/* -DestinationPath M3u8Downloader_H-SingleFile.zip -Force
shell: pwsh

- name: Get Releases Descript
id : get_desc
run: |
curl -Lo changlog.md https://raw.githubusercontent.com/Harlan-H/M3u8Downloader_H/refs/heads/master/Changelog.md
result=$(awk '/^# /{if (flag) exit; flag=1} flag && NF' changlog.md)
echo "release_body<<EOF" >> $GITHUB_OUTPUT
echo "$result" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create release
uses: softprops/action-gh-release@v1
with:
body: |
${{ steps.get_desc.outputs.release_body }}
#
- [更多更新内容](https://github.com/Harlan-H/M3u8Downloader_H/blob/master/Changelog.md)
#
| 名称 | 描述 |
|-------|-------|
| [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 |
| [M3u8Downloader_H-SingleFile.zip](https://github.com/Harlan-H/M3u8Downloader_H/releases/download/${{ github.event.inputs.tags }}/M3u8Downloader_H-SingleFile.zip) | 无需运行库版本,可能某些功能无法使用 |
- 如果你是win7用户且程序双击没反应 那么就必须安装KB4457144 [跳转环境问题](https://github.com/Harlan-H/M3u8Downloader_H/wiki#%E7%8E%AF%E5%A2%83%E9%97%AE%E9%A2%98)
draft: false
prerelease: false
files: |
M3u8Downloader_H.zip
M3u8Downloader_H-SingleFile.zip
13 changes: 13 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 3.14.6 (2024/12/18)
- .net6官方停止维护故升级.net9
- 设置中增加关闭声音按钮
- 设置中删除相同缓存按钮
- 修改重复下载机制,改成同时判断路径和名称
- 修改名称生成规则,由原先的随机改成链接地址hash以保证断点续传功能的正常使用
- 修改api接口中的DownloadByContent实现方案,当传入m3u8文件内容时将直接解析,如果出现错误会通过接口返回
- 因为api接口实现的改变删除一个方法
- 代码优化,均升级成官方推荐代码
- 日志中删除xx.ts下载成功的提示
- 修复在某些情况下转到mp4会报错的问题
- 下个版本将推出支持mp3,mp4,flv等长连接视频的下载方案,尽情期待

# 3.14.5 (2024/07/06)
- 修复上次更新后导致缓存无法删除的bug

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
12 changes: 5 additions & 7 deletions M3u8Downloader_H.Combiners/M3uCombinerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,11 @@ protected async ValueTask ConverterToMp4(string m3u8FilePath, bool allowed_exten
if (allowed_extensions)
arguments.Add("-allowed_extensions").Add("ALL");

arguments.Add("-i").Add(m3u8FilePath);

arguments.Add("-f").Add(Settings.SelectedFormat);

arguments
.Add("-c:a").Add("copy")
.Add("-c:v").Add("copy");
arguments.Add("-i").Add(m3u8FilePath)
.Add("-f").Add(Settings.SelectedFormat)
.Add("-c:a").Add("copy")
.Add("-c:v").Add("copy")
.Add("-bsf:a").Add("aac_adtstoasc");

var tmpOutputFile = Path.ChangeExtension(DownloadParams.VideoFullName, Settings.SelectedFormat);
DownloadParams.ChangeVideoNameDelegate(tmpOutputFile);
Expand Down
10 changes: 2 additions & 8 deletions M3u8Downloader_H.Combiners/M3uCombiners/CryptM3uCombiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@

namespace M3u8Downloader_H.Combiners.M3uCombiners
{
internal class CryptM3uCombiner : M3uCombiner
internal class CryptM3uCombiner(M3UFileInfo m3UFileInfo, string videoFullName) : M3uCombiner(videoFullName)
{
private readonly M3UFileInfo m3UFileInfo;

public CryptM3uCombiner(M3UFileInfo m3UFileInfo, string videoFullName) : base(videoFullName)
{
this.m3UFileInfo = m3UFileInfo;
}

private readonly M3UFileInfo m3UFileInfo = m3UFileInfo;

public override void Initialization(string videoName)
{
Expand Down
8 changes: 2 additions & 6 deletions M3u8Downloader_H.Combiners/M3uCombiners/M3uCombiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@

namespace M3u8Downloader_H.Combiners.M3uCombiners
{
internal class M3uCombiner : IM3uCombiner
internal class M3uCombiner(string dirPath) : IM3uCombiner
{
protected readonly string cacheFullPath;
protected readonly string cacheFullPath = dirPath;
protected FileStream videoFileStream = default!;

public IProgress<double> Progress { get; set; } = default!;
public M3uCombiner(string dirPath)
{
cacheFullPath = dirPath;
}

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

Expand Down
6 changes: 2 additions & 4 deletions M3u8Downloader_H.Combiners/VideoConverter/FFmpeg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

namespace M3u8Downloader_H.Core.VideoConverter
{
internal class FFmpeg
internal class FFmpeg(string filePath)
{
private readonly string _filePath;

public FFmpeg(string filePath) => _filePath = filePath;
private readonly string _filePath = filePath;

public async ValueTask ExecuteAsync(
string arguments,
Expand Down
16 changes: 10 additions & 6 deletions M3u8Downloader_H.Combiners/VideoConverter/FFmpegProgressRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,24 @@

namespace M3u8Downloader_H.Core.VideoConverter
{
internal class FFmpegProgressRouter : PipeTarget
internal partial class FFmpegProgressRouter(IProgress<double> output) : PipeTarget
{
private readonly StringBuilder _buffer = new();
private readonly IProgress<double> _output;
private readonly IProgress<double> _output = output;

private TimeSpan? _totalDuration;
private TimeSpan? _lastOffset;

public FFmpegProgressRouter(IProgress<double> output) => _output = output;

private TimeSpan? TryParseTotalDuration(string data)
{
return data
.Pipe(s => Regex.Match(s, @"Duration:\s(\d\d:\d\d:\d\d.\d\d)").Groups[1].Value)
.Pipe(s => Duration().Match(s).Groups[1].Value)
.NullIfWhiteSpace()?
.Pipe(s => TimeSpan.ParseExact(s, "c", CultureInfo.InvariantCulture));
}

private TimeSpan? TryParseCurrentOffset(string data) => data
.Pipe(s => Regex.Matches(s, @"time=(\d\d:\d\d:\d\d.\d\d)")
.Pipe(s => Time().Matches(s)
.Cast<Match>()
.LastOrDefault()?
.Groups[1]
Expand Down Expand Up @@ -73,5 +71,11 @@ public override async Task CopyFromAsync(Stream source, CancellationToken cancel
HandleBuffer();
}
}

[GeneratedRegex(@"time=(\d\d:\d\d:\d\d.\d\d)")]
private static partial Regex Time();

[GeneratedRegex(@"Duration:\s(\d\d:\d\d:\d\d.\d\d)")]
private static partial Regex Duration();
}
}
2 changes: 1 addition & 1 deletion M3u8Downloader_H.Common/M3u8Downloader_H.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Harlan</Authors>
Expand Down
4 changes: 2 additions & 2 deletions M3u8Downloader_H.Common/M3u8Infos/M3UFileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public M3UFileInfo(M3UFileInfo m3UFileInfo)
AllowCache = m3UFileInfo.AllowCache;
PlaylistType = m3UFileInfo.PlaylistType;
Key = m3UFileInfo.Key;
Streams = m3UFileInfo.Streams.ToList();
MediaFiles = m3UFileInfo.MediaFiles.ToList();
Streams = [.. m3UFileInfo.Streams];
MediaFiles = [.. m3UFileInfo.MediaFiles];
}


Expand Down
7 changes: 2 additions & 5 deletions M3u8Downloader_H.Common/Utils/JsonPathConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ public class JsonPathConverter : JsonConverter

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

var jsonPath = jsonPropertyAttr.PropertyName;
var token = jObject.SelectToken(jsonPath!);
Expand Down
2 changes: 1 addition & 1 deletion M3u8Downloader_H.Common/Utils/KV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static KeyValuePair<string, string> Parse(string text, char separator = '
return new KeyValuePair<string, string>();

var strArray = text.Split(
new[] { separator }, 2, StringSplitOptions.RemoveEmptyEntries
[separator], 2, StringSplitOptions.RemoveEmptyEntries
);

if (strArray.Length == 2)
Expand Down
26 changes: 8 additions & 18 deletions M3u8Downloader_H.Core/DownloadClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

namespace M3u8Downloader_H.Core
{
public class DownloadClient
public class DownloadClient(HttpClient httpClient, Uri url, IEnumerable<KeyValuePair<string, string>>? header, ILog log, Type? pluginType)
{
private readonly HttpClient httpClient;
private Uri _url;
private readonly IEnumerable<KeyValuePair<string, string>>? _header;
private readonly IPluginManager? pluginManager;
private readonly ILog _log;
private readonly HttpClient httpClient = httpClient;
private Uri _url = url;
private readonly IEnumerable<KeyValuePair<string, string>>? _header = header;
private readonly PluginManger? pluginManager = PluginManger.CreatePluginMangaer(pluginType, httpClient, log);
private readonly ILog _log = log;
private M3u8FileInfoClient? m3U8FileInfoClient;
private M3uDownloaderClient? m3UDownloaderClient;
private M3uCombinerClient? m3UCombinerClient;
Expand Down Expand Up @@ -91,15 +91,6 @@ public M3uCombinerClient Merger
}
}

public DownloadClient(HttpClient httpClient,Uri url,IEnumerable<KeyValuePair<string,string>>? header, ILog log, Type? pluginType)
{
this.httpClient = httpClient;
_url = url;
_header = header;
_log = log;
pluginManager = PluginManger.CreatePluginMangaer(pluginType, httpClient, log);
}

public async Task GetM3u8Uri(CancellationToken cancellationToken)
{
if(!M3U8UriManager.Completed)
Expand All @@ -112,9 +103,8 @@ public async Task GetM3U8FileInfo(CancellationToken cancellationToken)
if (M3u8FileInfo is not null)
return;

if (M3uContent is not null)
M3u8FileInfo = M3uFileReader.GetM3u8FileInfo(_url, M3uContent);
else if (_url.IsFile)

if (_url.IsFile)
{
string ext = Path.GetExtension(_url.OriginalString).Trim('.');
M3u8FileInfo = M3uFileReader.GetM3u8FileInfo(ext, _url);
Expand Down
Loading

0 comments on commit 1e8f9de

Please sign in to comment.