Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread Terminating with Exception: stoi: no conversion #189

Open
Macadoshis opened this issue Sep 11, 2022 · 2 comments
Open

Thread Terminating with Exception: stoi: no conversion #189

Macadoshis opened this issue Sep 11, 2022 · 2 comments

Comments

@Macadoshis
Copy link

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.

@Macadoshis
Copy link
Author

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
Copy link
Member

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

Macadoshis pushed a commit to Macadoshis/pvr.stalker that referenced this issue Sep 12, 2022
Macadoshis pushed a commit to Macadoshis/pvr.stalker that referenced this issue Sep 17, 2022
Macadoshis pushed a commit to Macadoshis/pvr.stalker that referenced this issue Sep 20, 2022
Macadoshis pushed a commit to Macadoshis/pvr.stalker that referenced this issue Sep 21, 2022
phunkyfish added a commit that referenced this issue Sep 21, 2022
(Matrix) Fix issue #189 : "year" and "starRating" are optional in xmltv contract
phunkyfish added a commit that referenced this issue Sep 21, 2022
(Nexus) Fix issue #189 : "year" and "starRating" are optional in xmltv contract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants