Res iptv
Serijinis numeris yra parašytas ant IPTV BOX'o (dėžutės kurios pagalba žiūrite iptv per TV).
ARBA
Pažiūrėję srautą, turim gauti http user agent'o headerį t.y aprašą (tai yra iptv box'o serijinis numeris). Pagal jį ir vyksta visa http ir stream'o autorizacija. Taigi...
192.168.1.99 - iptv box'o ip
tcpdump -i eth1 -s 0 -A src host 192.168.1.99 and dst port 80
Arba jeigu nežinome tikslaus tvbox ip adreso tinkle, galime daryti taip
tcpdump -i eth1 -s 0 -A dst port 6081 -vvv -X
Gavus kažą panašaus į:
stb_xxxxxxxxxxxx
Naudodami šį gautą serijinį numerį galime užspoofinti user agentą ir gauti visą kanalų sąrašą
curl -A "USER_AGENTAS" -O http://archyvas.res.lt/playlist
Žiūrėti kiekvieną kanalą galima su vlc pagal jo m3u8 playlistą. t.y:
./vlc http://cache.res.lt:6081/hls001-live/lrt_tv.m3u8 :http-user-agent=USER_AGENTAS
Aišku tai labai nepatogu ir reikia tam pasidaryti grojaraštį:
FIXME
|
cat playlist |grep url_hls|sed -n 's!^.*>\(http[^^]*\)<.*!\1!p'|xargs wget --user-agent="USER_AGENTAS" -O playlistas.m3u
Arba paprasčiau:
cat playlist |grep url_hls|sed -n 's!^.*>\(http[^^]*\)<.*!\1!p' > play.m3u ./vlc play.m3u :http-user-agent=USER_AGENTAS
EPG Generavimas
php scriptas skirtas generuoti xml epg (angl. electronic programme guide) failus suprantamus daugelių iptv leistuvų ir media centrų, reikalinga tik pakeisti kintamejį $user_agent į jūsų box'o.
<?php
// Tool to generate compatible xml epg list based on RES IPTV json sources
// validation can be made with this tool: https://www.freeformatter.com/xml-validator-xsd.html
// script is very primitive as not error handling are made, please improve it by yourself
$user_agent = "user agentas"; // user agent used for auth with iptv servers
$write_to_xml = 1; // write static 'res-epg.xml' file
$loud = 0; // print messages can be used to load xml directly
$script_dir = dirname(__FILE__);
function getPlaylist() {
global $user_agent;
$url = "http://archyvas.res.lt/playlist";
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"User-Agent: $user_agent\r\n"
)
);
$context = stream_context_create($options);
$data = file_get_contents($url, false, $context);
$xml = simplexml_load_string($data) ;
return $xml;
}
function returnJsonEpg($chanid, $type) {
global $user_agent;
$url = "http://archyvas.res.lt:8080/$chanid/epg/$type.json";
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"User-Agent: $user_agent\r\n"
)
);
$context = stream_context_create($options);
$data = file_get_contents($url, false, $context);
return json_decode($data);
}
function ReplaceInvalidStr($str) {
$str = str_replace('"', "'", $str);
$str = str_replace('&', "&", $str);
$str = str_replace('<', "<", $str);
$str = str_replace('>', ">", $str);
return $str;
}
function ConvertJsonProgramme($obj,$chan) {
$starttime = new DateTime("@$obj->start_time");
$stoptime = (clone $starttime)->add(new DateInterval("PT{$obj->duration}S"));
$programme = '
<programme start="'.$starttime->format('YmdHis').' +0200" stop="'.$stoptime->format('YmdHis').' +0200" channel="'.$chan.'">
<title lang="lt">'.ReplaceInvalidStr($obj->name).'</title>
<desc lang="lt">'.ReplaceInvalidStr($obj->text).'</desc>
</programme>';
return $programme;
}
function start() {
global $loud, $write_to_xml, $script_dir;
$xml = getPlaylist();
$channels = $xml->xpath('//feed');
if ($loud > 0) {
header("Content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<tv generator-info-name="zjbs generator" generator-info-url="http://google.lt">';
}
if ($write_to_xml > 0) {
$f=fopen($script_dir.'/res-epg.xml','w');
fwrite($f,'<?xml version="1.0" encoding="UTF-8"?>');
fwrite($f,'<tv generator-info-name="zjbs generator" generator-info-url="http://google.lt">');
}
// generate channels
foreach ($channels as $chan) {
if ($loud > 0) {
echo '
<channel id="'.$chan->name.'">
<display-name lang="lt">'.$chan->name.'</display-name>
<url>http://google.lt</url>
</channel>';
}
if ($write_to_xml > 0) {
fwrite($f,'
<channel id="'.$chan->name.'">
<display-name lang="lt">'.$chan->name.'</display-name>
<url>http://google.lt</url>
</channel>');
}
}
// generate simple epg for each channel for one day
foreach ($channels as $chan) {
$epg_programmes = returnJsonEpg($chan->attributes()->id,"day");
foreach ($epg_programmes as $programme) {
$converted = ConvertJsonProgramme($programme,$chan->name);
if ($loud > 0) {
print $converted;
}
if ($write_to_xml > 0) {
fwrite($f,$converted);
}
}
}
if ($loud > 0) echo '</tv>';
if ($write_to_xml > 0) {
fwrite($f,'</tv>');
fclose($f);
}
}
start();
?>
Paleisti php epg_gen.php, bus sugeneruotas res_epg.xml failas kurį galima naudoti bet kuriame iptv leistuve.. Patartina leisti kas 6val arba dar rečiau ir pahostinti kur nors leistuvui prieinamoje vietoje..