0
Completed
Arjan Gorinsek 1 month ago in Modules • updated 4 weeks ago 5

Is there a way to create a tv guide from a XML file.

I use a XMLTV file in kodi and works great. https://forum.kodi.tv/showthread.php?tid=120377

Maybe someone has a JS for reading these files or maybe other option to create a guide?

 

This is what a sample xmltv file looks like

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE tv SYSTEM "xmltv.dtd">

 

<tv source-info-url="http://www.schedulesdirect.org/" source-info-name="Schedules Direct" generator-info-name="XMLTV/$Id: tv_grab_na_dd.in,v 1.70 2008/03/03 15:21:41 rmeden Exp $" generator-info-url="http://www.xmltv.org/">

  <channel id="I10436.labs.zap2it.com">

    <display-name>13 KERA</display-name>

    <display-name>13 KERA TX42822:-</display-name>

    <display-name>13</display-name>

    <display-name>13 KERA fcc</display-name>

    <display-name>KERA</display-name>

    <display-name>KERA</display-name>

    <display-name>PBS Affiliate</display-name>

    <icon src="file://C:\Perl\site/share/xmltv/icons/KERA.gif" />

  </channel>

  <channel id="I10759.labs.zap2it.com">

    <display-name>11 KTVT</display-name>

    <display-name>11 KTVT TX42822:-</display-name>

    <display-name>11</display-name>

    <display-name>11 KTVT fcc</display-name>

    <display-name>KTVT</display-name>

    <display-name>KTVT</display-name>

    <display-name>CBS Affiliate</display-name>

    <icon src="file://C:\Perl\site/share/xmltv/icons/KTVT.gif" />

  </channel>

  <programme start="20080715003000 -0600" stop="20080715010000 -0600" channel="I10436.labs.zap2it.com">

    <title lang="en">NOW on PBS</title>

    <desc lang="en">Jordan's Queen Rania has made job creation a priority to help curb the staggering unemployment rates among youths in the Middle East.</desc>

    <date>20080711</date>

    <category lang="en">Newsmagazine</category>

    <category lang="en">Interview</category>

    <category lang="en">Public affairs</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">EP01006886.0028</episode-num>

    <episode-num system="onscreen">427</episode-num>

    <audio>

      <stereo>stereo</stereo>

    </audio>

    <previously-shown start="20080711000000" />

    <subtitles type="teletext" />

  </programme>

  <programme start="20080715010000 -0600" stop="20080715023000 -0600" channel="I10436.labs.zap2it.com">

    <title lang="en">Mystery!</title>

    <sub-title lang="en">Foyle's War, Series IV: Bleak Midwinter</sub-title>

    <desc lang="en">Foyle investigates an explosion at a munitions factory, which he comes to believe may have been premeditated.</desc>

    <date>20070701</date>

    <category lang="en">Anthology</category>

    <category lang="en">Mystery</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">EP00003026.0665</episode-num>

    <episode-num system="onscreen">2705</episode-num>

    <audio>

      <stereo>stereo</stereo>

    </audio>

    <previously-shown start="20070701000000" />

    <subtitles type="teletext" />

  </programme>

  <programme start="20080715023000 -0600" stop="20080715040000 -0600" channel="I10436.labs.zap2it.com">

    <title lang="en">Mystery!</title>

    <sub-title lang="en">Foyle's War, Series IV: Casualties of War</sub-title>

    <desc lang="en">The murder of a prominent scientist may have been due to a gambling debt.</desc>

    <date>20070708</date>

    <category lang="en">Anthology</category>

    <category lang="en">Mystery</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">EP00003026.0666</episode-num>

    <episode-num system="onscreen">2706</episode-num>

    <audio>

      <stereo>stereo</stereo>

    </audio>

    <previously-shown start="20070708000000" />

    <subtitles type="teletext" />

  </programme>

  <programme start="20080715040000 -0600" stop="20080715043000 -0600" channel="I10436.labs.zap2it.com">

    <title lang="en">BBC World News</title>

    <desc lang="en">International issues.</desc>

    <category lang="en">News</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">SH00315789.0000</episode-num>

    <previously-shown />

    <subtitles type="teletext" />

  </programme>

  <programme start="20080715043000 -0600" stop="20080715050000 -0600" channel="I10436.labs.zap2it.com">

    <title lang="en">Sit and Be Fit</title>

    <date>20070924</date>

    <category lang="en">Exercise</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">EP00003847.0074</episode-num>

    <episode-num system="onscreen">901</episode-num>

    <audio>

      <stereo>stereo</stereo>

    </audio>

    <previously-shown start="20070924000000" />

    <subtitles type="teletext" />

  </programme>

  <programme start="20080715060000 -0600" stop="20080715080000 -0600" channel="I10759.labs.zap2it.com">

    <title lang="en">The Early Show</title>

    <desc lang="en">Republican candidate John McCain; premiere of the film "The Dark Knight."</desc>

    <date>20080715</date>

    <category lang="en">Talk</category>

    <category lang="en">News</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">EP00337003.2361</episode-num>

    <audio>

      <stereo>stereo</stereo>

    </audio>

    <subtitles type="teletext" />

  </programme>

  <programme start="20080715080000 -0600" stop="20080715090000 -0600" channel="I10759.labs.zap2it.com">

    <title lang="en">Rachael Ray</title>

    <desc lang="en">Actresses Kim Raver, Brooke Shields and Lindsay Price ("Lipstick Jungle"); women in their 40s tell why they got breast implants; a 30-minute meal.</desc>

    <credits>

      <presenter>Rachael Ray</presenter>

    </credits>

    <date>20080306</date>

    <category lang="en">Talk</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">EP00847333.0303</episode-num>

    <episode-num system="onscreen">2119</episode-num>

    <audio>

      <stereo>stereo</stereo>

    </audio>

    <previously-shown start="20080306000000" />

    <subtitles type="teletext" />

  </programme>

  <programme start="20080715090000 -0600" stop="20080715100000 -0600" channel="I10759.labs.zap2it.com">

    <title lang="en">The Price Is Right</title>

    <desc lang="en">Contestants bid for prizes then compete for fabulous showcases.</desc>

    <credits>

      <director>Bart Eskander</director>

      <producer>Roger Dobkowitz</producer>

      <presenter>Drew Carey</presenter>

    </credits>

    <category lang="en">Game show</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">SH00004372.0000</episode-num>

    <audio>

      <stereo>stereo</stereo>

    </audio>

    <subtitles type="teletext" />

    <rating system="VCHIP">

      <value>TV-G</value>

    </rating>

  </programme>

  <programme start="20080715100000 -0600" stop="20080715103000 -0600" channel="I10759.labs.zap2it.com">

    <title lang="en">Jeopardy!</title>

    <credits>

      <presenter>Alex Trebek</presenter>

    </credits>

    <date>20080715</date>

    <category lang="en">Game show</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">EP00002348.1700</episode-num>

    <episode-num system="onscreen">5507</episode-num>

    <subtitles type="teletext" />

    <rating system="VCHIP">

      <value>TV-G</value>

    </rating>

  </programme>

  <programme start="20080715103000 -0600" stop="20080715113000 -0600" channel="I10759.labs.zap2it.com">

    <title lang="en">The Young and the Restless</title>

    <sub-title lang="en">Sabrina Offers Victoria a Truce</sub-title>

    <desc lang="en">Jeff thinks Kyon stole the face cream; Nikki asks Nick to give David a chance; Amber begs Adrian to go to Australia.</desc>

    <credits>

      <actor>Peter Bergman</actor>

      <actor>Eric Braeden</actor>

      <actor>Jeanne Cooper</actor>

      <actor>Melody Thomas Scott</actor>

    </credits>

    <date>20080715</date>

    <category lang="en">Soap</category>

    <category lang="en">Series</category>

    <episode-num system="dd_progid">EP00004422.1359</episode-num>

    <episode-num system="onscreen">8937</episode-num>

    <audio>

      <stereo>stereo</stereo>

    </audio>

    <subtitles type="teletext" />

    <rating system="VCHIP">

      <value>TV-14</value>

    </rating>

  </programme>

