myth CLI utilities

Top Page

Reply to this message
Author: Craig Sanders
Date:  
To: dmo-discussion
Subject: myth CLI utilities
speaking of mythtv, would there be any interest in a package containing
some mythtv utilities i've written? if there is, i'll try to find time
to write some man pages & (brief/minimalist) docs, etc for them and
package them up.

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


The tools:

1. myth-list-new.sh

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 recording 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.


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.


2. myth-list-queue.sh

list items in the 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.


3. 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.


the next two scripts are more Q&D hacks than polished tools:

4. myth-delete-recording.pl

delete one or more mythtv recordings. type or copy-paste (or use
xargs) to construct a list of recording 'basenames' (e.g. with
'myth-list-titles.sh -b') and put them on end of the command line.

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

myth-list-titles.sh -r simpsons --basename-only | xargs 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.



5. myth-cut-and-rebuild-index.sh

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

very ugly script, not "release quality". it really ought to be merged
into the myth-list-titles.sh script above.



dunno how useful these scripts would be to other people, but they're
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.

craig

--
craig sanders <cas@???>