diff --git a/KCNLanzouDirectLink.Demo/FormMain.Designer.cs b/KCNLanzouDirectLink.Demo/FormMain.Designer.cs new file mode 100644 index 0000000..fda0e0e --- /dev/null +++ b/KCNLanzouDirectLink.Demo/FormMain.Designer.cs @@ -0,0 +1,128 @@ +namespace KCNLanzouDirectLink.Demo +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + uiButton1 = new Sunny.UI.UIButton(); + uiTextBox1 = new Sunny.UI.UITextBox(); + uiTextBox2 = new Sunny.UI.UITextBox(); + uiLabel1 = new Sunny.UI.UILabel(); + uiLabel2 = new Sunny.UI.UILabel(); + SuspendLayout(); + // + // uiButton1 + // + uiButton1.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + uiButton1.Location = new Point(117, 299); + uiButton1.MinimumSize = new Size(1, 1); + uiButton1.Name = "uiButton1"; + uiButton1.Size = new Size(561, 75); + uiButton1.TabIndex = 0; + uiButton1.Text = "获取直链"; + uiButton1.TipsFont = new Font("宋体", 9F, FontStyle.Regular, GraphicsUnit.Point, 134); + uiButton1.Click += uiButton1_Click; + // + // uiTextBox1 + // + uiTextBox1.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + uiTextBox1.Location = new Point(117, 153); + uiTextBox1.Margin = new Padding(4, 5, 4, 5); + uiTextBox1.MinimumSize = new Size(1, 16); + uiTextBox1.Name = "uiTextBox1"; + uiTextBox1.Padding = new Padding(5); + uiTextBox1.ShowText = false; + uiTextBox1.Size = new Size(561, 64); + uiTextBox1.TabIndex = 1; + uiTextBox1.TextAlignment = ContentAlignment.MiddleLeft; + uiTextBox1.Watermark = "蓝奏云分享链接"; + // + // uiTextBox2 + // + uiTextBox2.Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + uiTextBox2.Location = new Point(117, 227); + uiTextBox2.Margin = new Padding(4, 5, 4, 5); + uiTextBox2.MinimumSize = new Size(1, 16); + uiTextBox2.Name = "uiTextBox2"; + uiTextBox2.Padding = new Padding(5); + uiTextBox2.ShowText = false; + uiTextBox2.Size = new Size(561, 64); + uiTextBox2.TabIndex = 2; + uiTextBox2.TextAlignment = ContentAlignment.MiddleLeft; + uiTextBox2.Watermark = "文件分享密码(可选)"; + // + // uiLabel1 + // + uiLabel1.BackColor = Color.Transparent; + uiLabel1.Dock = DockStyle.Bottom; + uiLabel1.Font = new Font("微软雅黑", 10F); + uiLabel1.ForeColor = Color.FromArgb(48, 48, 48); + uiLabel1.Location = new Point(0, 402); + uiLabel1.Name = "uiLabel1"; + uiLabel1.Size = new Size(800, 48); + uiLabel1.TabIndex = 3; + uiLabel1.Text = "Copyright ©2023-2024 剧毒的KCN, All Rights Reserved."; + uiLabel1.TextAlign = ContentAlignment.MiddleCenter; + // + // uiLabel2 + // + uiLabel2.Font = new Font("微软雅黑", 16F); + uiLabel2.ForeColor = Color.FromArgb(48, 48, 48); + uiLabel2.Location = new Point(117, 65); + uiLabel2.Name = "uiLabel2"; + uiLabel2.Size = new Size(561, 74); + uiLabel2.TabIndex = 4; + uiLabel2.Text = "蓝奏云直链获取Demo"; + uiLabel2.TextAlign = ContentAlignment.MiddleCenter; + // + // FormMain + // + AutoScaleMode = AutoScaleMode.None; + ClientSize = new Size(800, 450); + Controls.Add(uiLabel2); + Controls.Add(uiLabel1); + Controls.Add(uiTextBox2); + Controls.Add(uiTextBox1); + Controls.Add(uiButton1); + Font = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + MaximizeBox = false; + Name = "FormMain"; + Text = "KCNLanzouDirectLink.Demo"; + TitleFont = new Font("微软雅黑", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + ZoomScaleRect = new Rectangle(22, 22, 800, 450); + ResumeLayout(false); + } + + #endregion + + private Sunny.UI.UIButton uiButton1; + private Sunny.UI.UITextBox uiTextBox1; + private Sunny.UI.UITextBox uiTextBox2; + private Sunny.UI.UILabel uiLabel1; + private Sunny.UI.UILabel uiLabel2; + } +} diff --git a/KCNLanzouDirectLink.Demo/FormMain.cs b/KCNLanzouDirectLink.Demo/FormMain.cs new file mode 100644 index 0000000..cbaf376 --- /dev/null +++ b/KCNLanzouDirectLink.Demo/FormMain.cs @@ -0,0 +1,42 @@ +namespace KCNLanzouDirectLink.Demo +{ + public partial class FormMain : Sunny.UI.UIForm + { + public FormMain() + { + InitializeComponent(); + } + + private async void uiButton1_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(uiTextBox1.Text)) + { + KUI.Error("ӣ"); + return; + } + + string? link = null; + if (!string.IsNullOrEmpty(uiTextBox2.Text)) + { + for (int i = 0; i < 10; i++) + { + link = await KCNLanzouLinkHelper.GetDirectLinkAsync(uiTextBox1.Text, uiTextBox2.Text); // ƼֱȡȶೢԼ + if (!string.IsNullOrEmpty(link)) + break; + } + } + else + { + link = await KCNLanzouLinkHelper.GetDirectLinkAsync(uiTextBox1.Text); + } + + if (link == null) + { + KUI.Error("ֱȡʧܣ"); + return; + } + + KUI.OK($"ֱȡɹ\n{link}"); + } + } +} diff --git a/KCNLanzouDirectLink.Demo/FormMain.resx b/KCNLanzouDirectLink.Demo/FormMain.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/KCNLanzouDirectLink.Demo/FormMain.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/KCNLanzouDirectLink.Demo/KCNLanzouDirectLink.Demo.csproj b/KCNLanzouDirectLink.Demo/KCNLanzouDirectLink.Demo.csproj new file mode 100644 index 0000000..a09613c --- /dev/null +++ b/KCNLanzouDirectLink.Demo/KCNLanzouDirectLink.Demo.csproj @@ -0,0 +1,16 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + + + + \ No newline at end of file diff --git a/KCNLanzouDirectLink.Demo/KUI.cs b/KCNLanzouDirectLink.Demo/KUI.cs new file mode 100644 index 0000000..54b818a --- /dev/null +++ b/KCNLanzouDirectLink.Demo/KUI.cs @@ -0,0 +1,55 @@ +using Sunny.UI; + +namespace KCNLanzouDirectLink.Demo +{ + internal class KUI + { + public static void Error(string msg) + { + Sunny.UI.UIForm form = new Sunny.UI.UIForm(); + form.ShowErrorDialog("Error", msg); + } + + public static void Error(string msg, string title) + { + Sunny.UI.UIForm form = new Sunny.UI.UIForm(); + form.ShowErrorDialog(title, msg); + } + + public static void Warning(string msg) + { + Sunny.UI.UIForm form = new Sunny.UI.UIForm(); + form.ShowWarningDialog("Warn", msg); + } + + public static void Warning(string msg, string title) + { + Sunny.UI.UIForm form = new Sunny.UI.UIForm(); + form.ShowWarningDialog(title, msg); + } + + public static void OK(string msg) + { + Sunny.UI.UIForm form = new Sunny.UI.UIForm(); + form.ShowSuccessDialog("OK", msg); + } + + public static void OK(string msg, string title) + { + Sunny.UI.UIForm form = new Sunny.UI.UIForm(); + form.ShowSuccessDialog(title, msg); + } + + public static void Info(string msg) + { + Sunny.UI.UIForm form = new Sunny.UI.UIForm(); + form.ShowInfoDialog("Info", msg, UIStyle.Blue); + } + + public static void Info(string msg, string title) + { + Sunny.UI.UIForm form = new Sunny.UI.UIForm(); + form.ShowInfoDialog(title, msg, UIStyle.Blue); + } + } +} diff --git a/KCNLanzouDirectLink.Demo/Program.cs b/KCNLanzouDirectLink.Demo/Program.cs new file mode 100644 index 0000000..4de1ff1 --- /dev/null +++ b/KCNLanzouDirectLink.Demo/Program.cs @@ -0,0 +1,17 @@ +namespace KCNLanzouDirectLink.Demo +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new FormMain()); + } + } +} \ No newline at end of file diff --git a/KCNLanzouDirectLink.Demo/README.md b/KCNLanzouDirectLink.Demo/README.md new file mode 100644 index 0000000..774d768 --- /dev/null +++ b/KCNLanzouDirectLink.Demo/README.md @@ -0,0 +1,3 @@ +# KCNLanzouDirectLink.Demo + +### 库使用示例程序 \ No newline at end of file diff --git a/KCNLanzouDirectLink.sln b/KCNLanzouDirectLink.sln index 9d97d51..e511cf0 100644 --- a/KCNLanzouDirectLink.sln +++ b/KCNLanzouDirectLink.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34728.123 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KCNLanzouDirectLink", "KCNLanzouDirectLink.csproj", "{B6774CDE-57D3-4B33-984D-23BF0B6BE6BE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KCNLanzouDirectLink", "KCNLanzouDirectLink\KCNLanzouDirectLink.csproj", "{B6774CDE-57D3-4B33-984D-23BF0B6BE6BE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KCNLanzouDirectLink.Demo", "KCNLanzouDirectLink.Demo\KCNLanzouDirectLink.Demo.csproj", "{2E1836BA-EB1D-401F-A1B7-F28BEA94EE38}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +17,10 @@ Global {B6774CDE-57D3-4B33-984D-23BF0B6BE6BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6774CDE-57D3-4B33-984D-23BF0B6BE6BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6774CDE-57D3-4B33-984D-23BF0B6BE6BE}.Release|Any CPU.Build.0 = Release|Any CPU + {2E1836BA-EB1D-401F-A1B7-F28BEA94EE38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E1836BA-EB1D-401F-A1B7-F28BEA94EE38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E1836BA-EB1D-401F-A1B7-F28BEA94EE38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E1836BA-EB1D-401F-A1B7-F28BEA94EE38}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/GetUrlHelper.cs b/KCNLanzouDirectLink/GetUrlHelper.cs similarity index 100% rename from GetUrlHelper.cs rename to KCNLanzouDirectLink/GetUrlHelper.cs diff --git a/KCNLanzouDirectLink.csproj b/KCNLanzouDirectLink/KCNLanzouDirectLink.csproj similarity index 92% rename from KCNLanzouDirectLink.csproj rename to KCNLanzouDirectLink/KCNLanzouDirectLink.csproj index ebace02..3f725e8 100644 --- a/KCNLanzouDirectLink.csproj +++ b/KCNLanzouDirectLink/KCNLanzouDirectLink.csproj @@ -31,7 +31,7 @@ https://github.com/JDDKCN/KCNLanzouDirectLink True 初次发布 - Readme.md + README.md favicon.png @@ -40,8 +40,8 @@ + - diff --git a/KCNLanzouLinkHelper.cs b/KCNLanzouDirectLink/KCNLanzouLinkHelper.cs similarity index 100% rename from KCNLanzouLinkHelper.cs rename to KCNLanzouDirectLink/KCNLanzouLinkHelper.cs diff --git a/KCNLanzouDirectLink/README.md b/KCNLanzouDirectLink/README.md new file mode 100644 index 0000000..cd1396a --- /dev/null +++ b/KCNLanzouDirectLink/README.md @@ -0,0 +1,71 @@ +# KCNLanzouDirectLink + +[![NuGet](https://img.shields.io/nuget/v/KCNLanzouDirectLink.svg)](https://www.nuget.org/packages/KCNLanzouDirectLink/) +[![NuGet Downloads](https://img.shields.io/nuget/dt/KCNLanzouDirectLink.svg)](https://www.nuget.org/packages/KCNLanzouDirectLink/) + +`KCNLanzouDirectLink` 是一个用于解析蓝奏云分享链接并获取直链的 C# 原生实现类库。它提供了简单的 API 用于获取蓝奏云分享链接的直链,无需登录或第三方工具。 + +## 安装 + +你可以通过 NuGet 包管理器安装 `KCNLanzouDirectLink` 库: + +```bash +Install-Package KCNLanzouDirectLink +``` + +或者通过 .NET CLI: + +```bash +dotnet add package KCNLanzouDirectLink +``` + +## 使用示例 + +获取普通链接的直链 + +```csharp +using KCNLanzouDirectLink; + +class Program +{ + static async Task Main(string[] args) + { + string shareUrl = "https://syxz.lanzoue.com/qwertyuiopas"; + string? link = await KCNLanzouLinkHelper.GetDirectLinkAsync(shareUrl); + + Console.WriteLine($"直链地址: {link}"); + } +} +``` + +获取加密链接的直链 + +```csharp +using KCNLanzouDirectLink; + +class Program +{ + static async Task Main(string[] args) + { + string shareUrl = "https://syxz.lanzoue.com/qwertyuiopas"; + string key = "your_encryption_key"; + string? linkEncryption = await KCNLanzouLinkHelper.GetDirectLinkAsync(shareUrl, key); + + Console.WriteLine($"直链地址: {linkEncryption}"); + } +} +``` + +## 许可协议 + +该项目使用 [A-GPLv3](https://opensource.org/licenses/AGPL-3.0) 许可协议。 + +## 贡献 + +欢迎提出问题、改进建议或直接提交 Pull Request! + +## 联系方式 + +- [前往我的Github](https://github.com/JDDKCN) +- [前往我的B站首页](https://space.bilibili.com/475547854/) +- [前往我的Twitter账号](https://twitter.com/2233KCN03) \ No newline at end of file diff --git a/favicon.png b/KCNLanzouDirectLink/favicon.png similarity index 100% rename from favicon.png rename to KCNLanzouDirectLink/favicon.png