<?php
function iso8601_duration($seconds)
{
  $intervals = array('D' => 60*60*24, 'H' => 60*60, 'M' => 60, 'S' => 1);

  $pt = 'P';
  $result = '';
  foreach ($intervals as $tag => $divisor)
  {
    $qty = floor($seconds/$divisor);
    if ( !$qty && $result == '' )
    {
      $pt = 'T';
      continue;
    }

    $seconds -= $qty * $divisor;    
    $result  .= "$qty$tag";
  }
  if ( $result=='' )
    $result='0S';
  return "$pt$result";
}
require_once('getID3/getid3/getid3.php');
    $file = $_GET['link'];	
	$filename = '/home/cdn/public_html'.$file;
	$fpath = urldecode($filename);
	$getID3 = new getID3;
	$file = $getID3->analyze($filename);
	$finaltime = $file['playtime_seconds'];
	$duration = iso8601_duration($finaltime);
$data = [ 'time' => $duration ];

header('Content-Type: application/json');
echo json_encode($data);