[mythtv] mythfilldatabase is adding credits out of order

TimP mythtv at corky.co
Tue Dec 11 12:33:36 UTC 2018

Hi Mythtics,

I've looked in the code and it's way beyond me so hopefully someone can 
help me fix this:

I get listings from tv_grab_zz_sdjson and that has credits in billing 
order. I use that and a bit of a database hack in an attempt to list the 
actors in a tv progam in billing order. Most of the time it works but I 
noticed this today.

XML from tv_grab_zz_sdjson:

<programme start="20181225232000 +0000" stop="20181226014500 +0000" 
<title>The Silence of the Lambs</title>
<desc>Multi-Oscar-winning thriller about a trainee female FBI agent 
<director>Jonathan Demme</director>
<actor role="Clarice Starling">Jodie Foster</actor>
<actor role="Dr. Hannibal Lecter">Anthony Hopkins</actor>
<actor role="Jack Crawford">Scott Glenn</actor>
<actor role="Jame "Buffalo Bill" Gumb">Ted Levine</actor>
<actor role="Dr. Frederick Chilton">Anthony Heald</actor>
<actor role="Catherine Martin">Brooke Smith</actor>
<actor role="Senator Ruth Martin">Diane Baker</actor>
<actor role="Ardelia Mapp">Kasi Lemmons</actor>
<actor role="Lt. Boyle">Charles Napier</actor>
<actor role="FBI Director Hayden Burke">Roger Corman</actor>
<actor role="FBI Agent in Memphis">George A. Romero</actor>
<writer>Thomas Harris</writer>
<writer>Ted Tally</writer>
<producer>Grace Blake</producer>
<producer>Ron Bozman</producer>
<producer>Gary Goetzman</producer>
<producer>Edward Saxon</producer>
<producer>Kenneth Utt</producer>
<category>Crime drama</category>

That looks fine but my daily email has this:

The Silence of the Lambs (ITV4 Thriller film 1991 100%)
       Charles Napier, Roger Corman, George A. Romero, Kasi Lemmons, 
Brooke Smith
    Multi-Oscar-winning thriller about a trainee female FBI agent who is
    seconded to the hunt for a horrific serial killer. For insight into 
    workings of his diseased mind she turns to the psychotic yet urbane 
    Hannibal "the Cannibal" Lecter, with whom she forms a compelling and
    dangerous relationship.

The hack I use to try to get a list of actors in order is this SQL:

"alter table credits add column localrank int auto_increment primary 

I do this before fetching the listings, generate my list of new programs 
into an email and then remove the localrank column so the credits table 
is restored to standard format.

The SQL to extract program data is this:

"select localrank, role, name from credits, people where credits.person 
= people.person and chanid = $chanid and starttime = 
from_unixtime($unix_st) order by localrank;"

and I get this:

localrank       role    name
162737  writer  Thomas Harris
162738  producer        Gary Goetzman
162739  producer        Ron Bozman
162740  producer        Grace Blake
162741  producer        Kenneth Utt
162742  producer        Edward Saxon
162743  actor   Charles Napier
162744  actor   Roger Corman
162745  writer  Ted Tally
162746  actor   George A. Romero
162747  actor   Kasi Lemmons
162748  actor   Brooke Smith
162749  actor   Anthony Hopkins
162750  actor   Scott Glenn
162751  director        Jonathan Demme
162752  actor   Jodie Foster
162753  actor   Diane Baker
162754  actor   Ted Levine
162755  actor   Anthony Heald

As you can see localrank is an incrementing integer but those actor 
names are not in the order they came from the XML. I can only think that 
mythfilldatabase is adding the credits from XMLTV to a internal buffer 
in some way that does not preserve order before sending to the database.

Is it possible to fix this? I don't care if mythfilldatabase takes 
longer to run and a patch will do if a real fix would be problematic. 
BTW the credits on mythfrontend are not in order, I'm not worried about 
that as it includes all the credits but my email only lists the first 
five and having them in billing order makes it easy to spot interesting 


More information about the mythtv-dev mailing list