I'm using an API to generate video streams, problem that I want to change some strings from link below in PHP then export them to be used as new:
https://api.blogit.vn/getlink.php?link=https://drive.google.com/file/d/0B1xQLLJtrzJoaWUxUHdqY01mRGM&json=jwplayer
The link above returns a temporary HTML script:
[{"label":360,"default":"false","type":"mp4","file":"https:\/\/redirector.googlevideo.com\/videoplayback?api=api.blogit.vn&id=002f5ad6c741e491&itag=18&source=webdrive&requiressl=yes&ttl=transient&mm=31&mn=sn-ab5l6ne7&ms=au&mv=u&nh=IgpwcjAzLmxnYTA3KgkxMjcuMC4wLjE&pl=48&mime=video\/mp4&lmt=1451968289958732&mt=1484794782&ip=2604:a880:400:d0::1300:b001&ipbits=32&expire=1484809258&sparams=ip%2Cipbits%2Cexpire%2Cid%2Citag%2Csource%2Crequiressl%2Cttl%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Cmime%2Clmt&signature=2AA8E475C2979F19490C850FDAC99E5F55888F8E.8369F59FA0DF17DBDEB6727BD4805437E2F84F29&key=ck2&app=explorer"},
{"label":480,"default":"true","type":"mp4","file":"https:\/\/redirector.googlevideo.com\/videoplayback?api=api.blogit.vn&id=002f5ad6c741e491&itag=59&source=webdrive&requiressl=yes&ttl=transient&mm=31&mn=sn-ab5l6ne7&ms=au&mv=u&nh=IgpwcjAzLmxnYTA3KgkxMjcuMC4wLjE&pl=48&mime=video\/mp4&lmt=1451968288256365&mt=1484794782&ip=2604:a880:400:d0::1300:b001&ipbits=32&expire=1484809258&sparams=ip%2Cipbits%2Cexpire%2Cid%2Citag%2Csource%2Crequiressl%2Cttl%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Cmime%2Clmt&signature=7E46471E73EA1D47A3E40A63C2F9B94559E39C67.085EFA564867C6D8226632185559F9EBECB388AD&key=ck2&app=explorer"}]
How can I change the strings in label and default, example:
360 to 360p and this to default: true instead of 480 as above
480 to 480p
720 to 720p *not visible in script above but do exist
1080 to 1080p *not visible in script above but do exist
*And of course, list them correctly as:
1080p
720p
480p
360p
Full API Example:
<?php
$link = 'https://drive.google.com/file/d/0BwBTO689s4TSeU84LU5DMkszejg';
$api = 'https://api.blogit.vn/getlink.php?link='.$link.'&json=jwplayer';;
$sources = curl($api);
function curl($url)
{
$ch = @curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$head[] = "Connection: keep-alive";
$head[] = "Keep-Alive: 300";
$head[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$head[] = "Accept-Language: en-us,en;q=0.5";
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$page = curl_exec($ch);
curl_close($ch);
return $page;
}
?>
<div id="player"></div>
<script type="text/javascript" src="https://api.blogit.vn/BITplayer/jwplayer/jwplayer-7.7.4/jwplayer.js"></script>
<script type="text/javascript">
jwplayer.key = "####jwplayer.key####";
var playerInstance = jwplayer("player");
playerInstance.setup({
id:'player',
sources: <?php echo $sources; ?>,
controls: true,
displaytitle: true,
width: "100%",
height: "100%",
aspectratio: "16:9",
fullscreen: "true",
autostart: true,
});
</script>