Remove Query Strings from URLs in M3U Playlist using PHP
You can use the PHP str_replace() function to remove the unwanted query strings from the URLs in the text. Here's an example code:
<?php
$txt = '#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:11
#EXTINF:10.000,
5101070959_5097625319_111301.mp4_0-0.ts?jmhm=5e06310d49eac7fbfe985f266bf2bda3&videocodec=h264&bean=mgspwww&encrypt=8aac62dbe986aca37151d1f9ec88834d&hls_type=2&HlsSubType=2&HlsProfileId=0&mtv_session=f8678313db7bcc4443d4f8012c186cdd
#EXTINF:10.000,
5101070959_5097625319_111301.mp4_0-1.ts?jmhm=5e06310d49eac7fbfe985f266bf2bda3&videocodec=h264&bean=mgspwww&encrypt=c2475d030f82515f74dbc801327966bf&hls_type=2&HlsSubType=2&HlsProfileId=0&mtv_session=f8678313db7bcc4443d4f8012c186cdd
#EXTINF:10.000,
5101070959_5097625319_111301.mp4_0-2.ts?jmhm=5e06310d49eac7fbfe985f266bf2bda3&videocodec=h264&bean=mgspwww&encrypt=86aeaeb2701ebf56e7c09aee64eba19c&hls_type=2&HlsSubType=2&HlsProfileId=0&mtv_session=f8678313db7bcc4443d4f8012c186cdd';
// Remove query strings from URLs
$txt = str_replace('?jmhm=5e06310d49eac7fbfe985f266bf2bda3&videocodec=h264&bean=mgspwww&encrypt=8aac62dbe986aca37151d1f9ec88834d&hls_type=2&HlsSubType=2&HlsProfileId=0&mtv_session=f8678313db7bcc4443d4f8012c186cdd', '', $txt);
$txt = str_replace('?jmhm=5e06310d49eac7fbfe985f266bf2bda3&videocodec=h264&bean=mgspwww&encrypt=c2475d030f82515f74dbc801327966bf&hls_type=2&HlsSubType=2&HlsProfileId=0&mtv_session=f8678313db7bcc4443d4f8012c186cdd', '', $txt);
$txt = str_replace('?jmhm=5e06310d49eac7fbfe985f266bf2bda3&videocodec=h264&bean=mgspwww&encrypt=86aeaeb2701ebf56e7c09aee64eba19c&hls_type=2&HlsSubType=2&HlsProfileId=0&mtv_session=f8678313db7bcc4443d4f8012c186cdd', '', $txt);
echo $txt;
?>
This code will remove the specified query strings from the URLs and output the modified text:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:11
#EXTINF:10.000,
5101070959_5097625319_111301.mp4_0-0.ts
#EXTINF:10.000,
5101070959_5097625319_111301.mp4_0-1.ts
#EXTINF:10.000,
5101070959_5097625319_111301.mp4_0-2.ts
原文地址: https://www.cveoy.top/t/topic/o64j 著作权归作者所有。请勿转载和采集!