有什么方法可以将 link 的开头添加到未知的 m3u8 文件中
Is there any way to add a starting of link to a unknown m3u8 file
我最近写了一段代码,它使用 file_get_contents
以及一些 USER_AGENT
headers 和其他 headers 来获取 m3u8
文件的源代码,回显时它看起来像以下
#EXTM3U #EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=1280x720,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=1500000,BANDWIDTH=1870000 tracks-v1a1/mono.m3u8?token=XYZ_YIE2kpAL6yriswpbrwGAvA%3D%3D%2C1608554743.5691007667
现在我写了一个代码来添加
http://example.com/mono.php?
到 url (tracks-v1a1 one )
我写的代码是
$test_value = str_replace('tracks-v1a1/mono.m3u8?token=' . "(*^\)", "http://example.com/mono.php/tracks-v1a1/mono.m3u8?token=" . "-1/", $hs2);
我也尝试过使用preg_replace
但是没有成功,谁能找出我的错误。
已编辑
根据第四只鸟先生的link和代码
以下代码非常有效
<?php
$hs2 = '#EXTM3U #EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=1280x720,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=1500000,BANDWIDTH=1870000 tracks-v1a1/mono.m3u8?token=XYZ_YIE2kpAL6yriswpbrwGAvA%3D%3D%2C1608554743.5691007667';
$pattern = "~tracks-v1a1/mono\.m3u8\?token=\S+~";
$replacement = "http://example.com/mono.php?[=13=]";
$test_value = preg_replace($pattern, $replacement, $hs2);
echo $test_value;
非常感谢'The Fourth Bird '先生,
你可以使用
$hs2 = '#EXTM3U #EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=1280x720,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=1500000,BANDWIDTH=1870000 tracks-v1a1/mono.m3u8?token=XYZ_YIE2kpAL6yriswpbrwGAvA%3D%3D%2C1608554743.5691007667';
$pattern = "~tracks-v1a1/mono\.m3u8\?token=\S+~";
$replacement = "http://example.com/mono.php?[=10=]";
$test_value = preg_replace($pattern, $replacement, $hs2);
echo $test_value;
输出
#EXTM3U #EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=1280x720,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=1500000,BANDWIDTH=1870000 http://example.com/mono.php?tracks-v1a1/mono.m3u8?token=XYZ_YIE2kpAL6yriswpbrwGAvA%3D%3D%2C1608554743.5691007667
看到一个php demo
我最近写了一段代码,它使用 file_get_contents
以及一些 USER_AGENT
headers 和其他 headers 来获取 m3u8
文件的源代码,回显时它看起来像以下
#EXTM3U #EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=1280x720,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=1500000,BANDWIDTH=1870000 tracks-v1a1/mono.m3u8?token=XYZ_YIE2kpAL6yriswpbrwGAvA%3D%3D%2C1608554743.5691007667
现在我写了一个代码来添加
http://example.com/mono.php?
到 url (tracks-v1a1 one )
我写的代码是
$test_value = str_replace('tracks-v1a1/mono.m3u8?token=' . "(*^\)", "http://example.com/mono.php/tracks-v1a1/mono.m3u8?token=" . "-1/", $hs2);
我也尝试过使用preg_replace
但是没有成功,谁能找出我的错误。
已编辑 根据第四只鸟先生的link和代码 以下代码非常有效
<?php
$hs2 = '#EXTM3U #EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=1280x720,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=1500000,BANDWIDTH=1870000 tracks-v1a1/mono.m3u8?token=XYZ_YIE2kpAL6yriswpbrwGAvA%3D%3D%2C1608554743.5691007667';
$pattern = "~tracks-v1a1/mono\.m3u8\?token=\S+~";
$replacement = "http://example.com/mono.php?[=13=]";
$test_value = preg_replace($pattern, $replacement, $hs2);
echo $test_value;
非常感谢'The Fourth Bird '先生,
你可以使用
$hs2 = '#EXTM3U #EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=1280x720,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=1500000,BANDWIDTH=1870000 tracks-v1a1/mono.m3u8?token=XYZ_YIE2kpAL6yriswpbrwGAvA%3D%3D%2C1608554743.5691007667';
$pattern = "~tracks-v1a1/mono\.m3u8\?token=\S+~";
$replacement = "http://example.com/mono.php?[=10=]";
$test_value = preg_replace($pattern, $replacement, $hs2);
echo $test_value;
输出
#EXTM3U #EXT-X-STREAM-INF:CLOSED-CAPTIONS=NONE,RESOLUTION=1280x720,FRAME-RATE=25.000,CODECS="avc1.4d001f,mp4a.40.2",AVERAGE-BANDWIDTH=1500000,BANDWIDTH=1870000 http://example.com/mono.php?tracks-v1a1/mono.m3u8?token=XYZ_YIE2kpAL6yriswpbrwGAvA%3D%3D%2C1608554743.5691007667
看到一个php demo