Some MythTV command-line tools I've written

Most of these scripts interact directly with the mysql database, so they need a .my.cnf set up to allow RW access to the mythconverg.* tables.

I have no idea how useful these scripts would be to other people, but they can be very useful if, like me, you have lots of disk space and rarely delete anything so have a few thousand recordings. the myth interface doesn't really scale well to that many recordings.

I have a few other ideas for other myth utils too, lurking on my todo list. highest priority is command line tool (or tools) to list upcoming shows, schedule a recording, list upcoming recordings, and cancelling scheduled recordings.

I'd also like to write a GUI tool to manage recordings and job queues etc. all of the functionality above but in a GUI. search for and select/tag recordings and then run some operation (transcode, delete, rebuild index, whatever) on all selected items. ditto for the job queue. unfortunately, I can't see myself getting the time to do this any time soon, though.

Enough with the wittering, on with the show...

NOTE:

These scripts are offered as is, without any support and without any guarantee that they'll work. You're welcome to email and ask intelligent questions but there's no guarantee that i'll have time to answer.

I'm likely to just ignore dumb questions, or questions which seem like you haven't even tried to figure it out yourself, but that isn't necessarily the reason why i haven't replied - if i don't answer you, it's most likely because i'm too busy.

criticism, comment, suggestions, and patches are welcome

The tools:

plus some Quick & Dirty hacks:

Avert your eyes if you are easily offended by ugly code


Ultra-Minimalist Documentation

myth-list-new.sh

This started off being a simple tool to list "new" (i.e. untranscoded) recordings. now does a lot more

Usage: myth-list-new.sh [OPTIONS]

OPTIONS:
  -c, --cutlist      cutlist 0 or 1 (default = either)
  -t, --totals-only  only display totals

  -T, --transcoded   transcoded 0=no, 1=yes, 2=either (default = yes)
  -b, --bookmark     bookmark 0 or 1 (default = either)
  -w, --watched      watched 0 or 1 (default = either)
  -f, --flagged      commflagged 0 or 1 (default = either)
  -o, --hostname     show recording host
  -n, --filename     show recording filename

  -q, --queue        output SQL to insert transcode commands into jobqueue table
  -e, --execute      execute SQL rather than display it
  --force            force queuing of finished jobs that are still listed in the queue

  -d, --debug        show SQL commands as they are run
  -h, --help         this usage message

  -7, --seven        exclude ABC News and 7.30 Report

  -s, --sort         sort by title, size, date (default)
  -A, --ASC          sort ASCENDING (DEFAULT)
  -D, --DESC         sort DESCENDING

The '--force' option is useful because, by default, the script won't requeue a job if it's still in the queue (even if with status = 272 for completed or status = 304 for errored). sometimes it's convenient to force a requeue in that situation, rather than wait for the old queue entry to expire in a day or so.

the '-7' option is probably completely useless to anyone but me. unless you also record the (Australian) ABC News & 7.30 Report shows but don't bother transcoding them because you only keep a week's worth of episodes. which seems a bit unlikely. Think of it as an example of how to modify the script to exclude stuff you're not interested in seeing :)

this script is pretty much complete and finished. the only thing i can think of that needs to be added to it is the ability to specify which transcoder to use, which would require updating the transcoder setting in the recorded table. it's low priority on my TODO list.


myth-list-queue.sh

list entries in the myth job queue.

Usage: myth-list-queue.sh [OPTIONS] 

OPTIONS:
  -r, --running      show running jobs
  -q, --queued       show queued jobs
  -c, --completed    show completed jobs
  -e, --errors       show errored jobs
  -f, --flag         show commflag jobs
  -t, --transcode    show transcode jobs
  -h, --help         this usage message

default is to show all items in the queue - running, queued, completed, & errored.

One Of These Days<tm> i'll add the ability to delete an entry from the queue. and requeue as well (i.e. clear the hostname field so that some other machine running mythbackend or mythjobqueue can grab the job).

probably not too hard to do that, but i haven't needed those features myself yet, so i haven't done it.

myth-list-titles.sh

search for titles in the recording database.

Usage: myth-list-titles.sh [OPTIONS] [title search string]

OPTIONS:
  -l, --like          mysql 'LIKE' search rather than equals
  -r, --like          mysql 'REGEXP' search rather than equals
  -t, --totals-only   only display totals
  -b, --basename-only only display basename of recording
  -d, --debug         debug mode
  -h, --help          this usage message

the --basename-only option is useful for feeding into the next script, myth-delete-recording.pl.

also One Of These Days<tm>, i'll add the ability to insert transcode and commflag jobs into the job queue, as well as deleting recordings and rebuilding indexes, removing the need for the next two scripts.

the script really needs more ability to filter search results (e.g. to select specific episodes or all *except* for specific episodes, or the most recent N episodes, search by subtitle as well as title, etc) before i can do that. at which point, it should be renamed myth-search or something like that.

it may be a good idea to merge this script and myth-list-new.sh into one script that does it all. OTOH, while they're similar in function they each have a quite different focus (titles vs attributes) which would probably make the command line options clumsy if i combined them.


myth-delete-recording.pl

Delete one or more mythtv recordings. deletes a list of recording 'basenames' on stdin (e.g. from 'myth-list-titles.sh -b').

e.g. to delete all recordings containing the word 'simpsons' in the title:

  myth-list-titles.sh -r simpsons --basename-only | myth-delete-recording.pl

this one's a perl script using the MythTV.pm module because i haven't made the effort to figure out how to delete recordings from sh yet.

basenames can be provided on the command line and/or from stdin


myth-cut-and-rebuild-index.sh

given some filenames (e.g. 1003_20101113183000.mpg), run mythtranscode to run a lossless transcode (honoring the cutlist) and then rebuild the seektable.

filenames can be provided on the command line and/or from stdin. they can be fully-specified pathnames or just basenames (/video/myth*/ will be searched to find the full path)

this is a very ugly script, not "release quality". it really ought to be merged into the myth-list-titles.sh script above. and terminated. with extreme prejudice.


myth-rebuild-index.sh

same as myth-cut-and-rebuild-index.sh except that it only rebuilds the index, it does not transcode or cut.

filenames can be provided on the command line and/or from stdin