def load_cutlist(self, filename): cutlist = cutlists.Cutlist() cutlist.intended_app = 'VirtualDub.exe' if filename != None and os.path.exists(filename): cutlist.local_filename = filename cutlist.read_from_file() cutlist.read_cuts() if cutlist.author != self.app.config.get('general', 'cutlist_username'): cutlist.usercomment = 'Mit OTR-Verwaltung++ geschnitten; Vorlage von ' + cutlist.author + '; ' + cutlist.usercomment if cutlist.cuts_frames: self.initial_cutlist = cutlist.cuts_frames self.initial_cutlist_in_frames = True else: self.initial_cutlist = cutlist.cuts_seconds self.initial_cutlist_in_frames = False else: cutlist.usercomment = 'Mit OTR-Verwaltung++ geschnitten' self.initial_cutlist = [] self.initial_cutlist_in_frames = True if self.timer != None: # Running self.timelines.append( self.get_cuts_in_frames(self.initial_cutlist, self.initial_cutlist_in_frames)) if self.slider: self.slider.queue_draw() return cutlist
def _on_button_show_cuts_clicked(self, widget, data=None): cutlist = cutlists_management.Cutlist() if self.builder.get_object('radio_local_cutlist').get_active(): cutlist.local_filename = self.builder.get_object( 'label_cutlist').get_text() else: cutlist = self.treeview_cutlists.get_selected() if not cutlist: self.gui.message_error_box( "Es wurde keine Cutlist ausgewählt!") return error = cutlist.download(self.app.config.get('general', 'server'), self.filename) if error: self.gui.message_error_box(error) return self.app.show_cuts(self.filename, cutlist) # delete cutlist fileoperations.remove_file(cutlist.local_filename)
def setup(self, video_file): self.filename = video_file self.builder.get_object('label_file').set_markup( "<b>%s</b>" % os.path.basename(video_file)) # looking for local cutlists p, filename = os.path.split(video_file) cutregex = re.compile("^" + filename + "\.?(.*).cutlist$") files = os.listdir(p) local_cutlists = [] for f in files: match = cutregex.match(f) if match: # print "Found local cutlist" local_cutlists.append(p + '/' + match.group()) else: # print f + " is no cutlist" pass # print "%d cutlists found" % len(local_cutlists) if len(local_cutlists) > 0: self.treeview_local_cutlists.get_model().clear() self.builder.get_object('scrolledwindow_local').set_sensitive(True) self.builder.get_object('button_local').set_sensitive(True) for c in local_cutlists: cutlist = cutlists_management.Cutlist() cutlist.local_filename = c cutlist.read_from_file() self.treeview_local_cutlists.add_cutlist(cutlist) else: self.builder.get_object('scrolledwindow_local').set_sensitive( False) self.builder.get_object('button_local').set_active(False) self.builder.get_object('button_local').set_sensitive(False) # start looking for downloadable cutlists self.treeview_download_cutlists.get_model().clear() self.builder.get_object('label_status').set_markup( "<b>Cutlisten werden heruntergeladen...</b>") self.download_error = False GeneratorTask(cutlists_management.download_cutlists, None, self._completed).start( video_file, self.app.config.get('general', 'server'), self.app.config.get('general', 'choose_cutlists_by'), self.app.config.get('general', 'cutlist_mp4_as_hq'), self._error_cb, self._cutlist_found_cb)
def setup(self, video_file): self.filename = video_file self.builder.get_object('label_file').set_markup( "<b>%s</b>" % os.path.basename(video_file)) # looking for local cutlists p, filename = os.path.split(video_file) cutregex = re.compile("^" + filename + "\.?(.*).cutlist$") files = os.listdir(p) local_cutlists = [] for f in files: match = cutregex.match(f) if match: local_cutlists.append(p + '/' + match.group()) else: pass if len(local_cutlists) > 0: self.treeview_local_cutlists.get_model().clear() self.builder.get_object('scrolledwindow_local').set_sensitive(True) self.builder.get_object('button_local').set_sensitive(True) for c in local_cutlists: cutlist = cutlists_management.Cutlist() cutlist.local_filename = c cutlist.read_from_file() self.cutlists_list.append(cutlist) # ~ self.treeview_local_cutlists.add_cutlist(cutlist) ## Sorting -> self.cutlists_list.sort(key=lambda x: x.quality, reverse=False) for cutlist_obj in self.cutlists_list: self.treeview_local_cutlists.add_cutlist(cutlist_obj) ## <- Sorting else: self.builder.get_object('scrolledwindow_local').set_sensitive( False) self.builder.get_object('button_local').set_active(False) self.builder.get_object('button_local').set_sensitive(False) self.download_generator(False)
def cut_file_manually(self, filename): """ Cuts a file manually with Avidemux or VirtualDub or the CutInterface and gets cuts from possibly created project files (VD) or from output (AD). returns: error_message, cutlist """ global cutlist_error, cuts_frames program, config_value, ac3file = self.get_program(filename, manually=True) format, ac3_file, bframe_delay = self.get_format(filename) fps, dar, sar, max_frames, ac3_stream, error = self.analyse_mediafile( filename) if error: if exists(filename + '.mkv'): fileoperations.remove_file(filename + '.mkv') return "Konnte FPS nicht bestimmen: " + error, None if program < 0: return config_value, None cutlist = cutlists_management.Cutlist() if program == Program.AVIDEMUX: cutter = CutAvidemux(self.app, self.gui) cuts_frames, cutlist_error = cutter.create_cutlist( filename, config_value) elif program == Program.VIRTUALDUB: # VIRTUALDUB cutter = CutVirtualdub(self.app, self.gui) cuts_frames, cutlist_error = cutter.create_cutlist( filename, config_value) if program == Program.CUT_INTERFACE: # looking for latest cutlist, if any p, video_file = os.path.split(filename) cutregex = re.compile("^" + video_file + "\.?(.*).cutlist$") files = os.listdir(p) number = -1 local_cutlist = None # use fallback name in conclusions if there are no local cutlists for f in files: match = cutregex.match(f) if match: self.log.debug("Found local cutlist {}".format( match.group())) if match.group(1) == '' or match.group(1) == 'mkv': res_num = 0 elif "." in match.group(1): res_num = int(match.group(1).split('.')[1]) elif type(eval( match.group(1))) == type(1): # It's a number res_num = int(match.group(1)) else: res_num = 0 self.log.debug("local cutlist res_num: {}".format( match.group(1))) if res_num > number: res_num = number local_cutlist = p + "/" + match.group() ci = CutinterfaceDialog.NewCutinterfaceDialog(self.gui) ci.set_transient_for(self.gui.main_window) ci.set_modal(True) cutlist = ci._run(filename, local_cutlist, self.app) ci.destroy() if cutlist.cuts_frames is None or len(cutlist.cuts_frames) == 0: cutlist_error = "Keine Schnitte angegeben" else: cutlist_error = None else: # complete cutlist for Avidemux & VirtualDub # create cutlist data if cutlist_error is None: cutlist.cuts_frames = cuts_frames cutlist.intended_app = basename(config_value) cutlist.usercomment = 'Mit %s geschnitten' % self.app.app_name cutlist.fps = fps # calculate seconds for start_frame, duration_frames in cuts_frames: cutlist.cuts_seconds.append( (start_frame / fps, duration_frames / fps)) if cutlist_error: return cutlist_error, None else: return None, cutlist