</tv>

 




+1
IR.AddListener(IR.EVENT_START,0,function()
{
   pXMLTV.request(function(resp) {
      try {
         if (resp.tv[0]  !== undefined) {
            IR.Log("TEMPERATURE is " + resp.tv.channel.url);
            for (j=0; j<pXMLTV.lngth(resp.tv.channel); j++) {
              IR.Log(resp.tv.channel[j]["display-name"]);
              IR.Log('------------------////----------------');
            }
            for (k=0; k<pXMLTV.lngth(resp.tv.programme); k++) {
              st=pXMLTV.ctime(resp.tv.programme[k]["@start"]);
              et=pXMLTV.ctime(resp.tv.programme[k]["@stop"]);
              IR.Log(resp.tv.programme[k]["title"] + " ["+st + 
              " - " + et + "]") ;
            }
            //IR.Log(typeof resp.main.temp)
            //IR.GetDevice("HDL-BUS Pro Network (UDP)").Set("HVAC:temp", resp.main.temp); //type conversion warring!
         } 
      } catch (e) {
         IR.Log("Something is wrong \n" + e); // error handler 
      } 
   });
});
var pXMLTV  = {};
pXMLTV.dev = IR.CreateDevice(IR.DEVICE_CUSTOM_HTTP_TCP, "pXMLTV_dev", 
{Host: "raspored.hrt.hr",
            Port: 80,
            SSL: false,
            ScriptMode: IR.DIRECT_AND_SCRIPT,
            SendCommandAttempts: 0,
            ConnectWaitTimeMax: 3000,
            ReceiveWaitTimeMax: 5000
});
pXMLTV.request = function(in_callback){
      pXMLTV.dev.Connect(); // Must be
        pXMLTV.dev.SendEx({
            Type: "GET",
            Url: "/format/xmltv.xml?mreza=2",
            /*Headers: {
            "Content-Type": "application/json"
            },*/
            cbReceiveText: function(text, code, headers) {
            
            if (code != 200) return; //parse other error codes!
                var resp = new XML(text);
            //BUG: new XML return always  null || Ticket ID: #11928
            pXMLTV.dev.Disconnect();            
            in_callback(resp);            
            },
        });
   }
   
pXMLTV.lngth= function(node) { //childNode does not have the length property || Ticket ID: #11929
   var i = 0;
   while (node[i] !== undefined) ++i;
   return i;
}
pXMLTV.ctime= function(tme) { //
   return tme.replace(
    /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)\s([+-])(\d{4})$/,
    '$2/$3/$1 $4:$5:$6' //bug with GMT/UTC ;
    );
} 

Arjan, have you solved your task?

Andrey, thanks for the reply.

I was on vacation , I will test it this evening.

Andrey,


I was unable to create a tv guide. Do you have a example project?

Here is a short xml file XMLTV.