Skip to content

Commit bd762ef

Browse files
committed
Properly translate star ratings in XMLTV parser.
Convert from zero based star-ratings in XMLTV to one based star-ratings in MythTV. (cherry picked from commit c12af87)
1 parent 65d92fd commit bd762ef

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mythtv/programs/mythfilldatabase/xmltvparser.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,20 @@ ProgInfo *XMLTVParser::parseProgram(QDomElement &element)
371371
// In the case of uk_rt it's not unknown for a recommendation
372372
// to be given to programmes which are 'so bad, you have to
373373
// watch!'
374+
//
375+
// XMLTV uses zero based ratings and signals no rating by absence.
376+
// A rating from 1 to 5 is encoded as 0/4 to 4/4.
377+
// MythTV uses zero to signal no rating!
378+
// The same rating is encoded as 0.2 to 1.0 with steps of 0.2, it
379+
// is not encoded as 0.0 to 1.0 with steps of 0.25 because
380+
// 0 signals no rating!
381+
// See http://xmltv.cvs.sourceforge.net/viewvc/xmltv/xmltv/xmltv.dtd?revision=1.47&view=markup#l539
374382
item = values.item(0).toElement();
375383
if (!item.isNull())
376384
{
377385
stars = getFirstText(item);
378-
num = stars.section('/', 0, 0);
379-
den = stars.section('/', 1, 1);
386+
num = stars.section('/', 0, 0) + 1;
387+
den = stars.section('/', 1, 1) + 1;
380388
if (0.0 < den.toFloat())
381389
rating = num.toFloat()/den.toFloat();
382390
}

0 commit comments

Comments
 (0)