Skip to content

Commit

Permalink
2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Revan654 committed Jan 18, 2019
1 parent 106c77e commit 070476d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Forms/MainForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -6028,7 +6028,7 @@ Public Class MainForm
Sub UpdateStaxRip()
Using f As New UpdateForm
Try
f.Show()
f.ShowDialog()
Catch ex As Exception
End Try
End Using
Expand Down
1 change: 0 additions & 1 deletion Forms/UpdateForm.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 23 additions & 29 deletions Forms/UpdateForm.vb
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

0 comments on commit 070476d

Please sign in to comment.