📄 epg.cpp
字号:
{ "6.7.3", "Mild scenes of blood and gore (including medical procedures, injuries from accidents, terrorists attack, murder, disaster, war)" },
{ "6.7.3.1", "One mild scene of blood and gore" },
{ "6.7.3.2", "Occasional mild scenes of blood and gore" },
{ "6.7.3.3", "Frequent mild scenes of blood and gore" },
{ "6.7.4", "Severe scenes of blood and gore (as 6.7.3 above)" },
{ "6.7.4.1", "One severe scene of blood and gore" },
{ "6.7.4.2", "Occasional severe scenes of blood and gore (as 6.7.3 above)" },
{ "6.7.4.3", "Frequent severe scenes of blood and gore (as 6.7.3 above)" },
{ "6.7.5", "Scenes with extreme horror effects" },
{ "6.7.5.1", "One scene with extreme horror effects" },
{ "6.7.5.2", "Occasional scenes with extreme horror effects" },
{ "6.7.5.3", "Frequent scenes with extreme horror effects" },
{ "6.8", "DISCRIMINATION" },
{ "6.8.1", "No discrimination descriptors" },
{ "6.8.2", "Deliberate discrimination or the portrayal of deliberate discrimination" },
{ "6.9", "ILLEGAL DRUGS" },
{ "6.9.1", "No illegal drugs descriptors" },
{ "6.9.2", "Portrayal of illegal drug use" },
{ "6.9.2.1", "One scene of illegal drug use" },
{ "6.9.2.2", "Occasional portrayal of illegal drug use" },
{ "6.9.2.3", "Frequent portrayal of illegal drug use" },
{ "6.9.3", "Portrayal of illegal drug use with instructive detail" },
{ "6.9.3.1", "One scene of illegal drug use with instructive detail" },
{ "6.9.3.2", "Occasional portrayal of illegal drug use with instructive detail" },
{ "6.9.3.3", "Frequent portrayal of illegal drug use with instructive detail" },
{ "7", "GroupRecommendation" },
{ "7.0", "Proprietary" },
{ "7.1", "Linear" },
{ "7.1.1", "Audio only" },
{ "7.1.2", "Video only" },
{ "7.1.3", "Audio and video" },
{ "7.1.4", "Multimedia" },
{ "7.1.4.1", "Text" },
{ "7.1.4.2", "Graphics" },
{ "7.1.4.3", "Application" },
{ "7.1.5", "Data" },
{ "7.2", "Non Linear" },
{ "7.2.1", "Audio only" },
{ "7.2.2", "Video only" },
{ "7.2.3", "Audio and video" },
{ "7.2.4", "Multimedia" },
{ "7.2.4.1", "Text" },
{ "7.2.4.2", "Graphics" },
{ "7.2.4.3", "Application" },
{ "7.2.5", "Data" },
{ "7.3", "AUDIO VIDEO ENHANCEMENTS" },
{ "7.3.1", "Linear with non-sync" },
{ "7.3.10", "Linear broadcast with online insertions" },
{ "7.3.11", "Other" },
{ "7.3.2", "Linear with sync" },
{ "7.3.3", "Multi stream audio" },
{ "7.3.4", "Multi stream video" },
{ "7.3.5", "Non-linear one stream av show" },
{ "7.3.6", "Non-linear multi stream" },
{ "7.3.7", "Hybrid NVOD" },
{ "7.3.8", "Mix and match" },
{ "7.3.9", "Parallel 'layer controlled' audio or video support" },
{ "8", "Commercial advert" },
{ "8.0", "Proprietary" },
{ "8.1", "Alternative" },
{ "8.10", "Confrontational" },
{ "8.11", "Contemporary" },
{ "8.12", "Crazy" },
{ "8.13", "Cutting edge" },
{ "8.14", "Eclectic" },
{ "8.15", "Edifying" },
{ "8.16", "Exciting" },
{ "8.17", "Fast-moving" },
{ "8.18", "Frantic" },
{ "8.19", "Fun" },
{ "8.2", "Analytical" },
{ "8.20", "Gripping" },
{ "8.21", "Gritty" },
{ "8.22", "Gutsy" },
{ "8.23", "Happy" },
{ "8.24", "Heart-rending" },
{ "8.25", "Heart-warming" },
{ "8.26", "Hot" },
{ "8.27", "Humorous" },
{ "8.28", "Innovative" },
{ "8.29", "Insightful" },
{ "8.3", "Astonishing" },
{ "8.30", "Inspirational" },
{ "8.31", "Intriguing" },
{ "8.32", "Irreverent" },
{ "8.33", "Laid back" },
{ "8.34", "Outrageous" },
{ "8.35", "Peaceful" },
{ "8.36", "Powerful" },
{ "8.37", "Practical" },
{ "8.38", "Rollercoaster" },
{ "8.39", "Romantic" },
{ "8.4", "Ambitious" },
{ "8.40", "Rousing" },
{ "8.41", "Sad" },
{ "8.42", "Satirical" },
{ "8.43", "Serious" },
{ "8.44", "Sexy" },
{ "8.45", "Shocking" },
{ "8.46", "Silly" },
{ "8.47", "Spooky" },
{ "8.48", "Stunning" },
{ "8.49", "Stylish" },
{ "8.5", "Black" },
{ "8.50", "Terrifying" },
{ "8.51", "Thriller" },
{ "8.52", "Violent" },
{ "8.53", "Wacky" },
{ "8.6", "Breathtaking" },
{ "8.7", "Chilling" },
{ "8.8", "Coarse" },
{ "8.9", "Compelling" },
{ "9", "Direct product purchase" },
{ 0, 0 },
};
EPG::EPG ()
{
for(int i=0; true; i++){
if(genre_list[i].genre == 0)
break;
genres[genre_list[i].genre] = genre_list[i].desc;
}
dir = EPG_SAVE_PATH;
servicesFilename = dir + "/services.xml";
loadChannels (servicesFilename);
saveChannels (servicesFilename);
}
void
EPG::addChannel (const QString & label, uint32_t sid)
{
if (!sids.contains (label))
{
sids[label] = sid;
saveChannels (servicesFilename);
}
}
void
EPG::select (const QString & chan, const CDateAndTime & d)
{
if (!sids.contains (chan))
{
return;
}
uint32_t sid = sids[chan];
progs.clear ();
/* look for the basic profile */
QString fileName;
fileName = dir + "/" + QString (epgFilename (d, sid, 1, false).c_str ());
getFile (basic, fileName);
/* look for the advanced profile */
fileName = dir + "/" + QString (epgFilename (d, sid, 1, true).c_str ());
getFile (advanced, fileName);
if (progs.count () == 0)
{
return;
}
}
void
EPG::getFile (CEPGDecoder & epg, const QString & fileName)
{
epg.doc.setContent (QString (""));
QFile file (fileName);
if (!file.open (IO_ReadOnly))
{
return;
}
vector < _BYTE > vecData;
vecData.resize (file.size ());
vecData.resize (file.size ());
file.readBlock ((char *) &vecData.front (), file.size ());
file.close ();
epg.decode (vecData);
QDomNodeList programmes = epg.doc.elementsByTagName ("programme");
parseDoc (programmes.item (0));
}
void
EPG::parseDoc (const QDomNode & n)
{
QDomNode l1 = n;
while (!l1.isNull ())
{
if (l1.nodeName () == "programme")
{
QDomNode l2 = l1.firstChild ();
uint32_t shortId =
l1.toElement ().attribute ("shortId", "0").toInt ();
CProg p;
if (progs.contains (shortId))
p = progs[shortId];
while (!l2.isNull ())
{
if (l2.isElement ())
{
QDomElement e = l2.toElement ();
if (e.tagName () == "location")
{
QDomNode l3 = e.firstChild ();
while (!l3.isNull ())
{
if (l3.isElement ())
{
QDomElement e = l3.toElement ();
if (e.tagName () == "time")
{
QString start =
e.
attribute
("actualTime");
if (start != "")
{
p.start =
parseStart
(start);
p.duration =
parseDuration
(e.
attribute
("actualDuration"));
}
else
{
start =
e.
attribute
("time");
if (start != "")
{
p.start =
parseStart
(start);
p.duration =
parseDuration
(e.
attribute
("duration"));
}
}
}
}
l3 = l3.nextSibling ();
}
}
if ((e.tagName () == "mediumName") && (p.name == ""))
p.name = e.text ();
if (e.tagName () == "longName")
p.name = e.text ();
if (e.tagName () == "mediaDescription")
{
QDomNode l3 = e.firstChild ();
while (!l3.isNull ())
{
if (l3.isElement ())
{
QDomElement e = l3.toElement ();
if (e.tagName () ==
"shortDescription")
{
p.description = e.text ();
}
}
l3 = l3.nextSibling ();
}
}
if (e.tagName () == "genre")
{
QString genre = e.attribute ("href");
int i = genre.findRev(':');
if(i != -1)
genre = genre.mid(i+1);
QString type = e.attribute ("type", "main");
if (type == "main")
p.mainGenre.push_back( genres[genre]);
else if (type == "secondary")
p.secondaryGenre.push_back( genres[genre]);
else if (type == "other")
p.otherGenre.push_back( genres[genre]);
}
}
l2 = l2.nextSibling ();
}
if (shortId != 0)
{
progs[shortId] = p;
}
}
l1 = l1.nextSibling ();
}
}
/*
<service>
<serviceID id="e1.ce15.c221.0" />
<shortName>Radio 1</shortName>
<mediumName>BBC Radio 1</mediumName>
</service>
*/
void
EPG::saveChannels (const QString & fileName)
{
QFile f (fileName);
if (!f.open (IO_WriteOnly))
{
return;
}
QDomDocument doc ("serviceInformation");
QDomElement root = doc.createElement ("serviceInformation");
doc.appendChild (root);
QDomElement ensemble = doc.createElement ("ensemble");
root.appendChild (ensemble);
for (QMap < QString, uint32_t >::Iterator i = sids.begin ();
i != sids.end (); i++)
{
QDomElement service = doc.createElement ("service");
QDomElement serviceID = doc.createElement ("serviceID");
serviceID.setAttribute ("id",
QString::number (ulong (i.data ()), 16));
service.appendChild (serviceID);
QDomElement shortName = doc.createElement ("shortName");
QDomText text = doc.createTextNode (i.key ());
shortName.appendChild (text);
service.appendChild (shortName);
ensemble.appendChild (service);
}
QTextStream stream (&f);
stream << doc.toString ();
f.close ();
}
void
EPG::loadChannels (const QString & fileName)
{
sids.clear ();
QDomDocument domTree;
QFile f (fileName);
if (!f.open (IO_ReadOnly))
{
sids.insert ("BBCWorld Service", 0xE1C238);
return;
}
if (!domTree.setContent (&f))
{
f.close ();
return;
}
f.close ();
QDomNodeList ensembles = domTree.elementsByTagName ("ensemble");
QDomNode n = ensembles.item (0).firstChild ();
while (!n.isNull ())
{
if (n.nodeName () == "service")
{
QDomNode e = n.firstChild ();
QString name, sid;
while (!e.isNull ())
{
if (e.isElement ())
{
QDomElement s = e.toElement ();
if (s.tagName () == "shortName")
name = s.text ();
if (s.tagName () == "serviceID")
sid = s.attribute ("id");
}
e = e.nextSibling ();
}
if (name != "")
{
sids.insert (name, sid.toUInt (NULL, 16));
}
}
n = n.nextSibling ();
}
}
QString
EPG::parseStart (const QString & start)
{
QStringList d = QStringList::split ('+', start, true);
QStringList t = QStringList::split ('T', d[0], true);
QStringList hms = QStringList::split (':', t[1], true);
if (hms[2] == "00")
return hms[0] + ":" + hms[1];
else
return t[1];
}
QString
EPG::parseDuration (const QString & duration)
{
QRegExp r ("[PTHMS]");
QStringList dur = QStringList::split (r, duration);
return
QCString ("").sprintf ("%02u:%02u", dur[0].toInt (), dur[1].toInt ());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -