def create_folder_item(self, result_set): """ Creates a MediaItem of type 'folder' using the result_set from the regex. This method creates a new MediaItem from the Regular Expression or Json results <result_set>. The method should be implemented by derived classes and are specific to the channel. :param list[str]|dict[str,str] result_set: The result_set of the self.episodeItemRegex :return: A new MediaItem of type 'folder'. :rtype: MediaItem|None """ Logger.trace(result_set) if self.parentItem.url.endswith(str(DateHelper.this_year())): return None url = "%s%s" % (self.baseUrl, result_set[3]) name = result_set[4] item = MediaItem(name.title(), url) day = result_set[0] month = result_set[1] month = DateHelper.get_month_from_name(month, "nl", short=False) year = result_set[2] item.set_date(year, month, day) item.complete = True return item
def create_folder_item(self, result_set): """ Creates a MediaItem of type 'folder' using the result_set from the regex. This method creates a new MediaItem from the Regular Expression or Json results <result_set>. The method should be implemented by derived classes and are specific to the channel. :param list[str]|dict[str,str] result_set: The result_set of the self.episodeItemRegex :return: A new MediaItem of type 'folder'. :rtype: MediaItem|None """ if len(result_set) > 3 and result_set[3] != "": Logger.debug("Sub category folder found.") url = parse.urljoin( self.baseUrl, HtmlEntityHelper.convert_html_entities(result_set[3])) name = "\a.: %s :." % (result_set[4], ) item = MediaItem(name, url) item.complete = True item.type = "folder" return item url = parse.urljoin( self.baseUrl, HtmlEntityHelper.convert_html_entities(result_set[0])) name = HtmlEntityHelper.convert_html_entities(result_set[1]) helper = HtmlHelper(result_set[2]) description = helper.get_tag_content("div", {'class': 'description'}) item = MediaItem(name, "%s/RSS" % (url, )) item.type = 'folder' item.description = description.strip() date = helper.get_tag_content("div", {'class': 'date'}) if date == "": date = helper.get_tag_content("span", {'class': 'lastPublishedDate'}) if not date == "": date_parts = Regexer.do_regex(r"(\w+) (\d+)[^<]+, (\d+)", date) if len(date_parts) > 0: date_parts = date_parts[0] month_part = date_parts[0].lower() day_part = date_parts[1] year_part = date_parts[2] try: month = DateHelper.get_month_from_name(month_part, "en") item.set_date(year_part, month, day_part) except: Logger.error("Error matching month: %s", month_part, exc_info=True) item.complete = True return item
def create_video_item_hw_info(self, result_set): """ Creates a MediaItem of type 'video' using the result_set from the regex. This method creates a new MediaItem from the Regular Expression or Json results <result_set>. The method should be implemented by derived classes and are specific to the channel. If the item is completely processed an no further data needs to be fetched the self.complete property should be set to True. If not set to True, the self.update_video_item method is called if the item is focussed or selected for playback. :param list[str]|dict[str,str] result_set: The result_set of the self.episodeItemRegex :return: A new MediaItem of type 'video' or 'audio' (despite the method's name). :rtype: MediaItem|None """ xml_data = xmlhelper.XmlHelper(result_set) title = xml_data.get_single_node_content("title") # Retrieve an ID and create an URL like: http://www.youtube.com/get_video_info?hl=en_GB&asv=3&video_id=OHqu64Qnz9M url = xml_data.get_tag_attribute("enclosure", {'url': None}, {'type': 'video/youtube'}) Logger.trace(url) item = MediaItem(title, url) item.icon = self.icon item.type = 'video' # date stuff date = xml_data.get_single_node_content("pubDate") dayname, day, month, year, time, zone = date.split(' ', 6) month = DateHelper.get_month_from_name(month, language="en") hour, minute, seconds = time.split(":") Logger.trace("%s-%s-%s %s:%s", year, month, day, hour, minute) item.set_date(year, month, day, hour, minute, 0) # # description stuff description = xml_data.get_single_node_content("description") item.description = description # # thumbnail stuff item.thumb = self.noImage thumb_urls = xml_data.get_tag_attribute("enclosure", {'url': None}, {'type': 'image/jpg'}, firstOnly=False) for thumb_url in thumb_urls: if thumb_url != "" and "thumb" not in thumb_url: item.thumb = thumb_url # finish up item.complete = False return item
def create_json_video_item(self, result_set): """ Creates a MediaItem of type 'video' using the result_set from the regex. This method creates a new MediaItem from the Regular Expression or Json results <result_set>. The method should be implemented by derived classes and are specific to the channel. If the item is completely processed an no further data needs to be fetched the self.complete property should be set to True. If not set to True, the self.update_video_item method is called if the item is focussed or selected for playback. :param dict[str,str|None] result_set: The result_set of the self.episodeItemRegex :return: A new MediaItem of type 'video' or 'audio' (despite the method's name). :rtype: MediaItem|None """ Logger.trace(result_set) url = result_set["url"] if not url.startswith("http"): url = "{}{}".format(self.baseUrl, url) title = result_set["title"] item = MediaItem(title, url) item.description = result_set.get("synopsis", None) item.thumb = result_set.get("photo", self.noImage) item.type = "video" if "publicationTimeString" in result_set: try: # publicationTimeString=7 jun 2018 17:20 uur date_parts = result_set["publicationTimeString"].split(" ") day = int(date_parts[0]) month = DateHelper.get_month_from_name(date_parts[1], language="nl", short=True) year = int(date_parts[2]) hours, minutes = date_parts[3].split(":") hours = int(hours) minutes = int(minutes) item.set_date(year, month, day, hours, minutes, 0) except: Logger.warning("Error parsing date %s", result_set["publicationTimeString"], exc_info=True) item.complete = False return item
def create_video_item(self, result_set): """ Creates a MediaItem of type 'video' using the result_set from the regex. This method creates a new MediaItem from the Regular Expression or Json results <result_set>. The method should be implemented by derived classes and are specific to the channel. If the item is completely processed an no further data needs to be fetched the self.complete property should be set to True. If not set to True, the self.update_video_item method is called if the item is focussed or selected for playback. :param list[str]|dict[str,str] result_set: The result_set of the self.episodeItemRegex :return: A new MediaItem of type 'video' or 'audio' (despite the method's name). :rtype: MediaItem|None """ Logger.trace(result_set) url = result_set["url"] if not url.startswith("http"): url = "%s%s" % (self.baseUrl, url) name = result_set["title"] item = MediaItem(name, url) item.type = 'video' item.icon = self.icon item.thumb = self.noImage month = result_set["month"] month = DateHelper.get_month_from_name(month, "en", False) day = result_set["day"] year = result_set["year"] item.set_date(year, month, day) item.complete = False return item