def __init__(self): self.headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" } self.download = downloader.Downloader().download self.client = pymongo.MongoClient('192.168.0.153', port=27017) self.db = self.client.edition self.db.authenticate("wangkun", 'wk123456') self.contact = self.db['contact']
for section in cnf.sections(): if section == '__properties__': # special section, rule properties (extend url's etc.) for item in cnf.items(section): rule_properties[item[0]] = item[1] elif cnf.has_option(section, 'enabled') and cnf.getint(section, 'enabled') == 1: enabled_rulefiles[section.strip()] = {} # input filter if cnf.has_option(section, 'filter'): enabled_rulefiles[section.strip()]['filter'] = cnf.get(section, 'filter').strip() else: enabled_rulefiles[section.strip()]['filter'] = "" # download / remove rules md = metadata.Metadata() dl = downloader.Downloader(target_dir=rule_source_directory) for rule in md.list_rules(rule_properties): if rule['metadata_source'] not in metadata_sources: metadata_sources[rule['metadata_source']] = 0 if 'url' in rule['source']: full_path = ('%s/%s' % (rule_source_directory, rule['filename'])).replace('//', '/') if dl.is_supported(url=rule['source']['url']): if rule['required']: # Required files are always sorted last in list_rules(), add required when there's at least one # file selected from the metadata package or not on disk yet. if metadata_sources[rule['metadata_source']] > 0 or not os.path.isfile(full_path): enabled_rulefiles[rule['filename']] = {'filter': ''} if rule['filename'] not in enabled_rulefiles: if not rule['required']: if os.path.isfile(full_path): os.remove(full_path)
def run(cli_args): test_config = cfg.TestConfig(cli_args.test_config, cli_args.filter_src, cli_args.filter_hrc, cli_args.filter_pvs) # get all required segments to be encoded required_segments = test_config.get_required_segments() # encode in parallel logger.info("will generate " + str(len(required_segments)) + " segments") import lib.downloader as downloader dload = downloader.Downloader( folder=test_config.get_video_segments_path(), bitmovin_key_file=os.path.join( check_requirements.get_processing_chain_dir(), "bitmovin_settings", "keyfile.txt"), input_details=os.path.join( check_requirements.get_processing_chain_dir(), "bitmovin_settings", "input_details.yaml"), output_details=os.path.join( check_requirements.get_processing_chain_dir(), "bitmovin_settings", "output_details.yaml"), overwrite=cli_args.force) cmd_runner = cmd_utils.ParallelRunner(cli_args.parallelism) for seg in required_segments: if seg.video_coding.is_online: if not cli_args.skip_online_services: if seg.video_coding.encoder == "youtube": logger.debug("will download youtube-encoding for video " + seg.get_filename() + ".") if not cli_args.dry_run: dload.init_download(seg, cli_args.force, cli_args.verbose) elif seg.video_coding.encoder.casefold() == "bitmovin": logger.debug("will encode " + seg.get_filename() + " using Bitmovin.") if not cli_args.dry_run: dload.encode_bitmovin(seg=seg) else: logger.debug("skipping " + seg.get_filename() + "because skipping online services is enabled.") else: cmd = ffmpeg.encode_segment(seg, overwrite=cli_args.force) cmd_runner.add_cmd(cmd, name=str(seg)) # only write logfile if command should run if cmd: logfile = seg.get_logfile_path() # replace all absolute paths seg_cmd = cmd.replace( test_config.get_video_segments_path() + "/", "") seg_cmd = seg_cmd.replace( check_requirements.get_processing_chain_dir() + "/logs/", "") seg_cmd = seg_cmd.replace(test_config.get_src_vid_path() + "/", "") logger.debug("writing segment logfile to " + logfile) if not cli_args.dry_run: with open(logfile, "w") as lf: lf.write("segmentFilename: " + seg.get_filename() + "\n") lf.write( "processingChain: " + check_requirements.get_processing_chain_version() + "\n") lf.write("ffmpegCommand: " + seg_cmd + "\n") if cli_args.dry_run: cmd_runner.log_commands() return test_config logger.info("starting to process segments, please wait") cmd_runner.run_commands() return test_config
def __init__(self): self.headers = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" } self.download = downloader.Downloader().download