Skip to content

Instantly share code, notes, and snippets.

@andey
Created December 29, 2018 23:56
Show Gist options
  • Save andey/b891ed4c1c5e3ab7f80afb70ada92bb4 to your computer and use it in GitHub Desktop.
Save andey/b891ed4c1c5e3ab7f80afb70ada92bb4 to your computer and use it in GitHub Desktop.
Filter out the garbage channels, and only show me what I want to see
<?php
// download the file
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "<M3U_LINK>");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close ($ch);
// write to file
$fp = fopen('tv_channels.m3u', 'w');
fwrite($fp, $result);
fclose($fp);
// filter the file
echo "#EXTM3U\n";
exec('grep -E "^#EXTINF.*tvg\-name=\"([^#])*\".*group\-title=\"(NHL|NBA|Canada|USA Entertainment|USA Docs & News|Latino|USA Sports)\"" -A 1 tv_channels.m3u | sed "/^--$/d"', $out);
foreach($out as $line) {
echo $line."\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment