| 1 |
|
|---|
| 2 |
|
|---|
| 3 | def generateProjectXCutlist(chanid, starttime, folder):
|
|---|
| 4 | """generate cutlist_x.txt for ProjectX"""
|
|---|
| 5 |
|
|---|
| 6 | sqlstatement = """SELECT mark FROM recordedmarkup
|
|---|
| 7 | WHERE chanid = '%s' AND starttime = '%s'
|
|---|
| 8 | AND type IN (0,1) ORDER BY mark""" % (chanid, starttime)
|
|---|
| 9 |
|
|---|
| 10 | db = getDatabaseConnection()
|
|---|
| 11 | cursor = db.cursor()
|
|---|
| 12 | cursor.execute(sqlstatement)
|
|---|
| 13 | result = cursor.fetchall()
|
|---|
| 14 | numrows = int(cursor.rowcount)
|
|---|
| 15 |
|
|---|
| 16 | #We must have at least one row returned for this recording
|
|---|
| 17 | if numrows==0:
|
|---|
| 18 | write("No cutlist in the DB for chanid %s, starttime %s" % chanid, starttime)
|
|---|
| 19 | db.close()
|
|---|
| 20 | del db
|
|---|
| 21 | del cursor
|
|---|
| 22 | return False
|
|---|
| 23 |
|
|---|
| 24 | sqlstatement = """SELECT mark FROM recordedmarkup
|
|---|
| 25 | WHERE chanid = '%s' AND starttime = '%s'
|
|---|
| 26 | AND type 1 ORDER BY mark LIMIT 1 """ % (chanid, starttime)
|
|---|
| 27 |
|
|---|
| 28 | cursor.execute(sqlstatement)
|
|---|
| 29 | firstcut = cursor.fetchall()
|
|---|
| 30 |
|
|---|
| 31 | sqlstatement = """SELECT mark FROM recordedmarkup
|
|---|
| 32 | WHERE chanid = '%s' AND starttime = '%s'
|
|---|
| 33 | AND type IN (0,1) ORDER BY mark LIMIT 1 """ % (chanid, starttime)
|
|---|
| 34 |
|
|---|
| 35 | cursor.execute(sqlstatement)
|
|---|
| 36 | firstedit = cursor.fetchall()
|
|---|
| 37 |
|
|---|
| 38 | cutlist_f=open(os.path.join(folder, "cutlist_x.txt"), 'w')
|
|---|
| 39 | cutlist_f.write("CollectionPanel.CutMode=2\n")
|
|---|
| 40 |
|
|---|
| 41 | if firstcut == firstedit:
|
|---|
| 42 | cutlist_f.write("0\n")
|
|---|
| 43 |
|
|---|
| 44 | # iterate through resultset
|
|---|
| 45 | for i in range(len(result)):
|
|---|
| 46 | if result[i][0] != "" and result[i][0] <> 0:
|
|---|
| 47 | cutlist_f.write("%d\n" % result[i])
|
|---|
| 48 |
|
|---|
| 49 | cutlist_f.close()
|
|---|
| 50 |
|
|---|
| 51 | return True
|
|---|
| 52 |
|
|---|