Ticket #3655: mythburn.py.patch
File mythburn.py.patch, 5.9 KB (added by , 17 years ago) |
---|
-
mytharchive/mythburn/scripts/mythburn.py
14 14 # paulh 15 15 # 4 May 2006 - Added into mythtv svn 16 16 17 # robg 18 # 20 Jun 2007 - Added commercial skipping chapter marks 19 17 20 #For this script to work you need to have... 18 21 #Python2.3.5 19 22 #python2.3-mysqldb … … 31 34 #****************************************************************************** 32 35 33 36 # version of script - change after each update 34 VERSION="0.1.200706 19-1"37 VERSION="0.1.20070620-2" 35 38 36 39 37 40 ##You can use this debug flag when testing out new themes … … 522 525 523 526 write( "Video length is %s seconds. Each chapter will be %s seconds" % (lengthofvideo,segment)) 524 527 525 chapters="" 528 chapters = createVideoChaptersFixedLength(itemnum, segment, lengthofvideo) 529 526 530 thumbList="" 527 531 starttime=0 528 532 count=1 529 533 while count<=numofchapters: 530 chapters+=time.strftime("%H:%M:%S",time.gmtime(starttime))531 532 534 if starttime==0: 533 535 if thumboffset < segment: 534 536 thumbList+="%s," % thumboffset … … 537 539 else: 538 540 thumbList+="%s," % starttime 539 541 540 if numofchapters>1:541 chapters+=","542 542 starttime+=segment 543 543 count+=1 544 544 … … 548 548 549 549 return chapters 550 550 551 def createVideoChaptersFixedLength(segment, lengthofvideo): 552 """Returns chapter marks spaced segment seconds through the file""" 551 def createVideoChaptersFixedLength(itemnum, segment, lengthofvideo): 552 """Returns chapter marks at commercial ends, or spaced segment seconds through the file""" 553 554 # if there is a chapter list already available, use it 555 infoDOM = xml.dom.minidom.parse(os.path.join(getItemTempPath(itemnum),"info.xml")) 556 chapterlistNode = infoDOM.getElementsByTagName("chapterlist") 557 if chapterlistNode.length > 0: 558 chapterlist = getText(chapterlistNode[0]) 559 write("Using commercial end marks - %s" % chapterlist) 560 return chapterlist 561 553 562 if lengthofvideo < segment: 554 563 return "00:00:00" 555 564 … … 871 880 node.appendChild(infoDOM.createTextNode("")) 872 881 top_element.appendChild(node) 873 882 874 #if this a myth recording we still need to find the chanid, starttime and hascutlist883 #if this a myth recording we still need to find the chanid, starttime, hascutlist, and commercial end marks 875 884 if file.attributes["type"].value=="recording": 876 885 basename = os.path.basename(file.attributes["filename"].value) 877 886 sqlstatement = """SELECT starttime, chanid FROM recorded … … 918 927 node.appendChild(infoDOM.createTextNode("no")) 919 928 top_element.appendChild(node) 920 929 930 # find the commercial end marks if available 931 sqlstatement = """SELECT mark, type FROM recordedmarkup 932 WHERE chanid = '%s' AND starttime = '%s' 933 AND type = 5 ORDER BY mark""" % (chanid, starttime) 934 cursor = db.cursor() 935 # execute SQL statement 936 cursor.execute(sqlstatement) 937 # get the resultset as a tuple 938 result = cursor.fetchall() 939 if cursor.rowcount > 0: 940 res, fps, ar = getVideoParams(folder) 941 chapterlist="00:00:00" 942 #iterate through marks, adding to chapterlist 943 for record in result: 944 chapterlist += "," + frameToTime(int(record[0]), float(fps)) 945 946 node = infoDOM.createElement("chapterlist") 947 node.appendChild(infoDOM.createTextNode(chapterlist)) 948 top_element.appendChild(node) 949 921 950 db.close() 922 951 del db 923 952 del cursor … … 1016 1045 node.appendChild(infoDOM.createTextNode("no")) 1017 1046 top_element.appendChild(node) 1018 1047 1048 # find the commercial end marks if available 1049 sqlstatement = """SELECT mark, type FROM recordedmarkup 1050 WHERE chanid = '%s' AND starttime = '%s' 1051 AND type = 5 ORDER BY mark""" % (chanid, starttime) 1052 cursor = db.cursor() 1053 # execute SQL statement 1054 cursor.execute(sqlstatement) 1055 # get the resultset as a tuple 1056 result = cursor.fetchall() 1057 if cursor.rowcount > 0: 1058 res, fps, ar = getVideoParams(folder) 1059 chapterlist="00:00:00" 1060 #iterate through marks, adding to chapterlist 1061 for record in result: 1062 chapterlist += "," + frameToTime(int(record[0]), float(fps)) 1063 1064 node = infoDOM.createElement("chapterlist") 1065 node.appendChild(infoDOM.createTextNode(chapterlist)) 1066 top_element.appendChild(node) 1067 1019 1068 db.close() 1020 1069 del db 1021 1070 del cursor … … 2066 2115 if wantChapterMenu: 2067 2116 vob.setAttribute("chapters",createVideoChapters(itemnum,chapters,getLengthOfVideo(itemnum),False) ) 2068 2117 else: 2069 vob.setAttribute("chapters", createVideoChaptersFixedLength( chapterLength, getLengthOfVideo(itemnum)))2118 vob.setAttribute("chapters", createVideoChaptersFixedLength(itemnum,chapterLength, getLengthOfVideo(itemnum))) 2070 2119 2071 2120 vob.setAttribute("file",os.path.join(getItemTempPath(itemnum),"final.mpg")) 2072 2121 pgc.appendChild(vob) … … 2284 2333 2285 2334 vob = dvddom.createElement("vob") 2286 2335 vob.setAttribute("file", os.path.join(getItemTempPath(itemNum), "final.mpg")) 2287 vob.setAttribute("chapters", createVideoChaptersFixedLength( chapterLength, getLengthOfVideo(itemNum)))2336 vob.setAttribute("chapters", createVideoChaptersFixedLength(itemNum, chapterLength, getLengthOfVideo(itemNum))) 2288 2337 pgc.appendChild(vob) 2289 2338 2290 2339 del vob