def test_mediainfo_scraper_mov(filename, result_dict, mimetype, evaluate_scraper): """ Test Quicktime and DV scraping with Mediainfo. :filename: Test file name :result_dict: Result dict containing the test purpose, parts of expected results of stdout and stderr, and expected streams :mimetype: File MIME type """ correct = parse_results(filename, mimetype, result_dict, False) scraper = MediainfoScraper(filename=correct.filename, mimetype=mimetype) scraper.scrape_file() if filename == "valid__h264_aac_no_ftyp_atom.mov": correct.streams[0]["codec_name"] = "QuickTime" if ".dv" in filename: correct.streams[0].pop("stream_type", None) if "empty" in filename: assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) assert not scraper.streams else: evaluate_scraper(scraper, correct)
def test_mediainfo_scraper_wav(filename, result_dict, evaluate_scraper): """ Test WAV scraping with Mediainfo. :filename: Test file name :result_dict: Result dict containing the test purpose, parts of expected results of stdout and stderr, and expected streams """ mimetype = "audio/x-wav" correct = parse_results(filename, mimetype, result_dict, False) if "2" in filename: correct.streams[0]["version"] = "2" else: correct.streams[0]["version"] = UNAP scraper = MediainfoScraper(filename=correct.filename, mimetype=mimetype) scraper.scrape_file() if "empty" in filename: assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) assert not scraper.streams else: evaluate_scraper(scraper, correct)
def test_mediainfo_scraper_avi(filename, result_dict): """ Test AVI scraping with Mediainfo. Both Mediainfo and FFMpeg cannot be used for metadata scraping, and FFMpeg meets our needs better with AVI, so MediainfoScraper should just return one stream full of unavs to be overwritten by results from FFMpeg. """ mimetype = "video/avi" correct = parse_results(filename, mimetype, result_dict, True) scraper = MediainfoScraper(correct.filename, True, params={"mimetype_guess": mimetype}) scraper.scrape_file() assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) if "invalid" in filename: assert not scraper.streams else: assert len(scraper.streams) == 1 for method in scraper.streams[0].iterate_metadata_methods(): if method.__name__ == "index": assert method() == 0 else: assert method() == "(:unav)"
def test_mediainfo_scraper_mkv(filename, result_dict, evaluate_scraper): """ Test Matroska scraping with Mediainfo. :filename: Test file name :result_dict: Result dict containing the test purpose, parts of expected results of stdout and stderr, and expected streams """ mimetype = "video/x-matroska" correct = parse_results(filename, mimetype, result_dict, False) scraper = MediainfoScraper(filename=correct.filename, mimetype=mimetype) scraper.scrape_file() if "empty" in filename: correct.version = None correct.streams[0]["version"] = None correct.streams[0]["stream_type"] = None if "invalid" in filename: assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) assert not scraper.streams else: evaluate_scraper(scraper, correct)
def test_mediainfo_scraper_mpeg(filename, result_dict, evaluate_scraper): """Test MPEG scraping with MediainfoScraper.""" mimetype = "video/mpeg" correct = parse_results(filename, mimetype, result_dict, True) scraper = MediainfoScraper(correct.filename, True, params={"mimetype_guess": mimetype}) scraper.scrape_file() del correct.streams[0]["stream_type"] if "empty" in filename: assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) assert not scraper.streams else: evaluate_scraper(scraper, correct)
def test_mediainfo_scraper_mpegts(filename, result_dict, evaluate_scraper): """Test MPEG Transport Stream scraping with MediainfoScraper.""" mimetype = "video/MP2T" correct = parse_results(filename, mimetype, result_dict, True) scraper = MediainfoScraper(correct.filename, True, params={"mimetype_guess": mimetype}) scraper.scrape_file() for stream in correct.streams.values(): if stream["mimetype"] == "video/MP2T": stream["version"] = "(:unav)" if "empty" in filename: assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) assert not scraper.streams else: evaluate_scraper(scraper, correct)
def test_mediainfo_scraper_mov(filename, result_dict, mimetype, evaluate_scraper): """Test Quicktime and DV scraping with Mediainfo.""" correct = parse_results(filename, mimetype, result_dict, True) scraper = MediainfoScraper(correct.filename, True, params={"mimetype_guess": mimetype}) scraper.scrape_file() if ".dv" in filename: correct.streams[0].pop("stream_type", None) if "empty" in filename: assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) assert not scraper.streams else: evaluate_scraper(scraper, correct)
def test_mediainfo_scraper_wav(filename, result_dict, evaluate_scraper): """Test WAV scraping with Mediainfo.""" mimetype = "audio/x-wav" correct = parse_results(filename, mimetype, result_dict, True) if "2" in filename: correct.streams[0]["version"] = "2" scraper = MediainfoScraper(correct.filename, True, params={"mimetype_guess": mimetype}) scraper.scrape_file() if "empty" in filename: assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) assert not scraper.streams else: evaluate_scraper(scraper, correct)
def test_mediainfo_scraper_mpeg(filename, result_dict, evaluate_scraper): """ Test MPEG scraping with MediainfoScraper. :filename: Test file name :result_dict: Result dict containing the test purpose, parts of expected results of stdout and stderr, and expected streams """ mimetype = "video/mpeg" correct = parse_results(filename, mimetype, result_dict, False) scraper = MediainfoScraper(filename=correct.filename, mimetype=mimetype) scraper.scrape_file() if "empty" in filename: assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) assert not scraper.streams else: evaluate_scraper(scraper, correct)
def test_mediainfo_scraper_mkv(filename, result_dict, evaluate_scraper): """Test Matroska scraping with Mediainfo.""" mimetype = "video/x-matroska" correct = parse_results(filename, mimetype, result_dict, True) scraper = MediainfoScraper(correct.filename, True, params={"mimetype_guess": mimetype}) scraper.scrape_file() if "empty" in filename: correct.version = None correct.streams[0]["version"] = None correct.streams[0]["stream_type"] = None if "invalid" in filename: assert partial_message_included(correct.stdout_part, scraper.messages()) assert partial_message_included(correct.stderr_part, scraper.errors()) assert not scraper.streams else: evaluate_scraper(scraper, correct)