我有兩個 m3u8 播放列表,其中包含許多我試圖匹配在一起的流。來自 Playlist01 的每個鏈接在第二個鏈接中都有它的一對 - Playlist02 并且每一對都有一個公共頻道 ID,我想通過它進(jìn)行匹配。Playlist01 包含如下鏈接:#EXTM3U#EXTINF:-1 tvg-id="Name01" tvg-logo="http://link.png" tvg-chno="100" group-titles="groupone", Name01path/playlist.php?ch=5101-ab#EXTINF:-1 tvg-id="Name02" tvg-logo="http://link.png" tvg-chno="160" group-titles="groupone", Name02path/playlist.php?ch=5102-ab#EXTINF:-1 tvg-id="Name03" tvg-logo="http://link.png" tvg-chno="650" group-titles="groupone", Name03path/playlist.php?ch=6234-ab然后是帶有鏈接的 Playlist02,例如:#EXTM3U#EXTINF:-1 tvg-id="Name01" tvg-logo="http://link.png" tvg-chno="100" group-titles="groupone", Name01http://link345/at/a31350ff5/857183/5101-ab.m3u8#EXTINF:-1 tvg-id="Name02" tvg-logo="http://link.png" tvg-chno="160" group-titles="groupone", Name02http://link574/at/bn350frf5/675494/5102-ab.m3u8#EXTINF:-1 tvg-id="Name03" tvg-logo="http://link.png" tvg-chno="650" group-titles="groupone", Name03http://link674/at/g4K7J7h0r/845987/6234-ab.m3u8當(dāng)然還有一些 Playlist.php,它可以幫助我將來自兩個播放列表的鏈接配對在一起。在 Playlist.php 中,我從 Playlist02 讀取數(shù)據(jù)<?php$string = file_get_contents('playlist02.m3u8'); // reading data from playlist02preg_match_all('/(?P<tag>#EXTINF:-1)|(?<link>http[^\s]+)/', $string, $match ); // parsing data – I want to get just the url links$count = count( $match[0] );$result = [];$index = -1;for( $i =0; $i < $count; $i++ ){ $item = $match[0][$i]; if( !empty($match['tag'][$i])){ //is a tag increment the result index ++$index; }elseif( !empty($match['link'][$i])){ $result[$index]['link'] = $item ; }}print_r( $result );
PHP - 如何通過流 url 的公共部分匹配來自兩個 m3u8 播放列表的流?
呼喚遠(yuǎn)方
2023-04-21 10:54:02