def loadShowNoteFile(): """new main function. used to bail out if the user cancels the import request""" # Show the open file dialog. selected_file_tuple = RPR_GetUserFileNameForRead(None, 'Select Shownote file to import', 'osf') filepath = None if(selected_file_tuple[0] == 0): return else: filepath = selected_file_tuple[1] # open the file and read the content into an arrayreap with codecs.open(filepath, 'r', encoding='utf-8') as f: lines = f.readlines()[15:] # get the first starttime. This is our 0 time starttime = datetime.datetime.fromtimestamp(int(lines[0].split(' ')[0])) # we start at the end to have the length information available lines.reverse() # check if there is a shownote track. If not create one track = ULT.getTrackByName('Shownotes') if not track: track = createShownoteTrack() # call the function that creates the shownote items createShownoteItem(lines, starttime, track) # update the gui -> does not work right now RPR_UpdateArrange()
def loadChapterFile(): """new main function. used to bail out if the user cancels the import request""" # Show the open file dialog. selected_file_tuple = RPR_GetUserFileNameForRead(None, 'Select Chapter file to import', 'mp4chaps') filepath = None if(selected_file_tuple[0] == 0): return else: filepath = selected_file_tuple[1] # open the file and read the content into an arrayreap with codecs.open(filepath, 'r', encoding='utf-8') as f: lines = f.readlines() # we start at the end to have the length information available lines.reverse() # check if there is a chapters track. If not create one track = ULT.getTrackByName('Chapters') if not track: track = createChapterTrack() # call the function that creates the chapter items createChapterItem(lines, track) # update the gui -> does not work right now RPR_UpdateArrange()
def export_chapter_marks(): track = ULT.getTrackByName('Chapters') lines = [] for i in range(RPR_CountTrackMediaItems(track)): item = RPR_GetTrackMediaItem(track, i) time = RPR_GetMediaItemInfo_Value(item, 'D_POSITION') timestr = RPR_format_timestr_pos(time, None, 5, 5)[1] msg_text = ULT_GetMediaItemNote(item) lines.append(timestr + ' ' + msg_text + '\n') #def a(): # selected_file_tuple = RPR_GetUserFileNameForRead(None, 'Select Shownote file to import', 'osf') # filepath = None # if(selected_file_tuple[0] == 0): # return # else: # filepath = selected_file_tuple[1] filepath = os.path.join(os.path.expanduser("~"), 'Desktop', 'chapter_test.mp4chaps') # open the file and read the content into an arrayreap with codecs.open(filepath, 'w', encoding='utf-8') as f: f.writelines(lines)