kodi-pvr / pvr.stalker

A PVR Client that connects Kodi to Stalker Middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thread Terminating with Exception: stoi: no conversion

Macadoshis opened this issue · comments

Hello @AlwinEsch , @phunkyfish,
(sorry for the mentions but you look like the only 2 guys active)

I think there's an issue in the following process :

e.year = std::stoi(p->date.substr(0, 4));
e.iconPath = p->icon;
e.genreType = p->extra.genreType;
e.genreDescription = p->extra.genreDescription;
e.firstAired = p->previouslyShown;
e.starRating = std::stoi(p->starRating.substr(0, 1));

I get following error when loading my XMLEPG :

AddOnLog: pvr.stalker: GetEPGForChannel: time range: 1662776667 - 1662949467 | 7512 - Trace Urban
AddOnLog: pvr.stalker: GetChannelEvents
Thread Terminating with Exception: stoi: no conversion

Indeed for a programme as follow :

<?xml version="1.0" encoding="UTF-8"?>
<tv>
<channel id="TraceUrban.fr">
<display-name>Trace Urban</display-name>
</channel>
<programme start="20220910133000 +0000" stop="20220910140000 +0000" channel="TraceUrban.fr">
<title lang="fr-FR" >Hits Non Stop</title>
<desc lang="fr-FR">Sélection des plus grands succès musicaux du moment.</desc>
</programme>

there's actually no default fallback in the instantiation of a programme from xml for the 2 properties date and star-rating that actually most of the XMLTV providers don't offer (!)

sc_xmltv_programme_t *sc_xmltv_parse_programme(xmlTextReaderPtr reader) {

So the std::stoi method tries to read a null value producing this error.

I've tested with the following fix, by manually adding in epg_xmltv.xml :

<?xml version="1.0" encoding="UTF-8"?>
<tv>
<channel id="TraceUrban.fr">
<display-name>Trace Urban</display-name>
</channel>
<programme start="20220910133000 +0000" stop="20220910140000 +0000" channel="TraceUrban.fr">
<title lang="fr-FR" >Hits Non Stop</title>
<desc lang="fr-FR">Sélection des plus grands succès musicaux du moment.</desc>
<date>20220910</date>
<star-rating>
<value>1</value>
</star-rating>
</programme>

and it worked (stalkerclient managed to create the guide for this program and channel).

TL;DR

So can you please :

  • Either check upon null/empty before read or instantiate by default the XMLTV::Programme#date from the start (YYYYMMDD).

  • Either check upon null/empty before read or instantiate by default the XMLTV::Programme#starRating to 0 or 1.

Thanks a lot.

I think it might help a lot of people and prevent me from having to fork just for those 2 minor fixes.

As shown in the DTD, star-rating and date are no mandatory fields, so the code should work when those 2 fields are missing.

https://github.com/XMLTV/xmltv/blob/master/xmltv.dtd

Can you PR the change? I’m happy to review it you do so. On the Nexus branch first please.