Kodi Community Forum

Full Version: [Solved] Help with NHK World live stream
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I got it. Here's the XML if anyone wants it.

Code:
<item>
<title>NHK WORLD</title>
<link>rtmp://ny-1.srv.fivecool.net/nhkw/gwm swfUrl=http://www3.nhk.or.jp/nhkworld/r/movie/streamhub_player20130222.swf pageUrl=http://www3.nhk.or.jp/nhkworld/w/movie/</link>
<thumbnail>http://cdn.realscreen.com/wp/wp-content/uploads/2012/02/nhk.jpg</thumbnail>
</item>>
see first post
Thanks for this info! I've been looking for a way to view this stream using IPTVSimple. I got it working perfect and even have created a simple DOS program to get the EPG from the NHK World site and add it to my XMLTV file from mc2xml.

If anyone is interested here is the code I created. I'm including the code in case the url/structure changes in the future.

I used mc2xml from http://mc2xml.hosterbox.net and wget from http://users.ugent.be/~bpuype/wget/. Both files were put into a resources folder too keep things nice and organized.

IPTVSimple
Code:
#EXTINF:-1 tvg-id="NHKWorld" tvg-name="NHKWorld" tvg-logo=""  tvg-shift="-13" group-title="Cable",1 NHK World
rtmp://ny-1.srv.fivecool.net/nhkw/gwm swfUrl=http://www3.nhk.or.jp/nhkworld/r/movie/streamhub_player20130222.swf pageUrl=http://www3.nhk.or.jp/nhkworld/w/movie/

C++ Code to convert NHK World RSS feed to XMLTV format.
Code:
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;

