Custom Recording

From MythTV Official Wiki
Revision as of 06:25, 15 April 2006 by Steveadeff (talk | contribs) (Useful Links)

Jump to: navigation, search

Creating Power Search rules with Custom RecordMythTV's "Custom Record" feature gives you unlimited control for creating specialized search recording rules to meet your needs. It allows you to choose your criteria to search for matching shows based on any of the information in the program listings, channel information, time functions and more. This goes beyond the capabilities of any other DVR system and it is unlikely that this level of scheduling customization will ever be available in any commercial DVR system.

Getting Started

Go to Schedule Recordings->Custom Record. This page helps you build a database search one clause at a time. Each added clause further limits which showings will be matched in the TV listings. You can test the search at any time and when you are done, you can save your search as a recording rule.

How It Works

MythTV stores TV program information in a database and uses the Structured Query Language (SQL) to access the data. Information about each TV program is stored in the 'program' table and information about each TV station you receive is stored in 'channel'. These two tables are used in the scheduler queries and their fields are available to be used in your rules. The rules you create are stored in 'record'.

Normal rules in MythTV simply match the title in the rule with the titles in the 'program' table. MythTV also has search rules for "Titles", "Keywords" and "People". These store the key phrase in the description field of the rule and includes them in specialized SQL replacements for the normal title check. There is also a type called "Power Search" which takes the raw SQL in the description as the replacement for title matching.

Custom Record is a tool to help you build valid SQL for Power Search rules. You do not need to be a SQL expert to use Custom Record because the examples are known to work correctly and are usually self-explanatory so you can choose the pieces you need then modify them. Many powerful solutions to unique problems are possible by combining the examples. With some creativity and some knowledge of SQL, the possibilities are limitless.

Clauses

Clauses have the basic form of "check field A for content B". They can also be "Check part C of field A for content B". Fields are the information categories in the database. Modifiers let you examine a specific part of a Field. Logical Operators are how you test a field for your criteria.

Fields

This is a list of valid fields and what information they hold.

Notes: All times are stored in 24 hour time. 
Boolean: 1=True/Yes, 0=False/No.

program

  • program.chanid - The MythTV database channel ID for the program.
  • program.starttime - start date and time of the program.
  • program.endtime - End date and time of the program.
  • program.title - Program title.
  • program.subtitle - Program subtitle, ie the episode name.
  • program.description - Program description.
  • program.category - Category: Comedy, Children, Music, House/garden, Talk, Science, Sitcom, News, Documentary, etc.
  • program.category_type - Holds one of these exact four strings: "movie", "series", "sports" or "tvshow".
  • program.airdate - is a string representing the year of release for movies and may have no meaning for other types of shows.
  • program.stars - A floating point number from 0.0 to 1.0 representing a four star scale. 1.0 would be four stars, 0.75 would be three stars and so on.
  • program.previouslyshown - Whether the show has been aired. Boolean.
  • program.title_pronounce -
  • program.stereo - Broadcast in stereo. Boolean.
  • program.subtitled - Broadcast with subtitles. Boolean.
  • program.hdtv - Broadcast in HDTV. Boolean.
  • program.closecaptioned - Broadcast with Closed Captioning information. Boolean.
  • program.partnumber -
  • program.parttotal -
  • program.seriesid - The Tribune Media Service database record identifier for each program. In general, these start with a two letter prefix, MV, EP, SP or SH that correspond to the "program.category_type". This is the Prefix followed by the 6 letter series/program ID. Detailed information can be found in the Data Direct documentation at http://labs.zap2it.com/
  • program.originalairdate - If provided, is the date when a show was, or will be, first televised. This may be useful for finding episodes before or after a certain date such as finding just the original series of "Battlestar Galactica".
  • program.previouslyshown - is a field created by MythTV to try to determine if a showing is more than 14 days after its original air date or if the show was marked as a repeat and did not have a date for the first airing. If this is "0" it usually means that this is a brand new show or a rebroadcast within the first two weeks.
  • program.showtype -
  • program.colorcode -
  • program.syndicatedepisodenumber - Episode Number assigned by the production company
  • program.programid - The Tribune Media Service database record identifier for each program description. In general, these start with a two letter prefix, MV, EP, SP or SH that correspond to the "program.category_type". This is the full Program ID which includes the Series ID followed by the 4 digit episode ID, which will be 0000 for non-series. Detailed information can be found in the Data Direct documentation at http://labs.zap2it.com/

programrating

  • programrating.rating - Program rating: G, TV-Y, etc.

people

  • people.name -
  • people.person -

credits

  • credits.person -
  • credits.chanid -
  • credits.starttime -

channel

  • channel.callsign -
  • channel.sourceid -
  • channel.commfree -

favorites

  • favorites.chanid -

Modifiers

  • DAYNAME() - Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
  • HOUR() - 0 to 24, "military time", 17 = 5PM
  • WEEKDAY() - Weekday by number. 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday.
  • MINUTE() - Minute, 0 - 59
  • DAYOFYEAR() -
  • DATE_SUB() -

Logical Operators

  • AND - And. Used to combine two field queries requiring both to be true.
  • OR - Or. Used to combine two field queries requiring at least one to be true.
  • < - Less than.
  • > - Greater than.
  • = - Equal to. Can be combined with < or >.
  • LIKE '%String%' - Contains. Searches for your string within the field specified. % is the "all" operator and can be used in any part of the search string
program.title LIKE "%Colbert Report%"
program.title LIKE "Colbert Report%"
  • REGEXP To use regular expression searches.
AND program.subtitle REGEXP '(Miami|Cavaliers|Lakers)'

Useful Clauses

Some useful user submitted clauses

The Daily Show

program.title LIKE "%Daily Show%"
AND HOUR(DATE_SUB(program.starttime, INTERVAL 2 HOUR)) > 20
AND WEEKDAY(DATE_SUB(program.starttime, INTERVAL 2 HOUR)) < 4
AND (WEEKDAY(DATE_SUB(program.starttime, INTERVAL 2 HOUR)) = 0
OR program.previouslyshown = 0)

Colbert Report

program.title LIKE "%Colbert Report%"
AND MINUTE(program.starttime) = 30
AND HOUR(DATE_SUB(program.starttime, INTERVAL 2 HOUR)) > 20
AND WEEKDAY(DATE_SUB(program.starttime, INTERVAL 2 HOUR)) < 4
AND (WEEKDAY(DATE_SUB(program.starttime, INTERVAL 2 HOUR)) = 0
OR program.previouslyshown = 0)


Useful Links

http://www.mythtv.org/docs/mythtv-HOWTO-12.html#ss12.5 The Original How-To. Most of the information here was taken from this.