[Solved (for Gotham)] Weighted IMDB/TMDB rating via color, based on votes
#1
Question 
I was thinking of displaying a movie's rating with different colors based upon the number of votes. Does anyone know of an example of this, or what the most efficient way to do it would be?

So that a movie like "The General (1926)" with a rating of a 8.3 with 35,000 votes might be displayed as a green 8.3, whereas a Uwe Boll movie such as "Legend of the Red Reaper (2013)" with its 71 vote's 7.7 shows up as a red 7.7. Diffusing the color over stars would work too.

I guess I'm looking for a way to know at a glance with minimal screen real estate how true the ratings are.

Something like:
less than 600 is red.
601 to 1500 is orange.
1501 to 3000 is yelllow.
3001 to 6000 is green.
6001 to 10,000 is blue.

So far I got:
Code:
    <control type="label">
    <posx>13</posx>
    <posy>1.5</posy>
    <width>89</width>
    <height>50</height>
    <align>center</align>
    <aligny>center</aligny>
    <font>Font_20B</font>
    <textcolor>$VAR[value_ratingcolor]</textcolor>
    <fadetime>FanartCrossFadeTime</fadetime>
    <label>$INFO[ListItem.Rating]</label>
    </control>
where $VAR[value_ratingcolor] would be set like:

Code:
    <variable name="value_ratingcolor">
    <value condition="!IntegerGreaterThan(ListItem.Property(RatingAndVotes),600)">FFFFFFFF</value>
    <value condition="IntegerGreaterThan(ListItem.Property(RatingAndVotes),600) + !IntegerGreaterThan(ListItem.Property(RatingAndVotes),1500)">EEFFFFFF</value>
    <value condition="IntegerGreaterThan(ListItem.Property(RatingAndVotes),1500) + !IntegerGreaterThan(ListItem.Property(RatingAndVotes),3000)">DDFFFFFF</value>
    <value condition="IntegerGreaterThan(ListItem.Property(RatingAndVotes),3000) + !IntegerGreaterThan(ListItem.Property(RatingAndVotes),6000)">CCFFFFFF</value>
    <value condition="IntegerGreaterThan(ListItem.Property(RatingAndVotes),6000)">BBFFFFFF</value>
    </variable>
(I know those colors are nowhere near correct, I'll fix that problem if I can get it to work first)

but I'm not sure how to pull just the votes out of "RatingAndVotes" to pass it to the "IntegerGreaterThan" parser.
Example:
7.7 (81,897 votes)
needs to have some coding equivalent of
(6th from the left) through (7th from the right)
something like
IntegerGreaterThan(Right(Left(ListItem.Property(RatingAndVotes),6),7),6000)
to pull the 81,897 out of the string to be able compare it with. (and probably something to strip the comma out too)


I've rummaged through about 5 skins and the wiki and can find no examples, any ideas?

I noticed that there is a future InfoLabel named ListItem.Votes planned for Gotham, but what can be done currently under Frodo to accomplish this?
Using a NUC7PJYHN and a 2820FYKH0 Intel NUC running LibreELEC, and two FireTVs.:)
Reply
#2
So I tried to just make it work in Gotham, because ListItem.Votes is already there.

So I tried:
Code:
    <variable name="value_ratingcolor">
        <value condition="!IntegerGreaterThan(ListItem.Votes,600)">FFFF0000</value>
        <value condition="IntegerGreaterThan(ListItem.Votes,600) + !IntegerGreaterThan(ListItem.Votes,1500)">FFFF5500</value>
        <value condition="IntegerGreaterThan(ListItem.Votes,1500) + !IntegerGreaterThan(ListItem.Votes,3000)">FFFFFF00</value>
        <value condition="IntegerGreaterThan(ListItem.Votes,3000) + !IntegerGreaterThan(ListItem.Votes,6000)">FF00FF00</value>
        <value condition="IntegerGreaterThan(ListItem.Votes,6000)">FF0055FF</value>
    </variable>

and

Code:
                    <control type="label">
                        <posx>755</posx>
                        <posy>-2</posy>
                        <width>45</width>
                        <height>35</height>
                        <align>right</align>
                        <aligny>center</aligny>
                        <label>$INFO[ListItem.Rating]</label>
                        <font>METF_InfoText</font>
<!--                    <textcolor>TextNF</textcolor>
-->                     <textcolor>$VAR[value_ratingcolor]</textcolor>
                        <visible>!IsEmpty(ListItem.Rating)</visible>
                    </control>

but even that doesn't work. It always just shows up as red (the top).
In Gotham every listitem is returning the correct ListItem.Votes number, but the comparison isn't working. Could it be the comma that is left in the ListItem.Votes (7,450)? Is there a method for turning a string into an integer?

Image
Using a NUC7PJYHN and a 2820FYKH0 Intel NUC running LibreELEC, and two FireTVs.:)
Reply
#3
The problem is indeed the ",". IntegerGreaterThan does a string>int conversion but it doesn't cut out separators such as "," or ".".
Image
Reply
#4
So I tried everything I could think of and in the end I got it to work (mostly).

I decided to modify the values to simplify the code needed and ended up with this:
Code:
                </control>
                    <control type="image">
                        <posx>760</posx>
                        <posy>7</posy>
                        <width>20</width>
                        <height>20</height>
                        <texture>Star.png</texture>
<!--                        <colordiffuse>FilesStarDiffuse</colordiffuse>
-->                        <colordiffuse>$VAR[value_ratingcolor]</colordiffuse>
                        <visible>!IsEmpty(ListItem.Rating)</visible>
                    </control>
and
Code:
    <variable name="value_ratingcolor">
        <value condition="!SubString(ListItem.Votes,$COMMA)">FFFF0000</value>
        <value condition="SubString(ListItem.Votes,1$COMMA,Left)">FFFF5555</value>
        <value condition="SubString(ListItem.Votes,2$COMMA,Left)">FFFFFF00</value>
        <value condition="SubString(ListItem.Votes,3$COMMA,Left)">FFFFFF00</value>
        <value condition="SubString(ListItem.Votes,4$COMMA,Left)">FFFFFF00</value>
        <value condition="SubString(ListItem.Votes,5$COMMA,Left)">FFFFFF00</value>
        <value condition="SubString(ListItem.Votes,$COMMA)">FF00FF00</value>
    </variable>
In the end it shows the star next to the rating as:
Red if there is less than a 1000 votes.
Orange if there is at least a 1000 votes.
Yellow if there are between 2000 and 5000 votes.
and Green for anything 6000 and above.

It does the job I needed.

Thanks 'Black, I would have been stuck there forever.
Image
Image
Image
[attachment=249]
[attachment=250]
[attachment=251]

It could be done for the non actively selected objects through image files, but this is good enough for what I wanted, a quick reminder.
Using a NUC7PJYHN and a 2820FYKH0 Intel NUC running LibreELEC, and two FireTVs.:)
Reply
#5
Nice feature!
Reply

Logout Mark Read Team Forum Stats Members Help
[Solved (for Gotham)] Weighted IMDB/TMDB rating via color, based on votes0