-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wangzheng
committed
Apr 19, 2024
1 parent
ce104a1
commit 5b2ab9e
Showing
3 changed files
with
68 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Net.Http; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
|
||
namespace WeiboAlbumDownloader.Helpers | ||
{ | ||
public class GithubHelper | ||
{ | ||
public static async Task<string?> GetLatestVersion() | ||
{ | ||
try | ||
{ | ||
HttpClient client = new HttpClient(); | ||
var resp = await client.GetAsync("https://github.com/hupo376787/WeiboAlbumDownloader/tags"); | ||
var body = await resp.Content.ReadAsStringAsync(); | ||
string pattern = "tags.*zip"; | ||
//匹配多个 | ||
//MatchCollection list = Regex.Matches(body, pattern); | ||
//匹配第一个 | ||
Match match = Regex.Match(body, pattern); | ||
if (match.Success) | ||
{ | ||
var version = match.Value.Replace("tags/", "").Replace(".zip", ""); | ||
return version; | ||
} | ||
|
||
return null; | ||
|
||
} | ||
catch (Exception ex) | ||
{ | ||
return ex.ToString(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters