예제 #1
0
 def setUp(self, mock_random):
     self.temp_dir = mkdtemp()
     mock_random.randint.return_value = 1020
     timestamp = datetime(1999, 9, 9, 1, 2)
     vod_config = parse_config(find_data_file(default_config_path))
     self.vod_config = vod_config._replace(ecn_2009=True)
     self.vod_package = generate_metadata(reference_mp4, self.vod_config, timestamp=timestamp)
     self.ams_expected = {
         "Provider": "001",
         "Product": "MOD",
         "Version_Major": "1",
         "Version_Minor": "0",
         "Creation_Date": "1999-09-09",
         "Provider_ID": "example.com",
     }
 def setUp(self, mock_random):
     self.temp_dir = mkdtemp()
     mock_random.randint.return_value = 1020
     timestamp = datetime(1999, 9, 9, 1, 2)
     vod_config = parse_config(find_data_file(default_config_path))
     self.vod_config = vod_config._replace(ecn_2009=True)
     self.vod_package = generate_metadata(
         reference_mp4, self.vod_config, timestamp=timestamp
     )
     self.ams_expected = {
         "Provider":  "001",
         "Product": "MOD",
         "Version_Major": '1',
         "Version_Minor": '0',
         "Creation_Date": "1999-09-09",
         "Provider_ID": "example.com",
     }
예제 #3
0
    def test_custom_template(self):
        # Make a custom template file
        tree = etree.parse(default_template_path)
        doctype = b'<!DOCTYPE ADI SYSTEM "ADI.DTD">'
        ADI = tree.getroot()
        title_metadata = ADI.find("Asset").find("Metadata")
        for value in ("Scary", "Warning"):
            App_Data = etree.SubElement(title_metadata, "App_Data")
            App_Data.set("App", "MOD")
            App_Data.set("Name", "Advisories")
            App_Data.set("Value", value)

        template_path = join(self.temp_dir, "mytemplate.xml")
        with open(template_path, "wb") as outfile:
            outfile.write(tobytes(doctype, ADI))

        # Ensure that the templates values are used
        vod_package = generate_metadata(reference_mp4, self.vod_config, template_path)
        self.assertEqual(vod_package.D_app["title"]["Advisories"], ["Scary", "Warning"])
    def test_custom_template(self):
        # Make a custom template file
        tree = etree.parse(default_template_path)
        doctype = b'<!DOCTYPE ADI SYSTEM "ADI.DTD">'
        ADI = tree.getroot()
        title_metadata = ADI.find('Asset').find('Metadata')
        for value in ('Scary', 'Warning'):
            App_Data = etree.SubElement(title_metadata, "App_Data")
            App_Data.set("App", "MOD")
            App_Data.set("Name", "Advisories")
            App_Data.set("Value", value)

        template_path = join(self.temp_dir, 'mytemplate.xml')
        with open(template_path, 'wb') as outfile:
            outfile.write(tobytes(doctype, ADI))

        # Ensure that the templates values are used
        vod_package = generate_metadata(
            reference_mp4, self.vod_config, template_path
        )
        self.assertEqual(
            vod_package.D_app['title']['Advisories'], ['Scary', 'Warning']
        )
예제 #5
0
 def test_movie_only(self):
     vod_package = generate_metadata(reference_mp4, self.vod_config)
     self.assertFalse(vod_package.has_preview)
     self.assertFalse(vod_package.has_poster)
     self.assertFalse(vod_package.has_box_cover)
 def test_movie_only(self):
     vod_package = generate_metadata(reference_mp4, self.vod_config)
     self.assertFalse(vod_package.has_preview)
     self.assertFalse(vod_package.has_poster)
     self.assertFalse(vod_package.has_box_cover)
예제 #7
0
    # Retrieve the user's configuration, overriding with command line arguments
    config_path = args.config_path or default_config_path
    vod_config = parse_config(abspath(config_path))

    if args.mediainfo_path is not None:
        vod_config = vod_config._replace(mediainfo_path=args.mediainfo_path)

    template_path = args.template_path or default_template_path
    template_path = abspath(template_path)

    # If a directory was specified, switch to it
    if args.video_dir is not None:
        chdir(args.video_dir)

    for file_path in listdir(getcwd()):
        # Only process movie files (skip previews)
        file_name, file_ext = splitext(file_path)
        if file_ext not in vod_config.extensions:
            continue
        if file_name.endswith('_preview'):
            continue

        # Create the VodPackage instace
        print("Processing {}...".format(file_path))
        vod_package = generate_metadata(file_path, vod_config, template_path)

        # Write the result
        s = vod_package.write_xml(rewrite=True)
        with open(vod_package.xml_path, "wb") as outfile:
            _ = outfile.write(s)
예제 #8
0
    # Retrieve the user's configuration, overriding with command line arguments
    config_path = args.config_path or default_config_path
    vod_config = parse_config(abspath(config_path))

    if args.mediainfo_path is not None:
        vod_config = vod_config._replace(mediainfo_path=args.mediainfo_path)

    template_path = args.template_path or default_template_path
    template_path = abspath(template_path)

    # If a directory was specified, switch to it
    if args.video_dir is not None:
        chdir(args.video_dir)

    for file_path in listdir(getcwd()):
        # Only process movie files (skip previews)
        file_name, file_ext = splitext(file_path)
        if file_ext not in vod_config.extensions:
            continue
        if file_name.endswith('_preview'):
            continue

        # Create the VodPackage instace
        print("Processing {}...".format(file_path))
        vod_package = generate_metadata(file_path, vod_config, template_path)

        # Write the result
        s = vod_package.write_xml(rewrite=True)
        with open(vod_package.xml_path, "wb") as outfile:
            _ = outfile.write(s)