19.1.2021, 19:25
(10.6.2020, 10:06)Saros Napsal(a): Telly v php
Token + párování:
Kód:<?php
#login
$url = 'https://backoffice0-vip.tv.itself.cz/api/device/pairDeviceByLogin/';
$ch = curl_init($url);
$jsonData = array('id_brand' => 2, 'login' => 'login','password' => 'heslo');
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$j = json_decode($result,true);
$token = $j["token"];
curl_close($ch);
#echo $token;
#save token
$file = fopen("./token.txt", "w");
fwrite($file, $token);
fclose($file);
#pairing
$url = 'https://backoffice0-vip.tv.itself.cz/api/device/completeDevicePairing/';
$ch = curl_init($url);
$jsonData = array('device_token' => $token, 'device_type_code' => 'ANDROID_4_4PLUS','model' => 'xiaomi', 'name' => 'Redmi Note 7','serial_number' => 'unknown');
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$j = json_decode($result,true);
$res = $j["success"];
curl_close($ch);
echo $res;
?>
Playlist:
Kód:<?php
#read token
$lines = file("token.txt", FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
$data = array_chunk($lines, 3);
$token = $data[0][0];
#echo $token;
#playlist
$url = 'https://backoffice0-vip.tv.itself.cz/api/device/getSources/';
$ch = curl_init($url);
$jsonData = array('device_token' => $token);
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$j = json_decode($result,true);
$res = $j["channels"];
curl_close($ch);
$file = fopen("./telly.m3u8", "w");
fwrite($file, '#EXTM3U'."\n");
foreach($res as $ch){
$name = $ch["name"];
echo $name."<br/>";
$url = $ch["content_sources"][0]["stream_profile_urls"]["adaptive"];
fwrite($file, '#EXTINF:-1,'.$name."\n".$url."\n");
}
fclose($file);
?>
melo by to jeste fungovat ???? Tyto texty jen ulozim do dvou soboru playlist.sh a token.sh a pustim ???? samozrejme chmod 755 nastaven, ale stejne kdyz pustim tak to nic nedela