def __fetch_textures(self):
        textures_to_retrieve = TextureHandler.instance(
        ).number_of_missing_textures()

        if textures_to_retrieve > 0:
            w = None
            try:
                # show a blocking or background progress bar
                if textures_to_retrieve > 4:
                    w = XbmcDialogProgressWrapper(
                        "%s: %s" % (Config.appName,
                                    LanguageHelper.get_localized_string(
                                        LanguageHelper.InitChannelTitle)),
                        LanguageHelper.get_localized_string(
                            LanguageHelper.FetchTexturesTitle),
                        # Config.textureUrl
                    )
                else:
                    w = XbmcDialogProgressBgWrapper(
                        "%s: %s" % (Config.appName,
                                    LanguageHelper.get_localized_string(
                                        LanguageHelper.FetchTexturesTitle)),
                        Config.textureUrl)

                TextureHandler.instance().fetch_textures(w.progress_update)
            except:
                Logger.error("Error fetching textures", exc_info=True)
            finally:
                if w is not None:
                    # always close the progress bar
                    w.close()
        return
示例#2
0
    def __initialise_channel_set(self, channel_info):
        # type: (ChannelInfo) -> None
        """ Initialises a channelset (.py file)

        WARNING: these actions are done ONCE per python file, not per channel.

        Arguments:
        channelInfo : ChannelInfo - The channelinfo

        Keyword Arguments:
        abortOnNew  : Boolean - If set to true, channel initialisation will not continue if a new channel was found.
                                This will have to be done later.

        Returns True if any operations where executed

        """

        Logger.info("Initialising channel set at: %s.", channel_info.path)

        # now import (required for the PerformFirstTimeActions
        sys.path.append(channel_info.path)

        # make sure a pyo or pyc exists
        # __import__(channelInfo.moduleName)
        # The debugger won't compile if __import__ is used. So let's use this one.
        import py_compile
        py_compile.compile(os.path.join(channel_info.path, "%s.py" % (channel_info.moduleName,)))

        # purge the texture cache.
        if TextureHandler.instance():
            TextureHandler.instance().purge_texture_cache(channel_info)
        else:
            Logger.warning("Could not purge_texture_cache: no TextureHandler available")
        return
示例#3
0
    def get_image_location(self, image):
        """ Returns the path for a specific image name.

        :param str image: the filename of the requested argument.

        :return: The full local path to the requested image.
        :rtype: str

        """

        return TextureHandler.instance().get_texture_uri(self, image)
示例#4
0
    def __get_image_path(self, image):
        """ Tries to determine the path of an image

        Arguments:
        image : String - The filename (not path) of the image

        Returns the path of the image. In case of a Kodi skin image it will
        return just the filename, else the full path.

        """

        return TextureHandler.instance().get_texture_uri(self, image)
示例#5
0
    def init_channel(self):
        """Initializes the channel and will call some post processing stuff.

        This method is called for each add-on call and can be used to do some
        channel initialisation.

        """

        Logger.debug("Initializing channel (init_channel): %s", self)

        # Make sure all images are from the correct absolute location
        # self.icon = self.get_image_location(self.icon) -> already in the __init__
        # self.fanart = self.get_image_location(self.fanart) -> already in the __init__
        self.noImage = TextureHandler.instance().get_texture_uri(
            self, self.noImage)
        return
    def __init__(self, channel_info):
        """ Initialisation of the class.

        All class variables should be instantiated here and this method should not
        be overridden by any derived classes.

        :param ChannelInfo channel_info: The channel info object to base this channel on.

        """

        chn_class.Channel.__init__(self, channel_info)

        # ============== Actual channel setup STARTS here and should be overwritten from derived classes ===============
        self.noImage = "vrtnuimage.png"
        self.mainListUri = "https://www.vrt.be/vrtnu/a-z/"
        self.baseUrl = "https://www.vrt.be"

        # first regex is a bit tighter than the second one.
        episode_regex = r'<a[^>]+href="(?<url>/vrtnu[^"]+)"[^>]*>(?<title>[^<]+)\s*</a>\s*</h3>\s*<div[^>]+>(?:<p>)?(?<description>[^<]*)(?:<br[^>]*>)?(?<descriptionMore>[^<]*)?(?:</p>)?\W*</div>\s*(?:<p[^>]*data-brand="(?<channel>[^"]+)"[^>]*>[^<]+</p>)?\s*(?:<img[\w\W]{0,100}?data-responsive-image="(?<thumburl>//[^" ]+)")?'
        episode_regex = Regexer.from_expresso(episode_regex)
        self._add_data_parser(self.mainListUri,
                              name="Main A-Z listing",
                              preprocessor=self.add_categories,
                              match_type=ParserData.MatchExact,
                              parser=episode_regex,
                              creator=self.create_episode_item)

        self._add_data_parser("#channels",
                              name="Main channel name listing",
                              preprocessor=self.list_channels)

        self._add_data_parser(
            "https://search.vrt.be/suggest?facets[categories]",
            name="JSON Show Parser",
            json=True,
            parser=[],
            creator=self.create_show_item)

        self._add_data_parser(
            "https://services.vrt.be/videoplayer/r/live.json",
            json=True,
            name="Live streams parser",
            parser=[],
            creator=self.create_live_stream)
        self._add_data_parsers(
            ["http://live.stream.vrt.be/", "https://live-vrt.akamaized.net"],
            name="Live streams updater",
            updater=self.update_live_video)
        self._add_data_parser(r"https://live-[^/]+\.vrtcdn\.be",
                              match_type=ParserData.MatchRegex,
                              name="Live streams updater",
                              updater=self.update_live_video)

        catregex = r'<a[^>]+href="(?<url>/vrtnu/categorieen/(?<catid>[^"]+)/)"[^>]*>(?<title>[^<]+)\s*</a>\s*</h3>\s*<img[\w\W]{0,100}?data-responsive-image="(?<thumburl>//[^" ]+)"'
        catregex = Regexer.from_expresso(catregex)
        self._add_data_parser("https://www.vrt.be/vrtnu/categorieen/",
                              name="Category parser",
                              match_type=ParserData.MatchExact,
                              parser=catregex,
                              creator=self.create_category)

        folder_regex = r'<li class="vrt-labelnav--item "[^>]*>\s*<h2[^<]*>\s*<a[^>]*href="' \
                       r'(?<url>[^"]+)"[^>]*>(?<title>[^<]+)</a>'
        folder_regex = Regexer.from_expresso(folder_regex)
        self._add_data_parser("*",
                              name="Folder/Season parser",
                              parser=folder_regex,
                              creator=self.create_folder_item)

        video_regex = r'<a[^>]+href="(?<url>/vrtnu/(?:[^/]+/){2}[^/]*?(?<year>\d*)/[^"]+)"[^>]*>\W*' \
                      r'<div[^>]*>\W*<h[23][^>]*>\s*(?<title>[^<]+)\s*(?:<br />\s*)*</h[23]>\W*' \
                      r'<p[^>]*>\W*(?:<span[^>]*class="vrtnu-list--item-meta[^>]*>\W*(?<day>\d+)/' \
                      r'(?<month>\d+)[^<]*</span>\W*<span[^>]+>[^<]*</span>|)' \
                      r'(\W*(?<subtitle>[^|]+)\W*\|)?[^<]*<abbr[\w\W]{0,1000}?' \
                      r'<source srcset="[^"]+(?<thumburl>//[^ ]+)'

        # No need for a subtitle for now as it only includes the textual date
        video_regex = Regexer.from_expresso(video_regex)
        self._add_data_parser("*",
                              name="Video item parser",
                              parser=video_regex,
                              creator=self.create_video_item)

        # needs to be after the standard video item regex
        single_video_regex = r'<script type="application/ld\+json">\W+({[\w\W]+?})\s*</script'
        single_video_regex = Regexer.from_expresso(single_video_regex)
        self._add_data_parser("*",
                              name="Single video item parser",
                              parser=single_video_regex,
                              creator=self.create_single_video_item)

        self._add_data_parser("*",
                              updater=self.update_video_item,
                              requires_logon=True)

        # ===============================================================================================================
        # non standard items
        self.__hasAlreadyVideoItems = False
        self.__currentChannel = None

        # The key is the channel live stream key
        self.__channelData = {
            "vualto_mnm": {
                "title":
                "MNM",
                "metaCode":
                "mnm",
                "fanart":
                TextureHandler.instance().get_texture_uri(
                    self, "mnmfanart.jpg"),
                "thumb":
                TextureHandler.instance().get_texture_uri(
                    self, "mnmimage.jpg"),
                "icon":
                TextureHandler.instance().get_texture_uri(self, "mnmicon.png")
            },
            "vualto_stubru": {
                "title":
                "Studio Brussel",
                "metaCode":
                "stubru",
                "fanart":
                TextureHandler.instance().get_texture_uri(
                    self, "stubrufanart.jpg"),
                "thumb":
                TextureHandler.instance().get_texture_uri(
                    self, "stubruimage.jpg"),
                "icon":
                TextureHandler.instance().get_texture_uri(
                    self, "stubruicon.png")
            },
            "vualto_een": {
                "title":
                "E&eacute;n",
                "metaCode":
                "een",
                "fanart":
                TextureHandler.instance().get_texture_uri(
                    self, "eenfanart.jpg"),
                "thumb":
                TextureHandler.instance().get_texture_uri(
                    self, "eenimage.png"),
                "icon":
                TextureHandler.instance().get_texture_uri(
                    self, "eenlarge.png"),
                "url":
                "https://live-vrt.akamaized.net/groupc/live/8edf3bdf-7db3-41c3-a318-72cb7f82de66/live_aes.isml/.m3u8"
            },
            "vualto_canvas": {
                "title":
                "Canvas",
                "metaCode":
                "canvas",
                "fanart":
                TextureHandler.instance().get_texture_uri(
                    self, "canvasfanart.png"),
                "thumb":
                TextureHandler.instance().get_texture_uri(
                    self, "canvasimage.png"),
                "icon":
                TextureHandler.instance().get_texture_uri(
                    self, "canvaslarge.png"),
                "url":
                "https://live-vrt.akamaized.net/groupc/live/14a2c0f6-3043-4850-88a5-7fb062fe7f05/live_aes.isml/.m3u8"
            },
            "vualto_ketnet": {
                "title":
                "KetNet",
                "metaCode":
                "ketnet",
                "fanart":
                TextureHandler.instance().get_texture_uri(
                    self, "ketnetfanart.jpg"),
                "thumb":
                TextureHandler.instance().get_texture_uri(
                    self, "ketnetimage.jpg"),
                "icon":
                TextureHandler.instance().get_texture_uri(
                    self, "ketnetlarge.png"),
                "url":
                "https://live-vrt.akamaized.net/groupc/live/f132f1b8-d04d-404e-90e0-6da1abb4f4fc/live_aes.isml/.m3u8"
            },
            "vualto_sporza":
            {  # not in the channel filter maps, so no metaCode
                "title":
                "Sporza",
                "fanart":
                TextureHandler.instance().get_texture_uri(
                    self, "sporzafanart.jpg"),
                "thumb":
                TextureHandler.instance().get_texture_uri(
                    self, "sporzaimage.jpg"),
                "icon":
                TextureHandler.instance().get_texture_uri(
                    self, "sporzalarge.png"),
                "url":
                "https://live-vrt.akamaized.net/groupa/live/7d5f0e4a-3429-4861-91d4-aa3229d7ad7b/live_aes.isml/.m3u8"
            },
            "ketnet-jr": {  # Not in the live channels
                "title":
                "KetNet Junior",
                "metaCode":
                "ketnet-jr",
                "fanart":
                TextureHandler.instance().get_texture_uri(
                    self, "ketnetfanart.jpg"),
                "thumb":
                TextureHandler.instance().get_texture_uri(
                    self, "ketnetimage.jpg"),
                "icon":
                TextureHandler.instance().get_texture_uri(
                    self, "ketnetlarge.png")
            }
        }

        # To get the tokens:
        # POST
        # Content-Type:application/json
        # https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/tokens

        # ===============================================================================================================
        # Test cases:

        # ====================================== Actual channel setup STOPS here =======================================
        return
示例#7
0
    def __init__(self, channel_info):
        """ Initialisation of the class.

        All class variables should be instantiated here and this method should not
        be overridden by any derived classes.

        :param ChannelInfo channel_info: The channel info object to base this channel on.

        """

        Logger.info("Initializing channel (__init__): %s", channel_info)

        self.mainListItems = []
        self.parentItem = None

        # The proxy to be used for this channel
        self.proxy = AddonSettings.get_proxy_for_channel(channel_info)
        self.localIP = AddonSettings.get_local_ip_header_for_channel(
            channel_info)

        # More and more API's need a specific set of headers. This set is used for the self.mainListUri, and is set to
        # all items generated by the chn_class.py.
        self.httpHeaders = dict()
        self.loggedOn = False

        # Initialize channel stuff from ChannelInfo object
        self.guid = channel_info.guid
        self.id = channel_info.id

        self.channelName = channel_info.channelName
        self.safeName = channel_info.safe_name
        self.channelCode = channel_info.channelCode
        self.channelDescription = channel_info.channelDescription
        self.moduleName = channel_info.moduleName
        self.compatiblePlatforms = channel_info.compatiblePlatforms
        self.sortOrder = channel_info.sortOrder
        self.sortOrderPerCountry = channel_info.sortOrderPerCountry
        self.category = channel_info.category
        self.language = channel_info.language
        self.path = channel_info.path
        self.version = channel_info.version
        self.adaptiveAddonSelectable = channel_info.adaptiveAddonSelectable
        self.hasSettings = channel_info.settings is not None and len(
            channel_info.settings) > 0

        # get the textures from the channelinfo and get their full uri's.
        self.icon = TextureHandler.instance().get_texture_uri(
            self, channel_info.icon)
        self.fanart = TextureHandler.instance().get_texture_uri(
            self, channel_info.fanart)

        # ============== Actual channel setup STARTS here and should be overwritten from derived classes ===============
        self.noImage = ""

        # set context menu items
        self.contextMenuItems = []

        # configure login stuff
        self.requiresLogon = False

        # setup the urls
        self.mainListUri = ""
        self.baseUrl = ""
        self.swfUrl = ""

        # setup the main parsing data
        # self.dataHandlers = dict()
        # self.updateHandlers = dict()
        self.dataParsers = dict()

        self.episodeItemRegex = ''  # : used for the ParseMainList
        self.episodeItemJson = None  # : used for the ParseMainList
        self.videoItemRegex = ''  # : used for the ParseMainList
        self.videoItemJson = None  # : used for the ParseMainList
        self.folderItemRegex = ''  # : used for the create_folder_item
        self.folderItemJson = None  # : used for the create_folder_item
        self.mediaUrlRegex = ''  # : used for the update_video_item
        self.mediaUrlJson = None  # : used for the update_video_item
        """
            The ProcessPageNavigation method will parse the current data using the pageNavigationRegex. It will
            create a pageItem using the create_page_item method. If no create_page_item method is in the channel,
            a default one will be created with the number present in the resultset location specified in the
            pageNavigationRegexIndex and the url from the combined resultset. If that url does not contain http://
            the self.baseUrl will be added.
        """
        self.pageNavigationIndicationRegex = ''
        self.pageNavigationRegex = ''
        self.pageNavigationJson = None
        self.pageNavigationRegexIndex = 0
        self.pageNavigationJsonIndex = None

        #===============================================================================================================
        # non standard items

        #===============================================================================================================
        # Test cases:

        # ====================================== Actual channel setup STOPS here =======================================
        return