示例#1
0
    def __init__(self, xml_path, vod_config=None):
        # Retrieve configuration if it's not set already
        if vod_config is None:
            self.vod_config = parse_config(default_config_path)
        else:
            self.vod_config = vod_config

        # The ECN 2009 options are not always supported - check configuration
        # to see whether they should be added.
        if self.vod_config.ecn_2009:
            self.param_skip = set()
        else:
            self.param_skip = {"Resolution", "Frame_Rate", "Codec"}

        self.xml_path = xml_path
        self.tree = etree.parse(self.xml_path)

        # The CableLabs VOD Metadata 1.1 specification stores metadata in "AMS"
        # and "App_Data" tags. The files that are part of the package are
        # stored in "Content" tags.
        self.D_ams = {}
        self.D_app = {}
        self.D_content = {}

        ADI = self.tree.getroot()
        self._read_package(ADI)
        self._read_title(ADI)
        self._read_elements(ADI)

        self.has_preview = "preview" in self.D_ams
        self.has_poster = "poster" in self.D_ams
        self.has_box_cover = "box cover" in self.D_ams
        self.is_delete = self.D_ams.get("Verb", "") == "DELETE"
        self.is_update = self.D_ams["package"]["Version_Major"] != "1"
示例#2
0
    def __init__(self, xml_path, vod_config=None):
        # Retrieve configuration if it's not set already
        if vod_config is None:
            self.vod_config = parse_config(default_config_path)
        else:
            self.vod_config = vod_config

        # The ECN 2009 options are not always supported - check configuration
        # to see whether they should be added.
        if self.vod_config.ecn_2009:
            self.param_skip = set()
        else:
            self.param_skip = {"Resolution", "Frame_Rate", "Codec"}

        self.xml_path = xml_path
        self.tree = etree.parse(self.xml_path)

        # The CableLabs VOD Metadata 1.1 specification stores metadata in "AMS"
        # and "App_Data" tags. The files that are part of the package are
        # stored in "Content" tags.
        self.D_ams = {}
        self.D_app = {}
        self.D_content = {}

        ADI = self.tree.getroot()
        self._read_package(ADI)
        self._read_title(ADI)
        self._read_elements(ADI)

        self.has_preview = "preview" in self.D_ams
        self.has_poster = "poster" in self.D_ams
        self.has_box_cover = "box cover" in self.D_ams
        self.is_delete = self.D_ams.get("Verb", '') == "DELETE"
        self.is_update = self.D_ams["package"]["Version_Major"] != "1"
示例#3
0
 def __init__(self, xml_path=None, vod_config=None, NewValuesArray={}):
     
     
     self.xml_path = xml_path
     self.tree = etree.parse(self.xml_path)
         
     self.D_ams = {}
     self.D_app = {}
     self.D_content = {}    
     
     if len(NewValuesArray) > 0:
         self.NewValuesArray = NewValuesArray;
     
     ADI = self.tree.getroot()
     self._read_package(ADI)
     self._read_title(ADI)
     self._read_elements(ADI)
示例#4
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']
        )