Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub GetBrave64() {
- #`{
- The list of revisions woudl be at:
- https://github.com/brave/brave-browser/releases
- The download site would then be:
- https://github.com/brave/brave-browser/releases/download/v1.31.87/BraveBrowserStandaloneSetup.exe
- }
- my $SubName = &?ROUTINE.name;
- # PrintRedErr( "$SubName not yet implemented\n" ); return;
- my $BaseTag = "BraveSetup"; # Note: do not use underscores in the base tab
- my $Extension = ".x64.exe";
- my $WorkingDir = "/home/CDs/WindowsInternet/Brave/";
- my $Status = %StatusHash<UNKNOWN>;
- my $OldRev = "";
- my $OldFileName = "";
- my $NewRev = "0";
- my $NewFileName = "";
- my $NewFileSize = 0;
- my $MinFileSize = 50000000;
- my Str $WebPrefix = "https://github.com";
- my Str $WebSite = $WebPrefix~ "/brave/brave-browser/releases"; # no trailing slash
- my Str $WebPage = "";
- my Str $ClickHere = "";
- my $PageStatus;
- my $VerTag = 0;
- my $Count = 0;
- my $ReturnStr;
- my $CurlStatus;
- my int $Page = 1;
- my Bool $ReleaseFound = False;
- print "Checking $SubName\n";
- if not $WorkingDir.IO.d.Bool { mkdir "{$WorkingDir}", 0o766; }
- # get the old revision and name with path
- ( $OldRev, $OldFileName ) = GetOldRev( $BaseTag, $Extension, $WorkingDir, $SubName, $Status );
- # get the web page with the revision on it
- ( $WebPage, $PageStatus ) = CurlGetWebSite( $WebSite, True );
- if $PageStatus != 0 {
- $Status +|= %StatusHash<DOWNLOAD_FAIL>;
- if $Debug { PrintBlue "$SubName\: Download failed WebSite = <$WebSite>\n"; }
- } else {
- # if the web page download okay, extact the latest new revison from it
- #`{
- <h1 data-view-component="true" class="d-inline mr-3"><a href="/brave/brave-browser/releases/tag/v1.35.98" \
- data-view-component="true" class="Link--primary">Release v1.35.98 (Chromium 98.0.4758.74)
- https://github.com/brave/brave-browser/releases/download/v1.35.98/BraveBrowserStandaloneSetup.exe
- Note: use "--location" (-L) with curl to skip all the cloak and dagger which is my default
- }
- while $Page < 21 {
- my Str $WebSitePage = $WebSite ~ "?page=" ~ "$Page";
- if CurlExists( $WebSitePage ) {
- ( $WebPage, $PageStatus ) = CurlGetWebSite( $WebSitePage, True );
- if $WebPage.contains( "Release v" ) {
- if $Debug { PrintGreen "$SubName\: release located on page $Page\n <$WebSitePage>\n"; }
- $ReleaseFound = True;
- last;
- } # contains
- } # if curl exists
- $Page += 1;
- } # while
- if $ReleaseFound {
- # $ curl --location 'https://github.com/brave/brave-browser/releases/download/v1.35.98/BraveBrowserStandaloneSetup.exe' -o eraseme.exe
- $NewRev = $WebPage;
- $NewRev ~~ s/ .*? "Release v" //;
- $NewRev ~~ s/ $( Q[ ] ) .* //;
- $ClickHere = $WebPrefix ~ "/brave/brave-browser/releases/download/v" ~ $NewRev ~ "/BraveBrowserStandaloneSetup.exe";
- } else {
- if $Debug { PrintRedErr "$SubName\: Release not located\n"; }
- }
- if $Debug { PrintBlue "$SubName\: NewRev = <$NewRev>\n$SubName\: ClickHere = <$ClickHere>\n"; }
- if "$NewRev" eq "0" {
- $Status +|= %StatusHash<DOWNLOAD_FAIL>;
- PrintRedErr( "$SubName: failed to extract \$NewRev from <$WebSite>\n" );
- } else {
- if IsCurrentRevNewer( $SubName, $NewRev, $OldRev ) {
- # if the new revision is greater that the old revision, download the new revision
- # print "IsCurrentRevNewer = yes";
- $NewFileName = $WorkingDir ~ "/" ~ $BaseTag ~ "-" ~ $NewRev ~ $Extension;
- # print "\$NewFileName = <$NewFileName>\n";
- ( $ReturnStr, $CurlStatus ) = CurlDownloadFile( "", $ClickHere, $NewFileName, %MaxTime<MaxTime2>, True );
- if $Debug { PrintBlue "$SubName\: CurlDownloadFile \$Status = <$Status>\n"; }
- if $CurlStatus == 0 {
- $Status +|= %StatusHash<UPDATE>;
- # make sure the new file has size, if so delete the old one
- $NewFileSize = CheckSizeAndDelete( $OldFileName, $NewFileName, $MinFileSize, $SubName, $Status );
- } else {
- $Status +|= %StatusHash<DOWNLOAD_FAIL>;
- } # if $Status=0
- } else { $Status +|= %StatusHash<NO_UPDATE> } # if GetUpdates; 1 = no new updates
- } # end else $NewRev
- } # end else
- Finalize( $WorkingDir, $SubName,
- $OldRev, $OldFileName,
- $NewRev, $NewFileName, $NewFileSize,
- $Status );
- return $Status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement