[mythtv] Sports Recordings

David Hampton mythtv at love2code.net
Sun Dec 5 21:16:52 UTC 2021

Hi all,

If you're using MythTV built from the git sources, I added a feature
last week to track sports recordings and automatically extend the
recording until the game is over.  It will also shorten the recording
if a game finishes early (e.g. called for rain).  This works for most
team sports (baseball, american football, basketball, volleyball,
lacrosse, water polo, and soccer), but doesn't work for things like
tennis, golf, or auto racing.

To enable this feature on a recording, go to "Managed Recordings" ->
"Recording Rules" -> (choose recording) -> "Schedule Options" and
change the option near the bottom from "Do not automatically extend
recording" to "Automatically extend recording using ESPN".  You can
also set this in the "Schedule Options" page when creating a recording.
If you want to track what the code is doing, tail the mythbackend log
and grep for RecExt. You'll see something like this:

  RecExt: Found game 'Steelers vs Chargers' at 2021-11-22T01:20:00Z
  RecExt: Steelers at Chargers (PIT @ LAC), 12:49 - 1st Quarter.
  RecExt: Steelers at Chargers (PIT @ LAC), 8:29 - 1st Quarter.
  RecExt: Steelers at Chargers (PIT @ LAC), 4:23 - 4th Quarter.
  RecExt: Steelers at Chargers (PIT @ LAC), 2:52 - 4th Quarter.
  RecExt: Recording 2953, created override rule 1719->1865 for
    'Steelers @ Chargers' ending
    2021-11-22T04:32:00Z -> 2021-11-22T04:42:00Z.
  RecExt: Steelers at Chargers (PIT @ LAC), Final.
  RecExt: Recording 2953 rule 1719->1865 for 'Steelers @ Chargers'
    has finished. Stop recording.

I know that most soccer games end within the allotted broadcast time,
but if you decide to use this feature for soccer, there may be a few
quirks. The first one is setting the proper mapping from the event name
used by your listing service (Schedules Direct or other EIT) to the
name of the league used by ESPN.  I collected a number of names used in
TV listings and put them into the database, but I'm sure that I missed
a lot.  The 'sportslisting' table in the database is what handles this
mapping.  For example, show titles of "Bundesliga Soccer" and "Fútbol
Copa de Alemania" (and others) all map to the German Bundesliga soccer
league, but there probably also needs to be a mapping from "Bundesliga
Fußball" or whatever listing title is used in Germany.  The second
quirk is that soccer teams have a huge variety of words in their names
that aren't used by the ESPN API (e.g. CD, FC, VFB, etc) and need to be
stripped from the team name.  This is handled by the 'sportscleanup'
table in the database, which essentially performs regular expression
pattern matching and replacement.  The last quirk is language
differences, because ESPN uses English names for teams, so "FC Bayern
Munchen" needs to map to "Bayern Munich".  This is also handled by the
'sportscleanup' table.  If you change the mythbackend log level to
"debug" you can see MythTV process a team name through the cleanups

There isn't a screen in MythTV to edit these databases, and I know that
manual editing of the database is discouraged.  If anyone has a problem
with missing mappings, I'd be happy to put together an update for the
'sportscleanups' table and commit that to MythTV.  Send me the listing
information and actual league names and I'll add it to the update.

Please let me know if you try this feature (for any sport), and how it
works for you.



More information about the mythtv-dev mailing list