bpking1 / embyExternalUrl

some emby/jellyfin scripts
MIT License
784 stars 136 forks source link

反馈一个疑似bug #256

Closed NASA0719 closed 3 months ago

NASA0719 commented 4 months ago

1.发现一个疑似bug,emby2Alist/nginx/conf.d/common/util.js文件中

function getFilePathPart(url) {
  const matches = url.match(/\/False\/(.*)|\/d\/(.*)/);
  return matches && matches[1] ? matches[1] : "";
}

这部分如果strm文件中链接是http://xxx/d/115/那么匹配不到,只能匹配到/False/这种格式,交换/d/False又只能匹配到/d

chen3861229 commented 4 months ago

多谢反馈,确实正则写得有问题,已修复

/**
 * 1.CloudDrive
 * http://mydomain:19798/static/http/mydomain:19798/False//AList/xxx.mkv
 * 2.AList
 * http://mydomain:5244/d/AList/xxx.mkv
 * see: https://regex101.com/r/Gd3JUH/1
 * @param {String} url full url
 * @returns "/AList/xxx.mkv" or "AList/xxx.mkv" or ""
 */
function getFilePathPart(url) {
  const matches = url.match(/(?:\/False\/|\/d\/)(.*)/g);
  return matches ? matches[1] : "";
}
NASA0719 commented 3 months ago
function getFilePathPart(url) {
  const matches = url.match(/(?:\/False\/|\/d\/)(.*)/g);
  return matches ? matches[1] : "";
}

大佬,再请教两个问题, 1.conf.d/common/util.js文件注释下面这里之后strm文件中的路径编码失效,这个不知道符不符合预期

const redirectStrmLastLinkRule = [
  // [0, strHead.lanIp.map(s => "http://" + s)],
];

日志如下: 2024/07/25 22:11:15 [warn] 63#63: 7671 js: notLocal: true 2024/07/25 22:11:15 [warn] 63#63: 7671 js: notLocal decodeURIComponent embyRes.path 2024/07/25 22:11:15 [warn] 63#63: 7671 js: mount emby file path: http://10.0.0.2:5555/d/115/电视剧/欧美剧/绝命毒师 (2008)/xxx 2024/07/25 22:11:15 [warn] 63#63: 7671 js: sourceStrValue, r.args.X-Emby-Client = Emby Theater 2024/07/25 22:11:15 [warn] 63#63: 7671 js: sourceStrValue, r.args.X-Emby-Client = Emby Theater 2024/07/25 22:11:15 [warn] 63#63: 7671 js: getRouteMode: redirect 2024/07/25 22:11:15 [warn] 63#63: 7671 js: mediaPathMapping: [] 2024/07/25 22:11:15 [warn] 63#63: 7671 js: mapped emby file path: http://10.0.0.2:5555/d/115/电视剧/欧美剧/绝命毒师 (2008)/xxx 2024/07/25 22:11:15 [warn] 63#63: *7671 js: redirect to: http://10.0.0.2:5555/d/115/电视剧/欧美剧/绝命毒师 (2008)/xxx

2.这里提到的nginx日志定期自动清理是注释conf.d/emby.conf文件这里吗?我注释了也没有生效

# global schedule task, since njs 0.8.1
    location @periodics {
        # to be run at 7 day intervals in worker process 0
        js_periodic periodics.logHandler interval=7d;
chen3861229 commented 3 months ago

1.和注释的那个无关,是我正则写错了,测试不够充分,需要去掉正则结尾的 g

function getFilePathPart(url) {
  const matches = url.match(/(?:\/False\/|\/d\/)(.*)/);
  return matches ? matches[1] : "";
}

2.确实是这里,默认是 7d , 也就是 7天清空一次,测试的话可以改成秒数单位,更加直观查看结果,不过需要注意 njs 版本 >= 0.8.1

# global schedule task, since njs 0.8.1
    location @periodics {
        # to be run at 7 day intervals in worker process 0
        js_periodic periodics.logHandler interval=5s;
    }
NASA0719 commented 3 months ago

1.和注释的那个无关,是我正则写错了,测试不够充分,需要去掉正则结尾的 g

function getFilePathPart(url) {
  const matches = url.match(/(?:\/False\/|\/d\/)(.*)/);
  return matches ? matches[1] : "";
}

2.确实是这里,默认是 7d , 也就是 7天清空一次,测试的话可以改成秒数单位,更加直观查看结果,不过需要注意 njs 版本 >= 0.8.1

# global schedule task, since njs 0.8.1
    location @periodics {
        # to be run at 7 day intervals in worker process 0
      js_periodic periodics.logHandler interval=5s;
    }

感谢回复,按你说的解决了,问题2是用户不一致,nginx.config文件里的user改为root就好了