def run(self) -> None: self.pre_concat() if not self.config['spec']['recorder']['keep_raw_record']: utils.del_files_and_dir(self.record_dir) # duration = float(ffmpeg.probe(self.merged_file_path)[ # 'format']['duration']) # start_time = get_start_time(self.merged_file_path) # self.times.append((start_time, duration)) # self.live_start = self.times[0][0] # self.live_duration = ( # self.times[-1][0]-self.times[0][0]).total_seconds()+self.times[-1][1] if self.config['spec']['clipper']['enable_clipper']: with open(self.danmu_path, "r", encoding="utf-8") as f: lines = f.readlines() raw_danmu_dict = parse_lines(lines) counted_danmu_dict = count( raw_danmu_dict, self.live_start, self.live_duration, self.config['spec']['parser']['interval']) cut_points = get_cut_points( counted_danmu_dict, self.config['spec']['parser']['up_ratio'], self.config['spec']['parser']['down_ratio'], self.config['spec']['parser']['topK']) self.cut(cut_points, self.config['spec']['clipper']['min_length']) if self.config['spec']['uploader']['record']['upload_record']: self.split( self.config['spec']['uploader']['record']['split_interval'])
def run(self) -> None: logging.basicConfig( level=utils.get_log_level(self.config), format= '%(asctime)s %(thread)d %(threadName)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s', datefmt='%a, %d %b %Y %H:%M:%S', handlers=[ logging.FileHandler(os.path.join( self.config.get('root', {}).get('logger', {}).get('log_path', "./log"), "VideoChecker_" + datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S') + '.log'), "a", encoding="utf-8") ]) while True: video_info = self.common_request("GET", self.check_url, { 'bvid': self.bvid }).json() try: if video_info['code'] == 0 and video_info['data']['state'] == 0: logging.info("稿件%s 已开放浏览,准备删除 %s", self.bvid, self.path) utils.del_files_and_dir(self.path) return else: logging.info("稿件%s 未开放浏览", self.bvid) time.sleep(self.check_interval) except KeyError: pass
def run(self) -> None: self.pre_concat() if not self.config.get('spec', {}).get('recorder', {}).get('keep_raw_record', False): if os.path.exists(self.merged_file_path): utils.del_files_and_dir(self.record_dir) # duration = float(ffmpeg.probe(self.merged_file_path)[ # 'format']['duration']) # start_time = get_start_time(self.merged_file_path) # self.times.append((start_time, duration)) # self.live_start = self.times[0][0] # self.live_duration = ( # self.times[-1][0]-self.times[0][0]).total_seconds()+self.times[-1][1] if self.config.get('spec', {}).get('clipper', {}).get('enable_clipper', False): danmu_list = parse_danmu(self.danmu_path) counted_danmu_dict = count( danmu_list, self.live_start, self.live_duration, self.config.get('spec', {}).get('parser', {}).get('interval', 60)) cut_points = get_cut_points(counted_danmu_dict, self.config.get('spec', {}).get('parser', {}).get('up_ratio', 2.5), self.config.get('spec', {}).get('parser', {}).get('down_ratio', 0.75), self.config.get('spec', {}).get('parser', {}).get('topK', 5)) self.cut(cut_points, self.config.get('spec', {}).get( 'clipper', {}).get('min_length', 60)) if self.config.get('spec', {}).get('uploader', {}).get('record', {}).get('upload_record', False): self.split(self.config.get('spec', {}).get('uploader', {}) .get('record', {}).get('split_interval', 3600))
def run(self) -> bool: try: ret = self.pre_concat() success = isinstance(ret, subprocess.CompletedProcess) if success and not self.config.get('spec', {}).get( 'recorder', {}).get('keep_raw_record', False): if os.path.exists(self.merged_file_path): utils.del_files_and_dir(self.record_dir) # duration = float(ffmpeg.probe(self.merged_file_path)[ # 'format']['duration']) # start_time = get_start_time(self.merged_file_path) # self.times.append((start_time, duration)) # self.live_start = self.times[0][0] # self.live_duration = ( # self.times[-1][0]-self.times[0][0]).total_seconds()+self.times[-1][1] if not self.config.get('spec', {}).get('clipper', {}).get( 'enable_clipper', False) and not self.config.get( 'spec', {}).get('manual_clipper', {}).get( 'enabled', False): logging.info('Clipper and manual clipper are both disabled') os.rmdir(self.outputs_dir) if not self.config.get('spec', {}).get('uploader', {}).get( 'record', {}).get('upload_record', False): logging.info('Record uploader disabled') os.rmdir(self.splits_dir) if self.config.get('spec', {}).get('clipper', {}).get('enable_clipper', False): logging.info('Processing clipper') danmu_list = parse_danmu(self.danmu_path) counted_danmu_dict = count( danmu_list, self.live_start, self.live_duration, self.config.get('spec', {}).get('parser', {}).get('interval', 60)) cut_points = get_cut_points( counted_danmu_dict, self.config.get('spec', {}).get('parser', {}).get('up_ratio', 2.5), self.config.get('spec', {}).get('parser', {}).get('down_ratio', 0.75), self.config.get('spec', {}).get('parser', {}).get('topK', 5)) ret = self.cut( cut_points, self.config.get('spec', {}).get('clipper', {}).get('min_length', 60)) success = success and ret if self.config.get('spec', {}).get('manual_clipper', {}).get('enabled', False): logging.info('Processing manual clipper') danmu_list = parse_danmu(self.danmu_path) cut_points = get_manual_cut_points( danmu_list, self.config.get('spec', {}).get('manual_clipper', {}).get('uid', ""), self.config.get('spec', {}).get('manual_clipper', {}).get('command', '/DDR clip'), ) ret = self.cut(cut_points, 0) success = success and ret if self.config.get('spec', {}).get('uploader', {}).get('record', {}).get('upload_record', False): ret = self.split( self.config.get('spec', {}).get('uploader', {}).get( 'record', {}).get('split_interval', 3600)) success = success and ret return success except: traceback.print_exc() return False