Skip to content

Instantly share code, notes, and snippets.

@Mo45
Created December 11, 2018 09:15
Show Gist options
  • Save Mo45/6adca2b319ab9cff1f10552b0b0a7672 to your computer and use it in GitHub Desktop.
Save Mo45/6adca2b319ab9cff1f10552b0b0a7672 to your computer and use it in GitHub Desktop.
Fetch and display channels list from IPTV playlist (*.m3u)
<!DOCTYPE html>
<html>
<head>
<title>IPTV Channels</title>
</head>
<body>
<ul>
<?php
$file = './list.m3u'; //IPTV-playlist
$searchfor = '#EXTINF:-1';//Pattern for searching
$contents = file_get_contents($file);
$pattern = preg_quote($searchfor, '/');
$pattern = "/^.*$pattern.*\$/m";
if(preg_match_all($pattern, $contents, $matches)){}
else{echo "No matches found";}
foreach($matches[0] as $m){
$channel = explode(",", $m);
echo "<li>" . $channel[1] . "</li>";
};
?>
</ul>
</body>
</html>
#EXTM3U
#EXTINF:-1 group-title="Example Group ", Channel 1
http://10.232.0.15:9101/index.m3u8
#EXTINF:-1,Channel 2
http://10.232.0.15:9102/index.m3u8
#EXTINF:-1,Channel 3
http://10.232.0.15:9105/index.m3u8
#EXTINF:-1,Channel 4
http://10.232.0.15:9106/index.m3u8
#EXTINF:-1,Channel 5
http://10.232.0.15:9109/index.m3u8
#EXTINF:-1,Channel 6
http://10.232.0.15:9110/index.m3u8
#EXTINF:-1,Channel 7
@linhbear2021
Copy link

Why can't this code load the m3u list?

@Mo45
Copy link
Author

Mo45 commented Oct 16, 2020

Why can't this code load the m3u list?

¯_(ツ)_/¯

@linhbear2021
Copy link

linhbear2021 commented Oct 17, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment