创建 Homebrew cask 时出现问题(livecheck 无法找到最新版本)

Issue creating a Homebrew cask (livecheck unable to find the latest version)

我正在尝试为 Tentacle Sync Studio 提交 cask,但我遇到了 livecheck 无法找到最新版本的问题。我 运行 brew audit --new-cask tentacle-sync-studio 并收到以下错误 - Version '1.30' differs from '' retrieved by livecheck.

cask "tentacle-sync-studio" do
  version "1.30"
  sha256 "4f7bdaef85b78f576babac91d57da3b3276cc98a2f81ac621bea96a48fe8796a"

  url "https://tentaclesync.com/files/downloads/ttsyncstudio-v#{version.dots_to_underscores}.dmg"
  name "Tentacle Sync Studio"
  desc "Automatically synchronize video and audio via timecode"
  homepage "https://tentaclesync.com/"
  
  livecheck do
    url "https://tentaclesync.zendesk.com/hc/en-us/articles/115003866805-Tentacle-Sync-Studio-macOS-"
    strategy :page_match
    regex(%r{/v?(\d+(?:\.\d+)+)/ttsyncstudio\.dmg}i)
  end

  depends_on macos: ">= :high_sierra"

  app "Tentacle Sync Studio.app"
end

我可能没有使用正确的“策略”,尽管阅读了 Homebrew 的说明,但老实说我不知道​​如何设置正则表达式。感谢任何帮助。

vitalsource-bookshelf木桶had a similar issue:

Previous livecheck URL had Cloudflare protection, use API URL instead.

你会想要改变

https://tentaclesync.zendesk.com/hc/en-us/articles/115003866805-Tentacle-Sync-Studio-macOS-

https://tentaclesync.zendesk.com/api/v2/help_center/en-us/articles/115003866805

但是,必须进行一些更改才能使实时检查生效:

  1. 将正则表达式更改为 href=.*?/ttsyncstudio-v?(\d+(?:[._-]\d+)+)\.dmg

    • 我们要匹配这个字符串:href=\"https://tentaclesync.com/files/downloads/ttsyncstudio-v1_30.dmg
    • href=.*?homebrew/cask
    • 中的约定
    • [._-] 匹配点、下划线或连字符(另一种约定)
  2. strategy :page_match中添加do,将下划线改为点:

    strategy :page_match do |page, regex|
      page.scan(regex).map { |match| match[0].tr("_", ".") }
    end
    

    match[0]对应正则捕获(\d+(?:[._-]\d+)+)

最后,您的 cask 文件应该类似于 this