forked from rvs76/staxrip
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Showing
3 changed files
with
24 additions
and
31 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,55 +1,49 @@ | ||
Imports HtmlAgilityPack | ||
Imports System.Text.RegularExpressions | ||
Imports System.Net | ||
Imports System.IO.Compression | ||
|
||
Public Class UpdateForm | ||
Public WithEvents Progress As New WebClient | ||
Private Sub Update_Load(sender As Object, e As EventArgs) Handles MyBase.Load | ||
Try | ||
Update() | ||
Catch ex As Exception | ||
Me.Close() | ||
MsgInfo(ex.Message) | ||
End Try | ||
End Sub | ||
Private Sub Update() | ||
Dim html = "https://github.com/Revan654/staxrip/releases/latest" | ||
Dim web As HtmlWeb = New HtmlWeb() | ||
Dim htmlDoc = web.Load(html) | ||
Try | ||
Dim html = "https://github.com/Revan654/staxrip/releases/latest" | ||
Dim web As HtmlWeb = New HtmlWeb() | ||
Dim htmlDoc = web.Load(html) | ||
Try | ||
Dim node = htmlDoc.DocumentNode.SelectSingleNode("(//strong[@class='pl-1 pr-2 flex-auto min-width-0'])[1]") | ||
Dim Export As String = node.OuterHtml | ||
Dim match = Regex.Match(Export, ">(.*?)<") | ||
If match.Success Then | ||
Dim Tag = match.Groups(1).Value.ToString().Replace(".x64.7z", "") | ||
Dim FilePath = Folder.Startup + "\" + match.Groups(1).Value.ToString() | ||
Dim Results = "https://github.com/Revan654/staxrip/releases/download/" + Tag + "/" + match.Groups(1).Value.ToString() | ||
Try | ||
Dim Version = My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor & "." & My.Application.Info.Version.Build & "." & My.Application.Info.Version.Revision | ||
If Version < Tag Then | ||
Progress.DownloadFileAsync(New Uri(Results), FilePath) | ||
Else | ||
MsgInfo("Already Running the Latest Version", Nothing) | ||
Me.Close() | ||
End If | ||
Catch ex As Exception | ||
Dim node = htmlDoc.DocumentNode.SelectSingleNode("//strong[@class='pl-1 pr-2 flex-auto min-width-0']") | ||
Dim Export As String = node.OuterHtml | ||
Dim match = Regex.Match(Export, ">(.*?)<") | ||
If match.Success Then | ||
Dim Tag = match.Groups(1).Value.ToString().Replace("Staxrip.", "").Replace(".x64.rar", "") | ||
Dim FilePath = Folder.Startup + match.Groups(1).Value.ToString() | ||
Dim Results = "https://github.com/Revan654/staxrip/releases/download/" + Tag + "/" + match.Groups(1).Value.ToString() | ||
Try | ||
Dim Version = My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor & "." & My.Application.Info.Version.Build & "." & My.Application.Info.Version.Revision | ||
If Version < Tag Then | ||
Progress.DownloadFileAsync(New Uri(Results), FilePath) | ||
Else | ||
MsgInfo("Already Running the Latest Version", Nothing) | ||
Me.Close() | ||
End Try | ||
End If | ||
Catch ex As Exception | ||
Me.Close() | ||
End Try | ||
End If | ||
Catch ex As Exception | ||
MsgInfo(ex.Message) | ||
End Try | ||
End If | ||
Catch ex As Exception | ||
Me.Close() | ||
MsgInfo(ex.Message) | ||
End Try | ||
End Sub | ||
|
||
Private Sub ScrappyProgressBar_Report(sender As Object, e As DownloadProgressChangedEventArgs) Handles Progress.DownloadProgressChanged | ||
Try | ||
ScrappyProgressBar.Value = e.ProgressPercentage | ||
Catch ex As Exception | ||
Me.Close() | ||
End Try | ||
End Sub | ||
End Class |