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_episode_item(self, result_set): """ Creates a new MediaItem for an episode. 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 """ # dummy class item = MediaItem(result_set[1], "%s/%s" % (self.baseUrl, result_set[0])) item.complete = True item.icon = self.icon item.thumb = self.noImage item.complete = True if "/het-weer" in item.url: item.type = "video" item.complete = False return item
def add_others(self, data): """ Performs pre-process actions for data processing. Accepts an data from the process_folder_list method, BEFORE the items are processed. Allows setting of parameters (like title etc) for the channel. Inside this method the <data> could be changed and additional items can be created. The return values should always be instantiated in at least ("", []). :param str data: The retrieve data that was loaded for the current item and URL. :return: A tuple of the data and a list of MediaItems that were generated. :rtype: tuple[str|JsonHelper,list[MediaItem]] """ Logger.info("Performing Pre-Processing") items = [] others = MediaItem( "\b.: Populair :.", "https://api.kijk.nl/v2/default/sections/popular_PopularVODs?offset=0" ) items.append(others) days = MediaItem("\b.: Deze week :.", "#lastweek") items.append(days) search = MediaItem("\b.: Zoeken :.", "searchSite") search.complete = True search.dontGroup = True search.HttpHeaders = {"X-Requested-With": "XMLHttpRequest"} items.append(search) if self.channelCode == "veronica": live = LanguageHelper.get_localized_string( LanguageHelper.LiveStreamTitleId) live_radio = MediaItem("Radio Veronica {}".format(live), "") live_radio.type = "video" live_radio.dontGroup = True part = live_radio.create_new_empty_media_part() live_stream = "https://talparadiohls-i.akamaihd.net/hls/live/585615/VR-Veronica-1/playlist.m3u8" if AddonSettings.use_adaptive_stream_add_on(with_encryption=False, channel=self): stream = part.append_media_stream(live_stream, 0) M3u8.set_input_stream_addon_input(stream, self.proxy) live_radio.complete = True else: for s, b in M3u8.get_streams_from_m3u8(live_stream, self.proxy): live_radio.complete = True part.append_media_stream(s, b) items.append(live_radio) Logger.debug("Pre-Processing finished") return data, items
def add_recent_items(self, data): """ Builds the "Recent" folder for this channel. :param str data: The retrieve data that was loaded for the current item and URL. :return: A tuple of the data and a list of MediaItems that were generated. :rtype: tuple[str|JsonHelper,list[MediaItem]] """ items = [] recent = MediaItem("\a .: Recent :.", "") recent.type = "folder" recent.complete = True recent.dontGroup = True items.append(recent) today = datetime.datetime.now() days = [ "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag" ] for i in range(0, 7, 1): air_date = today - datetime.timedelta(i) Logger.trace("Adding item for: %s", air_date) # Determine a nice display date day = days[air_date.weekday()] if i == 0: day = "Vandaag" elif i == 1: day = "Gisteren" elif i == 2: day = "Eergisteren" title = "%04d-%02d-%02d - %s" % (air_date.year, air_date.month, air_date.day, day) # url = "https://www.npostart.nl/media/series?page=1&dateFrom=%04d-%02d-%02d&tileMapping=normal&tileType=teaser&pageType=catalogue" % \ url = "https://xlapi.rtl.nl/version=1/fun=gemist/model=svod/bcdate=" \ "{0:04d}{1:02d}{2:02d}/".format(air_date.year, air_date.month, air_date.day) extra = MediaItem(title, url) extra.complete = True extra.icon = self.icon extra.thumb = self.noImage extra.dontGroup = True extra.set_date(air_date.year, air_date.month, air_date.day, text="") recent.items.append(extra) news = MediaItem("\a .: Zoeken :.", "#searchSite") news.type = "folder" news.complete = True news.dontGroup = True items.append(news) return data, items
def add_search_and_genres(self, data): """ Performs pre-process actions for data processing and adds a search option and genres. Accepts an data from the process_folder_list method, BEFORE the items are processed. Allows setting of parameters (like title etc) for the channel. Inside this method the <data> could be changed and additional items can be created. The return values should always be instantiated in at least ("", []). :param str data: The retrieve data that was loaded for the current item and URL. :return: A tuple of the data and a list of MediaItems that were generated. :rtype: tuple[str|JsonHelper,list[MediaItem]] """ Logger.info("Performing Pre-Processing") items = [] if self.parentItem is not None and "genre" in self.parentItem.metaData: self.__genre = self.parentItem.metaData["genre"] Logger.debug("Parsing a specific genre: %s", self.__genre) return data, items search_item = MediaItem("\a.: Sök :.", "searchSite") search_item.complete = True search_item.thumb = self.noImage search_item.dontGroup = True search_item.fanart = self.fanart # search_item.set_date(2099, 1, 1, text="") # -> No items have dates, so adding this will force a date sort in Retrospect items.append(search_item) genres_item = MediaItem("\a.: Genrer :.", "") genres_item.complete = True genres_item.thumb = self.noImage genres_item.dontGroup = True genres_item.fanart = self.fanart items.append(genres_item) # find the actual genres genre_regex = '<li[^>]+genre[^>]*><button[^>]+data-value="(?<genre>[^"]+)"[^>]*>' \ '(?<title>[^>]+)</button></li>' genre_regex = Regexer.from_expresso(genre_regex) genres = Regexer.do_regex(genre_regex, data) for genre in genres: if genre["genre"] == "all": continue genre_item = MediaItem(genre["title"], self.mainListUri) genre_item.complete = True genre_item.thumb = self.noImage genre_item.fanart = self.fanart genre_item.metaData = {"genre": genre["genre"]} genres_item.items.append(genre_item) Logger.debug("Pre-Processing finished") return data, items
def add_categories(self, data): """ Performs pre-process actions for data processing. Accepts an data from the process_folder_list method, BEFORE the items are processed. Allows setting of parameters (like title etc) for the channel. Inside this method the <data> could be changed and additional items can be created. The return values should always be instantiated in at least ("", []). :param str data: The retrieve data that was loaded for the current item and URL. :return: A tuple of the data and a list of MediaItems that were generated. :rtype: tuple[str|JsonHelper,list[MediaItem]] """ Logger.info("Performing Pre-Processing") items = [] cat = MediaItem( "\b.: Categorieën :.", "http://m.schooltv.nl/api/v1/categorieen.json?size=100") cat.complete = True cat.dontGroup = True items.append(cat) tips = MediaItem( "\b.: Tips :.", "http://m.schooltv.nl/api/v1/programmas/tips.json?size=100") tips.complete = True tips.dontGroup = True items.append(tips) data = JsonHelper(data) ages = MediaItem("\b.: Leeftijden :.", "") ages.complete = True ages.dontGroup = True for age in ("0-4", "5-6", "7-8", "9-12", "13-15", "16-18"): age_item = MediaItem( "%s Jaar" % (age, ), "http://m.schooltv.nl/api/v1/leeftijdscategorieen/%s/afleveringen.json?" "size=%s&sort=Nieuwste" % (age, self.__PageSize)) age_item.complete = True age_item.dontGroup = True ages.items.append(age_item) # We should list programs instead of videos, so just prefill them here. for program in data.get_value(): if age in program['ageGroups']: age_item.items.append(self.create_episode_item(program)) items.append(ages) Logger.debug("Pre-Processing finished") return data, items
def add_live_streams_and_recent(self, data): """ Adds the live streams for RTL-Z. Accepts an data from the process_folder_list method, BEFORE the items are processed. Allows setting of parameters (like title etc) for the channel. Inside this method the <data> could be changed and additional items can be created. The return values should always be instantiated in at least ("", []). :param str data: The retrieve data that was loaded for the current item and URL. :return: A tuple of the data and a list of MediaItems that were generated. :rtype: tuple[str|JsonHelper,list[MediaItem]] """ items = [] # let's add the RTL-Z live stream rtlz_live = MediaItem("RTL Z Live Stream", "") rtlz_live.icon = self.icon rtlz_live.thumb = self.noImage rtlz_live.complete = True rtlz_live.isLive = True rtlz_live.dontGroup = True stream_item = MediaItem( "RTL Z: Live Stream", "http://www.rtl.nl/(config=RTLXLV2,channel=rtlxl,progid=rtlz,zone=inlineplayer.rtl.nl/rtlz,ord=0)/system/video/wvx/components/financien/rtlz/miMedia/livestream/rtlz_livestream.xml/1500.wvx" ) stream_item.icon = self.icon stream_item.thumb = self.noImage stream_item.complete = True stream_item.type = "video" stream_item.dontGroup = True stream_item.append_single_stream("http://mss6.rtl7.nl/rtlzbroad", 1200) stream_item.append_single_stream("http://mss26.rtl7.nl/rtlzbroad", 1200) stream_item.append_single_stream("http://mss4.rtl7.nl/rtlzbroad", 1200) stream_item.append_single_stream("http://mss5.rtl7.nl/rtlzbroad", 1200) stream_item.append_single_stream("http://mss3.rtl7.nl/rtlzbroad", 1200) rtlz_live.items.append(stream_item) items.append(rtlz_live) # Add recent items data, recent_items = self.add_recent_items(data) return data, recent_items
def create_trailer(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 = self.parentItem.url item = MediaItem(result_set["caption"], url, "video") item.thumb = result_set["still"].replace("nocropthumb/[format]/", "") item.fanart = item.thumb item.append_single_stream(result_set['filename']) item.complete = True item.HttpHeaders = self.httpHeaders return item
def create_episode_item(self, result_set): """ Creates a new MediaItem for an episode. 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) genres = result_set[0] if self.__genre and self.__genre not in genres: Logger.debug("Item '%s' filtered due to genre: %s", result_set[2], genres) return None url = result_set[1] if "&" in url: url = HtmlEntityHelper.convert_html_entities(url) if not url.startswith("http:"): url = "%s%s" % (self.baseUrl, url) # get the ajax page for less bandwidth url = "%s?sida=1&sort=tid_stigande&embed=true" % (url, ) item = MediaItem(result_set[2], url) item.complete = True item.isGeoLocked = True return item
def create_episode_item(self, result_set): """ Creates a new MediaItem for an episode. 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 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) title = result_set["title"] description = result_set.get("description", "") description_nl = result_set.get("introduction_lan1", "") thumb = result_set["image_full"] url = "https://www.24classics.com/app/core/server_load.php?" \ "r=default&page=luister&serial=&subserial=&hook=%s" % (result_set["hook"],) item = MediaItem(title, url) item.thumb = thumb item.description = "%s\n\n%s" % (description_nl, description) item.description = item.description.strip() item.complete = True return item
def create_music_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) title = "%(composers)s - %(title)s" % result_set url = "https://www.24classics.com/app/ajax/auth.php?serial=%(serial)s" % result_set item = MediaItem(title, url) item.type = "video" # seems to not really work well with track numbers (not showing) # item.type = "audio" item.complete = False item.description = "Composers: %(composers)s\nPerformers: %(performers)s" % result_set item.set_info_label("TrackNumber", result_set["order"]) item.set_info_label("AlbumArtist", result_set["composers"].split(",")) item.set_info_label("Artist", result_set["performers"].split(",")) return item
def alpha_listing(self, data): """ Creates a alpha listing with items pointing to the alpha listing on line. :param str data: The retrieve data that was loaded for the current item and URL. :return: A tuple of the data and a list of MediaItems that were generated. :rtype: tuple[str|JsonHelper,list[MediaItem]] """ Logger.info("Generating an Alpha list for BBC") items = [] # https://www.bbc.co.uk/iplayer/a-z/a title_format = LanguageHelper.get_localized_string(LanguageHelper.StartWith) url_format = "https://www.bbc.co.uk/iplayer/a-z/%s" for char in "abcdefghijklmnopqrstuvwxyz0": if char == "0": char = "0-9" sub_item = MediaItem(title_format % (char.upper(),), url_format % (char,)) sub_item.complete = True sub_item.dontGroup = True sub_item.HttpHeaders = {"X-Requested-With": "XMLHttpRequest"} items.append(sub_item) return data, items
def add_graphql_recents(self, data): items = [] today = datetime.datetime.now() days = LanguageHelper.get_days_list() for i in range(0, 7, 1): air_date = today - datetime.timedelta(i) Logger.trace("Adding item for: %s", air_date) # Determine a nice display date day = days[air_date.weekday()] if i == 0: day = LanguageHelper.get_localized_string(LanguageHelper.Today) elif i == 1: day = LanguageHelper.get_localized_string(LanguageHelper.Yesterday) title = "%04d-%02d-%02d - %s" % (air_date.year, air_date.month, air_date.day, day) recent_url = self.__get_api_query_url( "programsByDate(date:\"{:04d}-{:02d}-{:02d}\",numOfDays:0)".format( air_date.year, air_date.month, air_date.day), "{items{__typename,title,description,guid,updated,seriesTvSeasons{id}," "imageMedia{url,label},type,sources{type,drm,file},series{title},seasonNumber," "tvSeasonEpisodeNumber,lastPubDate}}" ) extra = MediaItem(title, recent_url) extra.complete = True extra.dontGroup = True extra.metaData["title_format"] = "{2} - s{0:02d}e{1:02d}" extra.set_date(air_date.year, air_date.month, air_date.day, text="") items.append(extra) return data, items
def create_page_item(self, result_set): """ Creates a MediaItem of type 'page' 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 'page'. :rtype: MediaItem|None """ Logger.trace(result_set) next_page = result_set["next"] if not next_page: Logger.debug("No more items available") return None more = LanguageHelper.get_localized_string(LanguageHelper.MorePages) url = "%s=%s" % (self.parentItem.url.rsplit("=", 1)[0], next_page) item = MediaItem(more, url) item.complete = True return item
def create_episode_item(self, result_set): """ Creates a new MediaItem for an episode. 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 """ url = parse.urljoin( self.baseUrl, HtmlEntityHelper.convert_html_entities(result_set[0])) name = result_set[1] if name == "Tags": return None if name == "Authors": return None if name == "Most Viewed": return None if name == "Top Rated": name = "Recent" url = "http://channel9.msdn.com/Feeds/RSS" else: url = "%s?sort=atoz" % (url, ) item = MediaItem(name, url) 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 """ Logger.trace(result_set) if result_set["Type"] == "sport": # http://www.foxsports.nl/video/filter/alle/tennis/ url = "%s/video/filter/fragments/1/alle/%s/" % (self.baseUrl, result_set["Url"]) elif result_set["Type"] == "meest_bekeken": url = "%s/video/filter/fragments/1/meer" % (self.baseUrl, ) else: # http://www.foxsports.nl/video/filter/samenvattingen/ url = "%s/video/filter/fragments/1/%s/" % (self.baseUrl, result_set["Url"]) title = result_set["Title"] if not title[0].isupper(): title = "%s%s" % (title[0].upper(), title[1:]) item = MediaItem(title, url) item.complete = True item.thumb = self.noImage item.fanart = self.fanart return item
def create_episode_item_json(self, result_set): """ Creates a new MediaItem for an episode. 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 """ time_stamp = result_set["created"] if time_stamp <= 1420070400: # older items don't have videos for now return None url = "https://at5news.vinsontv.com/api/news?source=web&externalid={}".format( result_set["externalId"]) item = MediaItem(result_set["title"], url) item.complete = True item.description = result_set.get("text") date_time = DateHelper.get_date_from_posix(time_stamp) item.set_date(date_time.year, date_time.month, date_time.day) # noinspection PyTypeChecker image_data = result_set.get("media", []) for image in image_data: item.thumb = image.get("imageHigh", image["image"]) return item
def create_video_item_new(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 result_set: The result_set of the self.episodeItemRegex :type result_set: list[str]|dict[str,str] :return: A new MediaItem of type 'video' or 'audio' (despite the method's name). :rtype: MediaItem|None """ Logger.trace(result_set) videos = self.__get_nested_value(result_set, "Assets", "Video") if not videos: Logger.warning("No video information found.") return None video_infos = [vi for vi in videos if vi["fullLength"]] if len(video_infos) > 0: video_info = video_infos[0] else: Logger.warning("No full length video found.") return None # noinspection PyTypeChecker video_id = video_info["id"] url = "http://il.srgssr.ch/integrationlayer/1.0/ue/srf/video/play/%s.json" % ( video_id, ) item = MediaItem(result_set["title"], url) item.type = "video" item.thumb = self.__get_nested_value(video_info, "Image", "ImageRepresentations", "ImageRepresentation", 0, "url") item.description = self.__get_nested_value(video_info, "AssetMetadatas", "AssetMetadata", 0, "description") date_value = str(result_set["publishedDate"]) date_value = date_value[0:-6] # 2015-01-20T22:17:59" date_time = DateHelper.get_date_from_string(date_value, "%Y-%m-%dT%H:%M:%S") item.set_date(*date_time[0:6]) item.icon = self.icon item.httpHeaders = self.httpHeaders 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 result_set: The result_set of the self.episodeItemRegex :type result_set: list[str]|dict[str,dict[str,dict]] :return: A new MediaItem of type 'video' or 'audio' (despite the method's name). :rtype: MediaItem|None """ Logger.trace(result_set) if "fullengthSegment" in result_set and "segment" in result_set[ "fullengthSegment"]: video_id = result_set["fullengthSegment"]["segment"]["id"] geo_location = result_set["fullengthSegment"]["segment"][ "geolocation"] geo_block = False if "flags" in result_set["fullengthSegment"]["segment"]: geo_block = result_set["fullengthSegment"]["segment"][ "flags"].get("geoblock", None) Logger.trace("Found geoLocation/geoBlock: %s/%s", geo_location, geo_block) else: Logger.warning("No video information found.") return None url = "http://www.srf.ch/player/webservice/videodetail/index?id=%s" % ( video_id, ) item = MediaItem(result_set["titleFull"], url) item.type = "video" # noinspection PyTypeChecker item.thumb = result_set.get("segmentThumbUrl", None) # apparently only the 144 return the correct HEAD info # item.thumb = "%s/scale/width/288" % (item.thumb, ) # the HEAD will not return a size, so Kodi can't handle it # item.fanart = resultSet.get("imageUrl", None) item.description = result_set.get("description", "") date_value = str(result_set["time_published"]) # 2015-01-20 22:17:59" date_time = DateHelper.get_date_from_string(date_value, "%Y-%m-%d %H:%M:%S") item.set_date(*date_time[0:6]) item.icon = self.icon item.httpHeaders = self.httpHeaders item.complete = False 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 """ 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 add_graphql_recents(self, data): items = [] today = datetime.datetime.now() days = LanguageHelper.get_days_list() for i in range(0, 7, 1): air_date = today - datetime.timedelta(i) Logger.trace("Adding item for: %s", air_date) # Determine a nice display date day = days[air_date.weekday()] if i == 0: day = LanguageHelper.get_localized_string(LanguageHelper.Today) elif i == 1: day = LanguageHelper.get_localized_string( LanguageHelper.Yesterday) title = "%04d-%02d-%02d - %s" % (air_date.year, air_date.month, air_date.day, day) recent_url = self.__get_api_query_url( "programsByDate(date:\"{:04d}-{:02d}-{:02d}\",numOfDays:0)". format(air_date.year, air_date.month, air_date.day), self.__video_fields) extra = MediaItem(title, recent_url) extra.complete = True extra.dontGroup = True extra.metaData["title_format"] = "{2} - s{0:02d}e{1:02d}" extra.set_date(air_date.year, air_date.month, air_date.day, text="") items.append(extra) return data, items
def create_episode_item_new(self, result_set): """ Creates a new MediaItem for an episode. 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) url = "http://il.srgssr.ch/integrationlayer/1.0/ue/srf/assetSet/listByAssetGroup/%s.json?pageSize=100" % ( result_set["id"], ) item = MediaItem(result_set["title"], url) item.description = result_set.get("description", "") item.httpHeaders = self.httpHeaders item.thumb = self.__get_nested_value(result_set, "Image", "ImageRepresentations", "ImageRepresentation", 0, "url") item.complete = True return item
def create_episode_item(self, result_set): """ Creates a new MediaItem for an episode. 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) title = result_set.get("title") if not title: return None if title.islower(): title = "%s%s" % (title[0].upper(), title[1:]) link = result_set.get("feedLink") if not link.startswith("http"): link = parse.urljoin(self.baseUrl, link) item = MediaItem(title, link) item.complete = True return item
def add_category_and_live_items(self, data): """ Performs pre-process actions for data processing. Accepts an data from the process_folder_list method, BEFORE the items are processed. Allows setting of parameters (like title etc) for the channel. Inside this method the <data> could be changed and additional items can be created. The return values should always be instantiated in at least ("", []). :param str data: The retrieve data that was loaded for the current item and URL. :return: A tuple of the data and a list of MediaItems that were generated. :rtype: tuple[str|JsonHelper,list[MediaItem]] """ Logger.info("Performing Pre-Processing") items = [] sub_items = { "\a.: Direct :.": "%s/auvio/direct/" % (self.baseUrl, ), "\a.: Catégories :.": "http://www.rtbf.be/news/api/menu?site=media" } for k, v in sub_items.items(): item = MediaItem(k, v) item.complete = True item.dontGroup = True items.append(item) item.isLive = v.endswith('/direct/') Logger.debug("Pre-Processing finished") return data, items
def create_live_item(self, result_set): """ Creates a live 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|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 """ url = result_set["stream"]["highQualityUrl"] title = result_set["title"] or result_set["id"].title() item = MediaItem(title, url) item.type = "video" item.isLive = True if item.url.endswith(".mp3"): item.append_single_stream(item.url) item.complete = True return item 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 = "%s%s" % (self.baseUrl, result_set["Url"]) item = MediaItem(result_set["Title"], url) item.type = "video" item.thumb = result_set["Thumb"] item.complete = False if self.parentItem is None: item.fanart = self.fanart else: item.fanart = self.parentItem.fanart return item
def create_episode_item(self, result_set): """ Creates a new MediaItem for an episode. 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) url = "http://il.srgssr.ch/integrationlayer/1.0/ue/srf/assetSet/listByAssetGroup/%s.json" % ( result_set["id"], ) item = MediaItem(result_set["title"], url) item.description = result_set.get("description", "") item.httpHeaders = self.httpHeaders # the 0005 seems to be a quality thing: 0001, 0003, 0004, 0005 # http://www.srf.ch/webservice/picture/videogroup/c60026b7-2ed0-0001-b4b1-1f801a6355d0/0005 # http://www.srfcdn.ch/piccache/vis/videogroup/c6/00/c60026b7-2ed0-0001-b4b1-1f801a6355d0_0005_w_h_m.jpg # item.thumb = "http://www.srf.ch/webservice/picture/videogroup/%s/0005" % (resultSet["id"],) item.thumb = "http://www.srfcdn.ch/piccache/vis/videogroup/%s/%s/%s_0005_w_h_m.jpg" \ % (result_set["id"][0:2], result_set["id"][2:4], result_set["id"],) # item.thumb = resultSet.get("thumbUrl", None) # item.thumb = "%s/scale/width/288" % (item.thumb, ) # apparently only the 144 return the correct HEAD info # item.fanart = resultSet.get("imageUrl", None) $# the HEAD will not return a size, so Kodi can't handle it item.complete = True return item
def create_episode_item(self, result_set): """ Creates a new MediaItem for an episode. 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 not result_set[0] == "": self.promotionId = result_set[0] Logger.debug("Setting PromotionId to: %s", result_set[0]) return None # <li><a href="(/guide/season/[^"]+)">(\d+)</a></li> # if (self.channelCode == "southpark"): # url = "%s/ajax/seasonepisode/%s" % (self.baseUrl, result_set[2]) # url = http://www.southpark.nl/feeds/full-episode/carousel/14/424b7b57-e459-4c9c-83ca-9b924350e94d # else: url = "%s/feeds/full-episode/carousel/%s/%s" % ( self.baseUrl, result_set[2], self.promotionId) item = MediaItem("Season %02d" % int(result_set[2]), url) item.complete = True return item
def create_category(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 result_set[str,any]: The result_set of the self.episodeItemRegex :return: A new MediaItem of type 'folder'. :rtype: MediaItem|None """ result_set = result_set["@attributes"] Logger.trace(result_set) # http://www.rtbf.be/auvio/archives?caid=29&contentType=complete,extract,bonus # { # u'url': u'http://www.rtbf.be/auvio/categorie/sport/football?id=11', # u'expandorder': u'6', u'aliases': u'football', u'id': u'category-11', # u'name': u'Football' # } cid = result_set["id"].split("-")[-1] url = "%s/auvio/archives?caid=%s&contentType=complete,extract,bonus" % ( self.baseUrl, cid) item = MediaItem(result_set["name"], url) item.complete = True return item
def create_category(self, result_set): """ Creates a new MediaItem for an category folder. 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 """ # https://search.vrt.be/suggest?facets[categories]=met-audiodescriptie url = "https://search.vrt.be/suggest?facets[categories]=%(name)s" % result_set title = result_set["title"] thumb = result_set["imageStoreUrl"] if thumb.startswith("//"): thumb = "https:{}".format(thumb) item = MediaItem(title, url) item.description = title item.thumb = thumb item.type = 'folder' item.HttpHeaders = self.httpHeaders item.complete = True return item