Marked util classes as static (#460)

* Marked util classes as static

* Used file-scoped namespaces
This commit is contained in:
irodai-majom 2024-11-10 09:15:30 +01:00 committed by GitHub
parent 8a25815c1f
commit 9fc37d5b61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 1560 additions and 1588 deletions

View File

@ -8,9 +8,9 @@ using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace N_m3u8DL_RE.Common.Util namespace N_m3u8DL_RE.Common.Util;
{
public class GlobalUtil public static class GlobalUtil
{ {
private static readonly JsonSerializerOptions Options = new JsonSerializerOptions private static readonly JsonSerializerOptions Options = new JsonSerializerOptions
{ {
@ -77,4 +77,3 @@ namespace N_m3u8DL_RE.Common.Util
return searchPath.Concat(envPath).Select(p => Path.Combine(p, name + fileExt)).FirstOrDefault(File.Exists); return searchPath.Concat(envPath).Select(p => Path.Combine(p, name + fileExt)).FirstOrDefault(File.Exists);
} }
} }
}

View File

@ -3,9 +3,9 @@ using System.Net.Http.Headers;
using N_m3u8DL_RE.Common.Log; using N_m3u8DL_RE.Common.Log;
using N_m3u8DL_RE.Common.Resource; using N_m3u8DL_RE.Common.Resource;
namespace N_m3u8DL_RE.Common.Util namespace N_m3u8DL_RE.Common.Util;
{
public class HTTPUtil public static class HTTPUtil
{ {
public static readonly HttpClientHandler HttpClientHandler = new() public static readonly HttpClientHandler HttpClientHandler = new()
{ {
@ -138,4 +138,3 @@ namespace N_m3u8DL_RE.Common.Util
return htmlCode; return htmlCode;
} }
} }
}

View File

@ -1,12 +1,6 @@
using System; namespace N_m3u8DL_RE.Common.Util;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace N_m3u8DL_RE.Common.Util public static class HexUtil
{
public class HexUtil
{ {
public static string BytesToHex(byte[] data, string split = "") public static string BytesToHex(byte[] data, string split = "")
{ {
@ -43,4 +37,3 @@ namespace N_m3u8DL_RE.Common.Util
return Convert.FromHexString(hexSpan); return Convert.FromHexString(hexSpan);
} }
} }
}

View File

@ -4,7 +4,7 @@ using Spectre.Console;
namespace N_m3u8DL_RE.Common.Util; namespace N_m3u8DL_RE.Common.Util;
public class RetryUtil public static class RetryUtil
{ {
public static async Task<T?> WebRequestRetryAsync<T>(Func<Task<T>> funcAsync, int maxRetries = 10, int retryDelayMilliseconds = 1500, int retryDelayIncrementMilliseconds = 0) public static async Task<T?> WebRequestRetryAsync<T>(Func<Task<T>> funcAsync, int maxRetries = 10, int retryDelayMilliseconds = 1500, int retryDelayIncrementMilliseconds = 0)
{ {

View File

@ -6,9 +6,9 @@ using System.IO;
using System.Net; using System.Net;
using System.Net.Http.Headers; using System.Net.Http.Headers;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
internal class DownloadUtil internal static class DownloadUtil
{ {
private static readonly HttpClient AppHttpClient = HTTPUtil.AppHttpClient; private static readonly HttpClient AppHttpClient = HTTPUtil.AppHttpClient;
@ -143,4 +143,3 @@ namespace N_m3u8DL_RE.Util
} }
} }
} }
}

View File

@ -11,9 +11,9 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
public class FilterUtil public static class FilterUtil
{ {
public static List<StreamSpec> DoFilterKeep(IEnumerable<StreamSpec> lists, StreamFilter? filter) public static List<StreamSpec> DoFilterKeep(IEnumerable<StreamSpec> lists, StreamFilter? filter)
{ {
@ -281,4 +281,3 @@ namespace N_m3u8DL_RE.Util
} }
} }
} }
}

View File

@ -1,13 +1,6 @@
using System; namespace N_m3u8DL_RE.Util;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace N_m3u8DL_RE.Util internal static class ImageHeaderUtil
{
internal class ImageHeaderUtil
{ {
public static bool IsImageHeader(byte[] bArr) public static bool IsImageHeader(byte[] bArr)
{ {
@ -86,4 +79,3 @@ namespace N_m3u8DL_RE.Util
await File.WriteAllBytesAsync(sourcePath, sourceData); await File.WriteAllBytesAsync(sourcePath, sourceData);
} }
} }
}

