我正在使用 JMeter 测试流媒体服务器的 HLS 播放。因此,第一个 HTTP 请求是针对主 list 文件 (m3u8)。说,
http://myserver/application1/subpath1/file1.m3u8
对此的回复将产生一个类似于以下内容的播放列表:
subsubFolder/360p/file1.m3u8
subsubFolder/480p/file1.m3u8
subsubFolder/720p/file1.m3u8
因此,下一组 URL 变为
http://myserver/application1/subpath1/subsubFolder/360p/file1.m3u8
http://myserver/application1/subpath1/subsubFolder/480p/file1.m3u8
http://myserver/application1/subpath1/subsubFolder/720p/file1.m3u8
现在,对这些进一步的单独回复将是 block 的索引,例如
0/file1.ts
1/file1.ts
2/file2.ts
3/file3.ts
同样,我们有下一组 URL
http://myserver/application1/subpath1/subsubFolder/360p/0/file1.ts
http://myserver/application1/subpath1/subsubFolder/360p/1/file1.ts
http://myserver/application1/subpath1/subsubFolder/360p/2/file1.ts
http://myserver/application1/subpath1/subsubFolder/360p/3/file1.ts
这只是一套(360p)的情况。还会有 2 套这样的(480p、720p)。
我希望到目前为止要求声明是明确的。
现在,问题陈述。
使用<a href="http://myserver/application1" rel="noreferrer noopener nofollow">http://myserver/application1</a>
作为静态部分, regex(.+?).m3u8 应用于第一个回复,给出 subpath1/subsubFolder/360p/file1
。然后再次将其添加到静态部分,得到 <a href="http://myserver/application1/subpath1/subsubFolder/360p/file1" rel="noreferrer noopener nofollow">http://myserver/application1/subpath1/subsubFolder/360p/file1</a> + .m3u8
问题出现在下一阶段。正如您所看到的,通过之前提取的部分,我得到的只是
http://myserver/application1/subpath1/subsubFolder/360p/file1/0/file1.ts
问题很明显,多了一个 file1,360p/file1 代替了 360p/0。
任何建议、意见或替代方法表示赞赏。
最佳答案
如果我正确理解了这个问题,那么您所需要的只是文件名,因为可以用它来构造其他 URL。我不会使用 http://myserver/application1
作为正则表达式的静态部分,而是尝试直接获取文件名:
([^\/.]+)\.m3u8$
# match one or more characters that are not a forward slash or a period
# followed by a period
# followed by the file extension (m3u8)
# anchor the whole match to the end
现在考虑您的网址,例如http://myserver/application1/subpath1/subsubFolder/360p/file1.m3u8
,上面的正则表达式将捕获file1
,参见 working demo这里。现在您可以构建其他 URL,例如(伪代码):
http://myserver/application1/subpath1/subsubFolder/360p/ + filename + .m3u8
http://myserver/application1/subpath1/subsubFolder/360p/ + filename + /0/ + filename + .ts
这就是你所追求的吗?
关于java - 使用 JMeter 测试 HLS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34311191/