Created
December 29, 2018 23:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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