#!/opt/local/bin/python2.7 #!/usr/bin/env python # -*- coding: UTF-8 -*- #--------------------------- # Name: delete_recordings.py # Python Script # Original Author: Raymond Wagner # Modified by: Scott Gruby # Purpose # This python script provides a command line tool to # queue jobs. #--------------------------- from MythTV import MythDB, MythLog import sys import datetime import os from datetime import timedelta def list_recs(recs): recs = dict(enumerate(recs.values())) for i,rec in recs.items(): command = '/opt/local/bin/mythutil --queuejob 2 --chanid %s --starttime %s' % \ (rec.chanid, datetime.datetime.utcfromtimestamp(rec.starttime.timestamp()).isoformat()) os.system(command) command = '/opt/local/bin/mythutil --queuejob 256 --chanid %s --starttime %s' % \ (rec.chanid, datetime.datetime.utcfromtimestamp(rec.starttime.timestamp()).isoformat()) os.system(command) return recs today = datetime.datetime.today()-timedelta(hours=24) newer_string = today.strftime('%Y-%m-%dT%H:%M:%S') recs = list(MythDB().searchRecorded(newerthan=(newer_string))) if len(recs) == 0: print 'no matching recordings found' sys.exit(0) recs = dict(enumerate(recs)) list_recs(recs)