def _create_video_node(self, details): """ This function creates Video OLX nodes. Args: details (Dict[str, str]): Dictionary that has Video tag value. Returns: [OLX Element]: Video OLX element. """ xml_element = element_builder(self.doc) attributes = {"youtube": "1.00:" + details["youtube"], "youtube_id_1_0": details["youtube"]} child = xml_element("video", children=None, attributes=attributes) return child
def _create_video_olx(self, doc, url_row): """ Video OLX generation happens here where each element is generated and a list is prepared. Args: doc (XML Document): The document on which the child is formed. url_row (List[Dict]): The row for that particular URL. Returns: [Xml child element]: Video OLX element """ xml_element = element_builder(doc) attributes = {} edx_id = url_row.get("Edx Id", "") youtube_id = url_row.get("Youtube Id", "") languages = url_row.get("Languages", "") if edx_id.strip() != "": attributes["edx_video_id"] = edx_id elif youtube_id.strip() != "": attributes["youtube"] = "1.00:" + youtube_id attributes["youtube_id_1_0"] = youtube_id else: raise IframeLinkParserError( "Missing Edx Id or Youtube Id for video conversion.") children = [] # For rows that contain languages generate transcript nodes if languages != "": for lang in languages.split("-"): src = f"{edx_id}-{lang}.srt" transcript = xml_element("transcript", children=None, attributes={ "language": lang, "src": src }) children.append(transcript) child = xml_element("video", children=children, attributes=attributes) return child
def _create_video_olx(self, doc, url_row): """ Video OLX generation happens here where each element is generated and a list is prepared. Args: doc (XML Document): The document on which the child is formed. url_row (List[Dict]): The row for that particular URL. Returns: [Xml child element]: Video OLX element """ xml_element = element_builder(doc) attributes = {} edx_id = url_row.get("Edx Id", "") youtube_id = url_row.get("Youtube Id", "") if edx_id.strip() != "": attributes["edx_video_id"] = edx_id elif youtube_id.strip() != "": attributes["youtube"] = "1.00:" + youtube_id attributes["youtube_id_1_0"] = youtube_id else: raise IframeLinkParserError("Missing Edx Id or Youtube Id for video conversion.") child = xml_element("video", children=None, attributes=attributes) return child