Content-Length: 283963 | pFad | http://github.com/Hill-98/mpv-config/commit/637fc38e8ff4bb6efea22e9533478804506eb7f6

9C 脚本: check-update: 支持自定义 mpv 相关正则表达式 · Hill-98/mpv-config@637fc38 · GitHub
Skip to content

Commit

Permalink
脚本: check-update: 支持自定义 mpv 相关正则表达式
Browse files Browse the repository at this point in the history
  • Loading branch information
Hill-98 committed Feb 13, 2024
1 parent a6c5939 commit 637fc38
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ mpv 检查间隔: `check_update-check_mpv_interval=[number] # 每 N 天检查一

mpv 检查源: `check_update-check_mpv_repo=[mpv-build-github-repo] # GitHub 上的 mpv 构建仓库。默认: shinchiro/mpv-winbuild-cmake (https://github.com/shinchiro/mpv-winbuild-cmake)`

mpv 本地版本正则表达式: `check_update-mpv_local_version_regex=[JS RegExp string] # 默认: -g([a-z0-9-]{7})`

mpv 远程发布名称正则表达式: `check_update-mpv_remote_name_regex=[JS RegExp string] # 默认: -([\w]+-git-[a-z0-9]{7})`

mpv 远程发布版本正则表达式: `check_update-mpv_remote_version_regex=[JS RegExp string] # 默认: -git-([a-z0-9-]{7})`

HTTP 代理: `check_update-http_proxy=[http-proxy] # 检查更新时使用的 HTTP 代理。默认: 无`

### [Format Filename](scripts/format-filename.js)
Expand Down
10 changes: 7 additions & 3 deletions scripts/check-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ var options = {
check_mpv_update: false,
check_mpv_repo: 'shinchiro/mpv-winbuild-cmake',
check_mpv_interval: 1,
mpv_local_version_regex: '-g([a-z0-9-]{7})',
mpv_remote_name_regex: '-([\\w]+-git-[a-z0-9]{7})',
mpv_remote_version_regex: '-git-([a-z0-9-]{7})',
http_proxy: '',
};
var checking_state = {};
Expand Down Expand Up @@ -100,7 +103,7 @@ function get_config_local_version() {
*/
function get_mpv_local_version() {
var mpv_version = mp.get_property_native('mpv-version').trim();
var matches = mpv_version.match(/-g([a-z0-9-]{7})/);
var matches = mpv_version.match(new RegExp(options.mpv_local_version_regex));
return matches === null ? null : matches[1];
}

Expand Down Expand Up @@ -152,8 +155,8 @@ function get_mpv_remote_version(remote_repo, cb) {
if (name.indexOf('mpv-x86_64-') !== 0) {
continue;
}
var name_matches = name.match(/-([\w]+-git-[a-z0-9]{7})/);
var version_matches = name.match(/-git-([a-z0-9-]{7})/);
var name_matches = name.match(new RegExp(options.mpv_remote_name_regex));
var version_matches = name.match(new RegExp(options.mpv_remote_version_regex));
if (version_matches !== null) {
cb(null, {
name: name_matches === null ? null : name_matches[1],
Expand Down Expand Up @@ -240,6 +243,7 @@ function check_mpv_update(force) {
var check_update_interval = parse_interval(options.check_mpv_interval);
var local_version = get_mpv_local_version();
var remote_repo = options.check_mpv_repo;
msg.info(local_version);

if (local_version === null) {
msg.error('检查 mpv 更新失败: 未获取到本地版本');
Expand Down

0 comments on commit 637fc38

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/Hill-98/mpv-config/commit/637fc38e8ff4bb6efea22e9533478804506eb7f6

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy