Пример #1
0
    def add_live_streams(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]]

        """

        items = []
        if self.parentItem is None:
            live_item = MediaItem(
                "\a.: Live TV :.",
                "https://d5ms27yy6exnf.cloudfront.net/live/omroepflevoland/tv/index.m3u8"
            )
            live_item.icon = self.icon
            live_item.thumb = self.noImage
            live_item.type = 'video'
            live_item.dontGroup = True
            now = datetime.datetime.now()
            live_item.set_date(now.year, now.month, now.day, now.hour,
                               now.minute, now.second)
            items.append(live_item)

            live_item = MediaItem(
                "\a.: Live Radio :.",
                "https://d5ms27yy6exnf.cloudfront.net/live/omroepflevoland/radio/index.m3u8"
            )
            live_item.icon = self.icon
            live_item.thumb = self.noImage
            live_item.type = 'video'
            live_item.dontGroup = True
            now = datetime.datetime.now()
            live_item.set_date(now.year, now.month, now.day, now.hour,
                               now.minute, now.second)
            items.append(live_item)

        # add "More"
        more = LanguageHelper.get_localized_string(LanguageHelper.MorePages)
        current_url = self.parentItem.url if self.parentItem is not None else self.mainListUri
        url, page = current_url.rsplit("=", 1)
        url = "{}={}".format(url, int(page) + 1)

        item = MediaItem(more, url)
        item.thumb = self.noImage
        item.icon = self.icon
        item.fanart = self.fanart
        item.complete = True
        items.append(item)

        return data, items
Пример #2
0
    def __show_empty_information(self, items, favs=False):
        """ Adds an empty item to a list or just shows a message.
        @type favs: boolean
        @param items:

        :param list[MediaItem] items:   The list of items.
        :param bool favs:               Indicating that we are dealing with favourites.

        :return: boolean indicating to report the listing as succes or not.
        :rtype: ok

        """

        if favs:
            title = LanguageHelper.get_localized_string(LanguageHelper.NoFavsId)
        else:
            title = LanguageHelper.get_localized_string(LanguageHelper.ErrorNoEpisodes)

        behaviour = AddonSettings.get_empty_list_behaviour()

        Logger.debug("Showing empty info for mode (favs=%s): [%s]", favs, behaviour)
        if behaviour == "error":
            # show error
            ok = False
        elif behaviour == "dummy" and not favs:
            # We should add a dummy items, but not for favs
            empty_list_item = MediaItem("- %s -" % (title.strip("."), ), "", type='video')
            if self.channelObject:
                empty_list_item.icon = self.channelObject.icon
                empty_list_item.thumb = self.channelObject.noImage
                empty_list_item.fanart = self.channelObject.fanart
            else:
                icon = Config.icon
                fanart = Config.fanart
                empty_list_item.icon = icon
                empty_list_item.thumb = fanart
                empty_list_item.fanart = fanart

            empty_list_item.dontGroup = True
            empty_list_item.description = "This listing was left empty intentionally."
            empty_list_item.complete = True
            # add funny stream here?
            # part = empty_list_item.create_new_empty_media_part()
            # for s, b in YouTube.get_streams_from_you_tube("", self.channelObject.proxy):
            #     part.append_media_stream(s, b)

            # if we add one, set OK to True
            ok = True
            items.append(empty_list_item)
        else:
            ok = True

        XbmcWrapper.show_notification(LanguageHelper.get_localized_string(LanguageHelper.ErrorId),
                                      title, XbmcWrapper.Error, 2500)
        return ok
Пример #3
0
    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
Пример #4
0
    def add_categories(self, data):
        """ Adds categories to the main listings.

        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 and "code" in self.parentItem.metaData:
            self.__currentChannel = self.parentItem.metaData["code"]
            Logger.info("Only showing items for channel: '%s'",
                        self.__currentChannel)
            return data, items

        cat = MediaItem("\a.: Categori&euml;n :.",
                        "https://www.vrt.be/vrtnu/categorieen.model.json")
        cat.fanart = self.fanart
        cat.thumb = self.noImage
        cat.icon = self.icon
        cat.dontGroup = True
        items.append(cat)

        live = MediaItem("\a.: Live Streams :.",
                         "https://services.vrt.be/videoplayer/r/live.json")
        live.fanart = self.fanart
        live.thumb = self.noImage
        live.icon = self.icon
        live.dontGroup = True
        live.isLive = True
        items.append(live)

        channel_text = LanguageHelper.get_localized_string(30010)
        channels = MediaItem("\a.: %s :." % (channel_text, ), "#channels")
        channels.fanart = self.fanart
        channels.thumb = self.noImage
        channels.icon = self.icon
        channels.dontGroup = True
        items.append(channels)

        Logger.debug("Pre-Processing finished")
        return data, items
    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.icon = self.icon
        item.thumb = thumb
        item.description = "%s\n\n%s" % (description_nl, description)
        item.description = item.description.strip()
        item.complete = True
        return item
Пример #6
0
    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.icon = self.icon
        item.complete = True
        return item
Пример #7
0
    def list_channels(self, data):
        """ Lists all the available channels.

        :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 = []

        for name, meta in self.__channelData.items():
            if "metaCode" not in meta:
                continue

            channel = MediaItem(meta["title"], self.mainListUri)
            # noinspection PyArgumentList
            channel.fanart = meta.get("fanart", self.fanart)
            # noinspection PyArgumentList
            channel.thumb = meta.get("icon", self.icon)
            # noinspection PyArgumentList
            channel.icon = meta.get("icon", self.icon)
            channel.dontGroup = True
            channel.metaData["code"] = meta["metaCode"]
            items.append(channel)
        return data, items
Пример #8
0
    def add_live_items(self, data):
        """ Performs pre-process actions for data processing and adds the live channels if present.

        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 = []
        if self.liveUrl:
            Logger.debug("Adding live item")
            live_item = MediaItem("\aLive TV", self.liveUrl)
            live_item.icon = self.icon
            live_item.thumb = self.noImage
            live_item.dontGroup = True
            items.append(live_item)

        return data, items
Пример #9
0
    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
Пример #10
0
    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.icon = self.icon
            sub_item.thumb = self.noImage
            sub_item.dontGroup = True
            sub_item.HttpHeaders = {"X-Requested-With": "XMLHttpRequest"}
            items.append(sub_item)
        return data, items
Пример #11
0
    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.icon = self.icon
        item.httpHeaders = self.httpHeaders
        item.thumb = self.__get_nested_value(result_set, "Image",
                                             "ImageRepresentations",
                                             "ImageRepresentation", 0, "url")
        item.complete = True
        return item
Пример #12
0
    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|dict] 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://m.schooltv.nl/api/v1/programmas/%s/afleveringen.json?size=%s&sort=Nieuwste" % (
            result_set['mid'], self.__PageSize)
        item = MediaItem(result_set['title'], url)
        item.thumb = result_set.get('image', self.noImage)
        item.icon = self.icon

        item.description = result_set.get('description', None)
        age_groups = result_set.get('ageGroups', ['Onbekend'])
        item.description = "%s\n\nLeeftijden: %s" % (item.description,
                                                     ", ".join(age_groups))
        return item
Пример #13
0
    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.icon = self.icon
        item.thumb = self.noImage
        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
Пример #14
0
    def create_category_item(self, result_set):
        """ Creates a MediaItem of type 'folder' for a category 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

        """

        title = result_set["displayValue"]
        category_id = result_set["id"]
        url = "https://psapi.nrk.no/medium/tv/categories/{}/indexelements?apiKey={}"\
            .format(category_id, self.__api_key)
        item = MediaItem(title, url)
        item.icon = self.icon
        item.type = 'folder'
        item.fanart = self.fanart
        item.thumb = self.__category_thumbs.get(category_id.lower(),
                                                self.noImage)
        return item
Пример #15
0
    def create_alpha_item(self, result_set):
        """ Creates a MediaItem of type 'folder' using the Alpha chars available. It uses
        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: The result_set of the self.episodeItemRegex

        :return: A new MediaItem of type 'folder'.
        :rtype: MediaItem|None

        """

        program_count = result_set.get("availableInternationally", 0)
        if program_count <= 0:
            return None

        title = result_set["title"]
        url_part = title.lower()
        if url_part == "0-9":
            url_part = "$"
        url = "https://psapi.nrk.no/medium/tv/letters/{}/indexelements?onlyOnDemandRights=false&" \
              "apiKey={}".format(url_part, self.__api_key)

        title = LanguageHelper.get_localized_string(
            LanguageHelper.StartWith) % (title, )
        item = MediaItem(title, url)
        item.icon = self.icon
        item.type = 'folder'
        item.fanart = self.fanart
        item.thumb = self.noImage
        return item
Пример #16
0
    def add_live_streams(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]]

        """

        # add live stuff
        live = MediaItem("\bLive streams", self.__liveUrl)
        live.icon = self.icon
        live.thumb = self.noImage
        live.complete = True
        live.HttpHeaders = self.__authenticationHeaders
        items = [live]
        return data, items
Пример #17
0
    def create_api_tvshow_type(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 result_set: The result_set of the self.episodeItemRegex

        :return: A new MediaItem of type 'folder'.
        :rtype: MediaItem|None

        This works for:
            __typename=TvShow, KidsTvShow, Single

        """

        url = result_set["urls"]["svtplay"]
        item = MediaItem(result_set['name'], "#program_item")
        item.metaData["slug"] = url
        item.icon = self.icon
        item.isGeoLocked = result_set.get('restrictions',
                                          {}).get('onlyAvailableInSweden',
                                                  False)
        item.description = result_set.get('description')
        image_info = result_set.get("image")
        if image_info:
            item.thumb = self.__get_thumb(image_info)
        return item
Пример #18
0
    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.icon = self.icon
        item.complete = True
        return item
Пример #19
0
    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.icon = self.icon
        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
Пример #20
0
    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["title"].replace("-", " ").title()

        # http://www.nickjr.nl/data/propertyStreamPage.json?&urlKey=dora&apiKey=nl_global_Nickjr_web&page=1
        url = "%s/data/propertyStreamPage.json?&urlKey=%s&apiKey=%s&page=1" % (
            self.baseUrl, result_set["seriesKey"], self.__apiKey)
        item = MediaItem(title, url)
        item.icon = self.icon
        item.complete = True
        item.fanart = self.fanart
        item.HttpHeaders = self.httpHeaders
        return item
Пример #21
0
    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
Пример #22
0
    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.thumb = self.parentItem.thumb
        item.icon = self.icon
        item.fanart = self.parentItem.fanart
        item.complete = True
        return item
Пример #23
0
    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
Пример #24
0
    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.icon = self.icon
        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
Пример #25
0
    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.icon = self.icon
        item.type = 'folder'
        item.fanart = self.fanart
        item.HttpHeaders = self.httpHeaders
        item.complete = True
        return item
Пример #26
0
    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 = "%s/%s" % (self.baseUrl, result_set["url"])
        item = MediaItem(result_set["title"], url)

        item.thumb = result_set["thumburl"]
        if not item.thumb.startswith("http"):
            item.thumb = "%s%s" % (self.baseUrl, item.thumb)
        item.thumb = item.thumb.replace("coverart-small", "coverart")

        item.icon = self.icon
        item.complete = True
        return item
Пример #27
0
    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.icon = self.icon
        item.thumb = self.noImage
        item.complete = True
        return item
Пример #28
0
    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.icon = self.icon
        item.type = "video"
        # seems to not really work well with track numbers (not showing)
        # item.type = "audio"
        item.thumb = self.parentItem.thumb
        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
Пример #29
0
    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)
        item.thumb = self.noImage
        item.icon = self.icon

        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
Пример #30
0
    def search_site(self, url=None):
        """ Creates an list of items by searching the site.

        This method is called when the URL of an item is "searchSite". The channel
        calling this should implement the search functionality. This could also include
        showing of an input keyboard and following actions.

        The %s the url will be replaced with an URL encoded representation of the
        text to search for.

        :param str|None url:     Url to use to search with a %s for the search parameters.

        :return: A list with search results as MediaItems.
        :rtype: list[MediaItem]

        """

        items = []
        if url is None:
            item = MediaItem("Search Not Implented", "", type='video')
            item.icon = self.icon
            items.append(item)
        else:
            items = []
            needle = XbmcWrapper.show_key_board()
            if needle:
                Logger.debug("Searching for '%s'", needle)
                # convert to HTML
                needle = HtmlEntityHelper.url_encode(needle)
                search_url = url % (needle, )
                temp = MediaItem("Search", search_url)
                return self.process_folder_list(temp)

        return items