Skip to content

Commit

Permalink
适配WindowsVista
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaoda committed Nov 21, 2024
1 parent bb20d50 commit 2b47870
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 32 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/build_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

jobs:
build-win7-x86:
build-win-nt6_0-x86:
runs-on: windows-latest

steps:
Expand All @@ -34,13 +34,15 @@ jobs:
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}

- run: powershell -Command "(Get-Content src/N_m3u8DL-RE/N_m3u8DL-RE.csproj) -replace '<TargetFramework>.*</TargetFramework>', '<TargetFramework>net9.0-windows</TargetFramework>' | Set-Content src/N_m3u8DL-RE/N_m3u8DL-RE.csproj"
- run: dotnet add src/N_m3u8DL-RE/N_m3u8DL-RE.csproj package YY-Thunks --version 1.1.4
- run: dotnet add src/N_m3u8DL-RE/N_m3u8DL-RE.csproj package VC-LTL --version 5.1.1
- run: dotnet publish src/N_m3u8DL-RE -r win-x86 -c Release -o artifact-x86
- run: dotnet publish src/N_m3u8DL-RE -p:TargetPlatformMinVersion=6.0 -r win-x86 -c Release -o artifact-x86

- name: Upload Artifact[win-x86]
uses: actions/[email protected]
with:
name: N_m3u8DL-RE_Beta_win7-x86
name: N_m3u8DL-RE_Beta_win_NT6.0-x86
path: artifact-x86\N_m3u8DL-RE.exe

build-win-x64-arm64:
Expand Down Expand Up @@ -135,7 +137,7 @@ jobs:
create_draft_release:
name: Create Github draft release
if: ${{ github.event.inputs.doRelease == 'true' }}
needs: [build-win7-x86,build-win-x64-arm64,build-linux-x64,build-linux-arm64,build-mac-x64-arm64]
needs: [build-win-nt6_0-x86,build-win-x64-arm64,build-linux-x64,build-linux-arm64,build-mac-x64-arm64]
runs-on: ubuntu-latest
steps:
- name: Audit gh version
Expand Down
2 changes: 1 addition & 1 deletion src/N_m3u8DL-RE.Common/N_m3u8DL-RE.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>N_m3u8DL_RE.Common</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
7 changes: 4 additions & 3 deletions src/N_m3u8DL-RE.Common/Resource/ResString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

public class ResString
{
public static string CurrentLoc = "en-US";

public static readonly string ReLiveTs = "<RE_LIVE_TS>";
public static string singleFileRealtimeDecryptWarn => GetText("singleFileRealtimeDecryptWarn");
public static string singleFileSplitWarn => GetText("singleFileSplitWarn");
Expand Down Expand Up @@ -132,10 +134,9 @@ private static string GetText(string key)
if (!StaticText.LANG_DIC.ContainsKey(key))
return "<...LANG TEXT MISSING...>";

var current = Thread.CurrentThread.CurrentUICulture.Name;
if (current == "zh-CN" || current == "zh-SG" || current == "zh-Hans")
if (CurrentLoc == "zh-CN" || CurrentLoc == "zh-SG" || CurrentLoc == "zh-Hans")
return StaticText.LANG_DIC[key].ZH_CN;
if (current.StartsWith("zh-"))
if (CurrentLoc.StartsWith("zh-"))
return StaticText.LANG_DIC[key].ZH_TW;
return StaticText.LANG_DIC[key].EN_US;
}
Expand Down
4 changes: 2 additions & 2 deletions src/N_m3u8DL-RE.Parser/N_m3u8DL-RE.Parser.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>library</OutputType>
<OutputType>library</OutputType>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>N_m3u8DL_RE.Parser</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
22 changes: 11 additions & 11 deletions src/N_m3u8DL-RE/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
<StaticallyLinked Condition="$(RuntimeIdentifier.StartsWith('win'))">true</StaticallyLinked>
<TrimMode>full</TrimMode>
<TrimmerDefaultAction>link</TrimmerDefaultAction>
<IlcTrimMetadata>true</IlcTrimMetadata>
<IlcGenerateStackTraceData>true</IlcGenerateStackTraceData>
<SatelliteResourceLanguages>zh-CN;zh-TW;en-US</SatelliteResourceLanguages>
<PublishAot>true</PublishAot>
<StripSymbols>true</StripSymbols>
<ObjCopyName Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">aarch64-linux-gnu-objcopy</ObjCopyName>
<TrimmerDefaultAction>link</TrimmerDefaultAction>
<IlcTrimMetadata>true</IlcTrimMetadata>
<IlcGenerateStackTraceData>true</IlcGenerateStackTraceData>
<SatelliteResourceLanguages>zh-CN;zh-TW;en-US</SatelliteResourceLanguages>
<PublishAot>true</PublishAot>
<StripSymbols>true</StripSymbols>
<ObjCopyName Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">aarch64-linux-gnu-objcopy</ObjCopyName>
</PropertyGroup>

