Advertisement
Guest User

Untitled

a guest
Apr 11th, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. sub GetBrave64() {
  2. #`{
  3. The list of revisions woudl be at:
  4. https://github.com/brave/brave-browser/releases
  5.  
  6. The download site would then be:
  7. https://github.com/brave/brave-browser/releases/download/v1.31.87/BraveBrowserStandaloneSetup.exe
  8. }
  9.  
  10. my $SubName = &?ROUTINE.name;
  11. # PrintRedErr( "$SubName not yet implemented\n" ); return;
  12.  
  13. my $BaseTag = "BraveSetup"; # Note: do not use underscores in the base tab
  14. my $Extension = ".x64.exe";
  15. my $WorkingDir = "/home/CDs/WindowsInternet/Brave/";
  16.  
  17. my $Status = %StatusHash<UNKNOWN>;
  18. my $OldRev = "";
  19. my $OldFileName = "";
  20.  
  21. my $NewRev = "0";
  22. my $NewFileName = "";
  23. my $NewFileSize = 0;
  24. my $MinFileSize = 50000000;
  25.  
  26. my Str $WebPrefix = "https://github.com";
  27. my Str $WebSite = $WebPrefix~ "/brave/brave-browser/releases"; # no trailing slash
  28. my Str $WebPage = "";
  29. my Str $ClickHere = "";
  30. my $PageStatus;
  31. my $VerTag = 0;
  32. my $Count = 0;
  33.  
  34. my $ReturnStr;
  35. my $CurlStatus;
  36.  
  37. my int $Page = 1;
  38. my Bool $ReleaseFound = False;
  39.  
  40.  
  41. print "Checking $SubName\n";
  42.  
  43. if not $WorkingDir.IO.d.Bool { mkdir "{$WorkingDir}", 0o766; }
  44.  
  45. # get the old revision and name with path
  46. ( $OldRev, $OldFileName ) = GetOldRev( $BaseTag, $Extension, $WorkingDir, $SubName, $Status );
  47.  
  48. # get the web page with the revision on it
  49. ( $WebPage, $PageStatus ) = CurlGetWebSite( $WebSite, True );
  50.  
  51. if $PageStatus != 0 {
  52. $Status +|= %StatusHash<DOWNLOAD_FAIL>;
  53. if $Debug { PrintBlue "$SubName\: Download failed WebSite = <$WebSite>\n"; }
  54.  
  55. } else {
  56. # if the web page download okay, extact the latest new revison from it
  57.  
  58. #`{
  59.  
  60. <h1 data-view-component="true" class="d-inline mr-3"><a href="/brave/brave-browser/releases/tag/v1.35.98" \
  61. data-view-component="true" class="Link--primary">Release v1.35.98 (Chromium 98.0.4758.74)
  62. https://github.com/brave/brave-browser/releases/download/v1.35.98/BraveBrowserStandaloneSetup.exe
  63.  
  64. Note: use "--location" (-L) with curl to skip all the cloak and dagger which is my default
  65.  
  66. }
  67.  
  68. while $Page < 21 {
  69. my Str $WebSitePage = $WebSite ~ "?page=" ~ "$Page";
  70.  
  71. if CurlExists( $WebSitePage ) {
  72. ( $WebPage, $PageStatus ) = CurlGetWebSite( $WebSitePage, True );
  73.  
  74. if $WebPage.contains( "Release v" ) {
  75. if $Debug { PrintGreen "$SubName\: release located on page $Page\n <$WebSitePage>\n"; }
  76. $ReleaseFound = True;
  77. last;
  78. } # contains
  79. } # if curl exists
  80. $Page += 1;
  81. } # while
  82.  
  83. if $ReleaseFound {
  84. # $ curl --location 'https://github.com/brave/brave-browser/releases/download/v1.35.98/BraveBrowserStandaloneSetup.exe' -o eraseme.exe
  85. $NewRev = $WebPage;
  86. $NewRev ~~ s/ .*? "Release v" //;
  87. $NewRev ~~ s/ $( Q[ ] ) .* //;
  88.  
  89. $ClickHere = $WebPrefix ~ "/brave/brave-browser/releases/download/v" ~ $NewRev ~ "/BraveBrowserStandaloneSetup.exe";
  90. } else {
  91. if $Debug { PrintRedErr "$SubName\: Release not located\n"; }
  92. }
  93. if $Debug { PrintBlue "$SubName\: NewRev = <$NewRev>\n$SubName\: ClickHere = <$ClickHere>\n"; }
  94.  
  95. if "$NewRev" eq "0" {
  96. $Status +|= %StatusHash<DOWNLOAD_FAIL>;
  97. PrintRedErr( "$SubName: failed to extract \$NewRev from <$WebSite>\n" );
  98.  
  99. } else {
  100. if IsCurrentRevNewer( $SubName, $NewRev, $OldRev ) {
  101. # if the new revision is greater that the old revision, download the new revision
  102.  
  103. # print "IsCurrentRevNewer = yes";
  104. $NewFileName = $WorkingDir ~ "/" ~ $BaseTag ~ "-" ~ $NewRev ~ $Extension;
  105. # print "\$NewFileName = <$NewFileName>\n";
  106.  
  107. ( $ReturnStr, $CurlStatus ) = CurlDownloadFile( "", $ClickHere, $NewFileName, %MaxTime<MaxTime2>, True );
  108. if $Debug { PrintBlue "$SubName\: CurlDownloadFile \$Status = <$Status>\n"; }
  109. if $CurlStatus == 0 {
  110. $Status +|= %StatusHash<UPDATE>;
  111. # make sure the new file has size, if so delete the old one
  112.  
  113. $NewFileSize = CheckSizeAndDelete( $OldFileName, $NewFileName, $MinFileSize, $SubName, $Status );
  114.  
  115. } else {
  116. $Status +|= %StatusHash<DOWNLOAD_FAIL>;
  117. } # if $Status=0
  118.  
  119. } else { $Status +|= %StatusHash<NO_UPDATE> } # if GetUpdates; 1 = no new updates
  120.  
  121. } # end else $NewRev
  122.  
  123. } # end else
  124.  
  125. Finalize( $WorkingDir, $SubName,
  126. $OldRev, $OldFileName,
  127. $NewRev, $NewFileName, $NewFileSize,
  128. $Status );
  129.  
  130. return $Status;
  131.  
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement