From MythTV Official Wiki
Revision as of 07:42, 28 April 2010 by Sphery (talk | contribs) (mention the poorly-named "Pre & Post Roll" commercial flagging method)

Jump to: navigation, search

Important.png Note: The correct title of this article is setbookmark. It appears incorrectly here due to technical restrictions.

Important.png Note: See, also, the "Pre & Post Roll" commercial flagging method.

Author Tony Lill
Description Set a bookmark at program start if a program was recorded with start early.

Set a bookmark at program start if we recorded with start early.


setbookmark --chanid=$CHANID% --starttime="%STARTTIMEISO%"

The Script

Script.png setbookmark

#!/usr/bin/env python
# Set a bookmark at progstart if we recorded with pre-roll
# Invoke as a user job like so:
# setbookmark --chanid=$CHANID% --starttime="%STARTTIMEISO%"

from MythTV import Recorded
from optparse import OptionParser
import sys

parser = OptionParser(usage="usage: %prog --chanid=<> --starttime=<>")

parser.add_option("--chanid", action="store", type="string", dest="chanid", help="Channel ID of recording.")
parser.add_option("--starttime", action="store", type="string", dest="starttime", help="Starting Time of recording.")
# for backward compatibility with perl script
parser.add_option("--progstart", action="store", type="string", dest="progstart", help="DO NOT USE.")

opts, args = parser.parse_args()

if not (opts.chanid and opts.starttime):
    # sanity check on inputs
    print "ChanID or Starttime not provided"

rec = Recorded((opts.chanid, opts.starttime))
if rec.chanid is None:
    # check for match
    print "Recording not found"

if rec.progstart >= rec.starttime:
    # no pre-roll

framerate =[-1].mark/float((rec.endtime-rec.starttime).seconds)
offset = int(seconds(rec.progstart-rec.starttime)*framerate)

rec.markup.add((offset, 2, None))
rec.bookmark = 1