Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加WinGet爬虫模板 #137

Open
xrgzs opened this issue Oct 11, 2024 · 4 comments
Open

增加WinGet爬虫模板 #137

xrgzs opened this issue Oct 11, 2024 · 4 comments

Comments

@xrgzs
Copy link
Contributor

xrgzs commented Oct 11, 2024

类似 Scoop 爬虫模板,增加 WinGet 爬虫模板

实现思路:

  1. 指定 PackageId 参数

  2. 下载:https://cdn.winget.microsoft.com/cache/source2.msix 并解压

  3. 加载数据库:\Public\index.db

  4. 从数据库中获取对应 PackageIdhash

  5. 获取软件版本信息: https://cdn.winget.microsoft.com/cache/packages/${PackageId}/${hex.toString()}/versionData.mszyml

    • VersionYAML.version.v
    • RelativePathYAML.version.rP
  6. 进一步获取该版本的软件下载地址等信息:https://cdn.winget.microsoft.com/cache/${RelativePath}

@Cnotech
Copy link
Member

Cnotech commented Oct 11, 2024

应该不需要这么麻烦吧,winget 也是把 manifest 存 GitHub 仓库里面的,是不是用这种路径就 OK 了:https://github.com/microsoft/winget-pkgs/blob/master/manifests/7/7zip/7zip/24.08/7zip.7zip.installer.yaml

@xrgzs
Copy link
Contributor Author

xrgzs commented Oct 11, 2024

这种方式的话无需Github Token来获取版本号,而且最终获取的Manifest是Singleton Mode,无需手动合并

这里有代码可以参考: https://github.com/ustclug/ustcmirror-images/tree/master/winget-source

@xrgzs
Copy link
Contributor Author

xrgzs commented Oct 11, 2024

补充一下,第 5 步那个接口返回的 .mszyml 是经过 MSZIP 压缩的 YAML,上面提供的那个仓库里面有 decode 的方法

@xrgzs
Copy link
Contributor Author

xrgzs commented Nov 5, 2024

发现个坑,WinGet服务器返回的 YAML 中 PackageVersion 数据类型需要注意一下。

比如:https://cdn.winget.microsoft.com/cache/manifests/g/GPSoftware/DirectoryOpus/13.10/d1cb

对应仓库中的文件:https://github.com/microsoft/winget-pkgs/blob/master/manifests/g/GPSoftware/DirectoryOpus/13.10/GPSoftware.DirectoryOpus.installer.yaml

GitHub 中有双引号,返回配置文件里面无,部分 YAML 库会将无引号的版本号识别成小数,导致版本识别错误,如这里的 13.10 会识别成 13.1。

不清楚 Typescript 中会不会像这样。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants