kodi-pvr / pvr.stalker

A PVR Client that connects Kodi to Stalker Middleware
GNU General Public License v2.0
41 stars 64 forks source link

Thread Terminating with Exception: stoi: no conversion #189

Open Macadoshis opened 1 year ago

Macadoshis commented 1 year ago

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 :

https://github.com/kodi-pvr/pvr.stalker/blob/ef243471bc8f8c1b4d6c1d53018573e59d6172e6/src/GuideManager.cpp#L186-L191

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 (!)

https://github.com/kodi-pvr/pvr.stalker/blob/ef243471bc8f8c1b4d6c1d53018573e59d6172e6/lib/libstalkerclient/xmltv.c#L266

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 :

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.

Macadoshis commented 1 year ago

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

phunkyfish commented 1 year ago

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