int main(int argc, char** argv)
{
    int start = 1;

    ofstream xmlfile;
    xmlfile.open("nhk.xml");

    system(".\\resources\\wget.exe -O nhk.rss http://www3.nhk.or.jp/nhkworld/english/epg/nhkworld_program.xml");

/* Start XMLTV File Structure
   =========================  ========================= */
    xmlfile << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
    xmlfile << "<!DOCTYPE tv SYSTEM \"xmltv.dtd\">\n\n";
    xmlfile << "<tv source-info-name=\"Zap2it\" generator-info-name=\"mcxml\" generator-info-url=\"mailto:[email protected]\">\n";
    xmlfile << "    <channel id=\"NHKWorld\">\n";
    xmlfile << "        <display-name>NHK World</display-name>\n";
    xmlfile << "    </channel>\n";

    ifstream file;

/* Read RSS data into Structure
   =========================  ========================= */
    file.open("nhk.rss");
    int i = 0;

    while(!file.eof())
    {
        char buffer[1024];
        char starttime[21];
        char time[3][21];
        char title[3][1024];
        char description[3][1024];

        file.getline(buffer,1024);
        string temp = (char*)buffer;

        // Check Start Time
        if(strncmp(buffer,"<pubDate>",9) == 0)
        {
            time[i][0]  = buffer[21];
            time[i][1]  = buffer[22];
            time[i][2]  = buffer[23];
            time[i][3]  = buffer[24];
            time[i][4]  = 'X';
            time[i][5]  = 'X';
            time[i][6]  = buffer[14];
            time[i][7]  = buffer[15];
            time[i][8]  = buffer[26];
            time[i][9]  = buffer[27];
            time[i][10] = buffer[29];
            time[i][11] = buffer[30];
            time[i][12] = buffer[32];
            time[i][13] = buffer[33];
            time[i][14] = ' ';
            time[i][15] = buffer[35];
            time[i][16] = buffer[36];
            time[i][17] = buffer[37];
            time[i][18] = buffer[38];
            time[i][19] = buffer[39];
            time[i][20] = '\0';

            if     ((buffer[17] == 'J') && (buffer[18] == 'a') && (buffer[19] == 'n')) { time[i][4] = '0'; time[i][5] = '1'; }
            else if((buffer[17] == 'F') && (buffer[18] == 'e') && (buffer[19] == 'b')) { time[i][4] = '0'; time[i][5] = '2'; }
            else if((buffer[17] == 'M') && (buffer[18] == 'a') && (buffer[19] == 'r')) { time[i][4] = '0'; time[i][5] = '3'; }
            else if((buffer[17] == 'A') && (buffer[18] == 'p') && (buffer[19] == 'r')) { time[i][4] = '0'; time[i][5] = '4'; }
            else if((buffer[17] == 'M') && (buffer[18] == 'a') && (buffer[19] == 'y')) { time[i][4] = '0'; time[i][5] = '5'; }
            else if((buffer[17] == 'J') && (buffer[18] == 'u') && (buffer[19] == 'n')) { time[i][4] = '0'; time[i][5] = '6'; }
            else if((buffer[17] == 'J') && (buffer[18] == 'u') && (buffer[19] == 'l')) { time[i][4] = '0'; time[i][5] = '7'; }
            else if((buffer[17] == 'A') && (buffer[18] == 'u') && (buffer[19] == 'g')) { time[i][4] = '0'; time[i][5] = '8'; }
            else if((buffer[17] == 'S') && (buffer[18] == 'e') && (buffer[19] == 'p')) { time[i][4] = '0'; time[i][5] = '9'; }
            else if((buffer[17] == 'O') && (buffer[18] == 'c') && (buffer[19] == 't')) { time[i][4] = '1'; time[i][5] = '0'; }
            else if((buffer[17] == 'N') && (buffer[18] == 'o') && (buffer[19] == 'v')) { time[i][4] = '1'; time[i][5] = '1'; }
            else if((buffer[17] == 'D') && (buffer[18] == 'e') && (buffer[19] == 'c')) { time[i][4] = '1'; time[i][5] = '2'; }
            else                                                                       { time[i][4] = 'X'; time[i][5] = 'X'; }

            if(start == 1)
            {
                if(i == 1) { strcpy(starttime,time[0]); }
            }
        }

        // Check Title
        if(strncmp(buffer,"<title>",7) == 0)
        {
            temp.erase(0,7);
            temp.erase(strlen(temp.c_str()) - 8,8);
            strcpy(title[i],temp.c_str());
        }

        // Check Description
        if(strncmp(buffer,"<description>",13) == 0)
        {
            temp.erase(0,13);
            temp.erase(strlen(temp.c_str()) - 14,14);
            strcpy(description[i],temp.c_str());
        }

        // Check Program Setup
        if((strncmp(buffer,"<item>",6) == 0) || (strncmp(buffer,"</channel>",10) == 0))
        {
            if(start == 1)
            {
                if(i == 1) start = 0;
                i++;
            }
            else
            switch(i)
            {
                case 0:
                    xmlfile << "    <programme start=\"" << time[2] << "\" stop=\"" << time[0] << "\" channel=\"NHKWorld\">\n";
                    xmlfile << "        <title lang=\"en\">" << title[2] << "</title>\n";
                    xmlfile << "        <desc lang=\"en\">" << description[2] << "</desc>\n";
                    xmlfile << "    </programme>\n";
                    i = 1;
                    break;
                case 1:
                    xmlfile << "    <programme start=\"" << time[0] << "\" stop=\"" << time[1] << "\" channel=\"NHKWorld\">\n";
                    xmlfile << "        <title lang=\"en\">" << title[0] << "</title>\n";
                    xmlfile << "        <desc lang=\"en\">" << description[0] << "</desc>\n";
                    xmlfile << "    </programme>\n";
                    i = 2;
                    break;
                default:
                    xmlfile << "    <programme start=\"" << time[1] << "\" stop=\"" << time[2] << "\" channel=\"NHKWorld\">\n";
                    xmlfile << "        <title lang=\"en\">" << title[1] << "</title>\n";
                    xmlfile << "        <desc lang=\"en\">" << description[1] << "</desc>\n";
                    xmlfile << "    </programme>\n";
                    i = 0;
                    break;
            }
        }
    }

    file.close();

    xmlfile << "</tv>\n";
    xmlfile.close();

    system(".\\resources\\mc2xml.exe -I nhk.xml -D .\\resources\\mx2xml.dat -o XMLTV.xml");
    system("erase nhk.rss");
    system("erase nhk.xml");

    return 0;
}