JTV format appeared thanks to the Polish programmer Yaroslav Kowalski, was originally used as part of the eponymous software for watching TV with TV tuners. It is a zip archive with a set of files. Each channel has 2 files - <channel name>.ndx and <channel name>.pdt.
They contain all the information about the start time, duration and description of the TV program. A file with the PDT extension contains information about the name of the TV programs, and a file with the NDX extension contains information about the start time of these TV programs.
The program in this format is less common than XMLTV because of the complex structure and processing inconvenience (compared to XML-format). Used by some media devices that support IPTV playback and IPTV players for PC.
Example of JTV file generation for a channel in PHP
<?php
$channel_info = array(
'name' => 'Title1', 'time' => time(),
'name' => 'Title2', 'time' => time(),
);
$pdt_file = fopen("Channel1.pdt", "wb");
$ndx_file = fopen("Channel1.ndx", "wb");
fwrite($pdt_file, "JTV 3.x TV Program Datax0Ax0Ax0A", 26);
fwrite($ndx_file, pack("v",count($channel_info)),2);
$time = $channel_info[0]['time'];
fwrite($ndx_file, pack ("v", 0), 2);
$filetime = bcmul(bcadd($time, "11644473600"), "10000000");
for ($i = 0; $i < 8; $i++) {
$byte = (int) bcmod ($filetime, "256");
fwrite($ndx_file, pack("c", $byte), 1);
$filetime = bcdiv($filetime, "256");
}
fwrite($ndx_file, pack("v",26), 2);
$programm_name = iconv ("UTF-8", "windows-1251", $channel_info[0]['name']);
$programm_name_length = strlen($programm_name);
fwrite($pdt_file, pack("v", $programm_name_length), 2);
fwrite($pdt_file, $programm_name, $programm_name_length);
$offset += $programm_name_length + 2;
?>