View File

@ -6,8 +6,8 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
class Language class Language
{ {
public string Code; public string Code;
@ -24,9 +24,8 @@ namespace N_m3u8DL_RE.Util
} }
} }
internal class LanguageCodeUtil internal static class LanguageCodeUtil
{ {
private LanguageCodeUtil() { }
private readonly static List<Language> ALL_LANGS = @" private readonly static List<Language> ALL_LANGS = @"
af;afr;Afrikaans;Afrikaans af;afr;Afrikaans;Afrikaans
@ -544,4 +543,3 @@ sr;srp
if (string.IsNullOrEmpty(outputFile.Description)) outputFile.Description = originalLangCode; if (string.IsNullOrEmpty(outputFile.Description)) outputFile.Description = originalLangCode;
} }
} }
}

View File

@ -9,9 +9,9 @@ using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
internal class LargeSingleFileSplitUtil internal static class LargeSingleFileSplitUtil
{ {
class Clip class Clip
{ {
@ -119,4 +119,3 @@ namespace N_m3u8DL_RE.Util
return clips; return clips;
} }
} }
}

View File

@ -5,9 +5,9 @@ using N_m3u8DL_RE.Config;
using System.Diagnostics; using System.Diagnostics;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
internal class MP4DecryptUtil internal static class MP4DecryptUtil
{ {
private static string ZeroKid = "00000000000000000000000000000000"; private static string ZeroKid = "00000000000000000000000000000000";
public static async Task<bool> DecryptAsync(bool shakaPackager, string bin, string[]? keys, string source, string dest, string? kid, string init = "", bool isMultiDRM=false) public static async Task<bool> DecryptAsync(bool shakaPackager, string bin, string[]? keys, string source, string dest, string? kid, string init = "", bool isMultiDRM=false)
@ -185,4 +185,3 @@ namespace N_m3u8DL_RE.Util
return ShakaKeyIDRegex.Match(errorOutput).Groups[1].Value; return ShakaKeyIDRegex.Match(errorOutput).Groups[1].Value;
} }
} }
}

View File

@ -8,9 +8,9 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
internal partial class MediainfoUtil internal static partial class MediainfoUtil
{ {
[GeneratedRegex(" Stream #.*")] [GeneratedRegex(" Stream #.*")]
private static partial Regex TextRegex(); private static partial Regex TextRegex();
@ -96,4 +96,3 @@ namespace N_m3u8DL_RE.Util
return result; return result;
} }
} }
}

View File

@ -5,9 +5,9 @@ using System.Diagnostics;
using System.Text; using System.Text;
using N_m3u8DL_RE.Enum; using N_m3u8DL_RE.Enum;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
internal class MergeUtil internal static class MergeUtil
{ {
/// <summary> /// <summary>
/// 输入一堆已存在的文件,合并到新文件 /// 输入一堆已存在的文件,合并到新文件
@ -291,4 +291,3 @@ namespace N_m3u8DL_RE.Util
return code == 0; return code == 0;
} }
} }
}

View File

@ -6,8 +6,8 @@ using System.IO.Compression;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
internal class OtherUtil internal class OtherUtil
{ {
public static Dictionary<string, string> SplitHeaderArrayToDic(string[]? headers) public static Dictionary<string, string> SplitHeaderArrayToDic(string[]? headers)
@ -177,4 +177,3 @@ namespace N_m3u8DL_RE.Util
}; };
} }
} }
}

View File

@ -10,9 +10,9 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
internal class PipeUtil internal static class PipeUtil
{ {
public static Stream CreatePipe(string pipeName) public static Stream CreatePipe(string pipeName)
{ {
@ -110,4 +110,3 @@ namespace N_m3u8DL_RE.Util
return p.ExitCode == 0; return p.ExitCode == 0;
} }
} }
}

View File

@ -7,9 +7,9 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace N_m3u8DL_RE.Util namespace N_m3u8DL_RE.Util;
{
internal class SubtitleUtil internal static class SubtitleUtil
{ {
/// <summary> /// <summary>
/// 写出图形字幕PNG文件 /// 写出图形字幕PNG文件
@ -37,4 +37,3 @@ namespace N_m3u8DL_RE.Util
else return false; else return false;
} }
} }
}