<!-- <ItemGroup Condition="'$(PublishAot)' == 'true' and '$(RuntimeIdentifier)' != 'win-arm64' and '$(RuntimeIdentifier)' != 'linux-arm64' and '$(RuntimeIdentifier)' != 'osx-arm64' and '$(RuntimeIdentifier)' != 'osx-x64'">
<PackageReference Include="PublishAotCompressed" Version="1.0.3" />
</ItemGroup> -->
<!--<ItemGroup Condition="'$(PublishAot)' == 'true' and '$(RuntimeIdentifier)' != 'win-arm64' and '$(RuntimeIdentifier)' != 'linux-arm64' and '$(RuntimeIdentifier)' != 'osx-arm64' and '$(RuntimeIdentifier)' != 'osx-x64'">
<PackageReference Include="PublishAotCompressed" Version="1.0.3" />
</ItemGroup>-->
<ItemGroup>
<RdXmlFile Include="rd.xml" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/N_m3u8DL-RE/N_m3u8DL-RE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>N_m3u8DL_RE</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<Version>0.2.1</Version>
<Platforms>AnyCPU;x64</Platforms>
<Version>0.2.1</Version>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
20 changes: 13 additions & 7 deletions src/N_m3u8DL-RE/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Spectre.Console;
using N_m3u8DL_RE.Common.Resource;
using N_m3u8DL_RE.Common.Log;
using System.Globalization;
using System.Text;
using N_m3u8DL_RE.Common.Util;
using N_m3u8DL_RE.Processor;
Expand All @@ -22,11 +21,21 @@ internal class Program
{
static async Task Main(string[] args)
{
// 处理NT6.0及以下System.CommandLine报错CultureNotFound问题
if (OperatingSystem.IsWindows())
{
var osVersion = Environment.OSVersion.Version;
if (osVersion.Major < 6 || (osVersion.Major == 6 && osVersion.Minor == 0))
{
Environment.SetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1");
}
}

Console.CancelKeyPress += Console_CancelKeyPress;
ServicePointManager.DefaultConnectionLimit = 1024;

Check warning on line 35 in src/N_m3u8DL-RE/Program.cs

View workflow job for this annotation

GitHub Actions / build-mac-x64-arm64

'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)

Check warning on line 35 in src/N_m3u8DL-RE/Program.cs

View workflow job for this annotation

GitHub Actions / build-win-x64-arm64

'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
try { Console.CursorVisible = true; } catch { }

string loc = "en-US";
string loc = ResString.CurrentLoc;
string currLoc = Thread.CurrentThread.CurrentUICulture.Name;
if (currLoc == "zh-CN" || currLoc == "zh-SG") loc = "zh-CN";
else if (currLoc.StartsWith("zh-")) loc = "zh-TW";
Expand All @@ -38,11 +47,8 @@ static async Task Main(string[] args)
{
loc = list[index + 1];
}

CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(loc);
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(loc);
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(loc);


ResString.CurrentLoc = loc;

await CommandInvoker.InvokeArgs(args, DoWorkAsync);
}
Expand Down

0 comments on commit 2b47870

Please sign in to comment.