def fromGuide(cls, guide, type=RECTYPE.kAllRecord, wait=False): if datetime.now() > guide.endtime: raise MythError('Cannot create recording rule for past recording.') rec = cls(None, db=guide._db) for key in ('chanid','title','subtitle','description', 'category', 'seriesid','programid'): rec[key] = guide[key] rec.startdate = guide.starttime.date() rec.starttime = guide.starttime-datetime.combine(rec.startdate, time()) rec.enddate = guide.endtime.date() rec.endtime = guide.endtime-datetime.combine(rec.enddate, time()) rec.station = Channel(guide.chanid, db=guide._db).callsign rec.type = type return rec.create(wait=wait)
def fromProgram(cls, program, type=RECTYPE.kAllRecord, wait=False): if datetime.now() > program.endtime: raise MythError('Cannot create recording rule for past recording.') rec = cls(None, db=program._db) for key in ('chanid','title','subtitle','description','category', 'seriesid','programid'): rec[key] = program[key] rec.station = program.callsign rec.startdate = program.starttime.date() rec.starttime = program.starttime-datetime.combine(rec.startdate, time()) rec.enddate = program.endtime.date() rec.endtime = program.endtime-datetime.combine(rec.enddate, time()) if program.recordid: rec.parentid = program.recordid if program.recstatus == RECTYPE.kNotRecording: rec.type = RECTYPE.kOverrideRecord else: rec.type = RECTYPE.kDontRecord else: rec.type = type return rec.create(wait=wait)