cinebench: update livecheck

This commit is contained in:
Sam Ford
2023-10-18 16:49:05 -04:00
parent 8c24517878
commit 46e92c3afa
+20 -2
View File
@@ -7,9 +7,27 @@ cask "cinebench" do
desc "Hardware benchmarking utility"
homepage "https://www.maxon.net/products/cinebench/"
# The content of the Downloads page is kept in a `payload.js` file but the
# URL contains a numeric identifier that changes when the website is updated.
# As such, we have to identify the JS file URL from the Downloads page HTML
# before fetching and checking the JS file for version information.
livecheck do
url "https://www.maxon.net/_nuxt/static/1697633267/en/downloads/cinebench-2024-downloads/payload.js"
regex(/Cinebench(\d+(?:\.\d+)*)(?:_macOS\.dmg)/i)
url "https://www.maxon.net/en/downloads"
regex(/cinebench-?[rv]?(\d+(?:\.\d+)*)-downloads/i)
strategy :page_match do |page, regex|
# Find the current JS file URL on the Downloads page
js_match = page.match(%r{href=["']?([^"' >]+?/en/downloads/payload.js[^"' >]*?)}i)
next if js_match.blank?
# Fetch the JS file (using the absolute URL)
js_response = Homebrew::Livecheck::Strategy.page_content(
URI.join(@url, js_match[1]).to_s,
)
next if (js_content = js_response[:content]).blank?
# Identify the version from the versioned downloads page URL
js_content.scan(regex).map { |match| match[0] }
end
end
depends_on macos: ">= :big_sur"