Ejemplo n.º 1
0
    def __FetchTextures(self):
        texturesToRetrieve = TextureHandler.Instance().NumberOfMissingTextures()

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

                bytesTransfered = TextureHandler.Instance().FetchTextures(w.ProgressUpdate)
                if bytesTransfered > 0:
                    Statistics.RegisterCdnBytes(bytesTransfered)
            except:
                Logger.Error("Error fetching textures", exc_info=True)
            finally:
                if w is not None:
                    # always close the progress bar
                    w.Close()
        return
Ejemplo n.º 2
0
    def __init__(self, cdn_url, cache_path, cache_uri, logger, uri_handler):
        """ Creates a Cached Texture handler

        @param cdn_url:          The URL of the CDN
        @param cache_path:       The os path of the profile for caching
        @param cache_uri:        The uri path (Kodi uri special:// ) for caching
        @param logger:          The Logger instance
        @param uri_handler:      The UriHandler instance

        """

        TextureHandler.__init__(self, logger)

        self.__cdnUrl = cdn_url
        if not self.__cdnUrl:
            self.__cdnUrl = "https://cdn.rieter.net/plugin.video.retrospect.cdn/"

        self.__channelTexturePath = os.path.join(cache_path, "textures")
        self.__channelTextureUri = "%s/%s" % (cache_uri, "textures")
        if not os.path.isdir(self.__channelTexturePath):
            os.makedirs(self.__channelTexturePath)

        self.__uriHandler = uri_handler

        self.__textureQueue = {}
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
    def __init__(self, cdnUrl, cachePath, logger, uriHandler):
        TextureHandler.__init__(self, logger)

        self.__cdnUrl = cdnUrl
        if not self.__cdnUrl:
            self.__cdnUrl = "http://www.rieter.net/net.rieter.xot.cdn/"

        self.__channelTexturePath = os.path.join(cachePath, "textures")
        if not os.path.isdir(self.__channelTexturePath):
            os.makedirs(self.__channelTexturePath)

        self.__uriHandler = uriHandler

        self.__textureQueue = {}
Ejemplo n.º 6
0
    def __InitialiseChannelSet(self, channelInfo):
        """ 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", channelInfo.path)

        # now import (required for the PerformFirstTimeActions
        sys.path.append(channelInfo.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(channelInfo.path, "%s.py" % (channelInfo.moduleName,)))

        # see if the channel included XOT updates
        self.__DeployUpdates(channelInfo.path)

        # purge the texture cache.
        TextureHandler.Instance().PurgeTextureCache(channelInfo)
        return True
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
0
    def __GetImagePath(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 XBMC skin image it will
        return just the filename, else the full path.

        """

        # if Config.CdnUrl is None:
        #     return os.path.join(self.path, image)
        #
        # return "%s%s" % (Config.CdnUrl, image)
        return TextureHandler.Instance().GetTextureUri(self, image)
Ejemplo n.º 10
0
    def GetImageLocation(self, image):
        """returns the path for a specific image name.

        Arguments:
        image : string - the filename of the requested argument.

        Returns:
        The full local path to the requested image.

        """

        # if Config.CdnUrl is None:
        #     return os.path.join(os.path.dirname(sys.modules[self.__module__].__file__), image)
        # return "%s%s" % (Config.CdnUrl, image)

        return TextureHandler.Instance().GetTextureUri(self, image)
Ejemplo n.º 11
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
Ejemplo n.º 12
0
    def InitChannel(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 (InitChannel): %s", self)

        # Make sure all images are from the correct absolute location
        # self.icon = self.GetImageLocation(self.icon) -> already in the __init__
        # self.fanart = self.GetImageLocation(self.fanart) -> already in the __init__
        self.noImage = TextureHandler.Instance().GetTextureUri(self, self.noImage)

        # perhaps log on?
        self.loggedOn = self.LogOn(self.userName, self.passWord)

        if not self.loggedOn:
            Logger.Error('Not logged on...exiting')
            return False

        return
Ejemplo n.º 13
0
def RunPlugin():
    """ Runs Retrospect as a Video Add-On """

    logFile = None

    try:
        from config import Config
        from helpers.sessionhelper import SessionHelper

        # get a logger up and running
        from logger import Logger

        # only append if there are no active sessions
        if not SessionHelper.IsSessionActive():
            # first call in the session, so do not append the log
            appendLogFile = False
        else:
            appendLogFile = True

        logFile = Logger.CreateLogger(os.path.join(Config.profileDir,
                                                   Config.logFileNameAddon),
                                      Config.appName,
                                      append=appendLogFile,
                                      dualLogger=lambda x, y=4: xbmc.log(x, y))

        from urihandler import UriHandler
        from addonsettings import AddonSettings
        from textures import TextureHandler

        # update the loglevel
        Logger.Instance().minLogLevel = AddonSettings.GetLogLevel()

        useCaching = AddonSettings.CacheHttpResponses()
        cacheDir = None
        if useCaching:
            cacheDir = Config.cacheDir

        # determine the platform
        from envcontroller import EnvController
        from environments import Environments
        maxFileNameLength = None
        if EnvController.IsPlatform(Environments.Xbox):
            maxFileNameLength = 42

        ignoreSslErrors = AddonSettings.IgnoreSslErrors()
        UriHandler.CreateUriHandler(cacheDir=cacheDir,
                                    maxFileNameLength=maxFileNameLength,
                                    cookieJar=os.path.join(
                                        Config.profileDir, "cookiejar.dat"),
                                    ignoreSslErrors=ignoreSslErrors)

        # start texture handler
        TextureHandler.SetTextureHandler(Config, Logger.Instance(),
                                         UriHandler.Instance())

        # run the plugin
        import plugin
        plugin.Plugin(sys.argv[0], sys.argv[2], sys.argv[1])

        # close the log to prevent locking on next call
        Logger.Instance().CloseLog()
        logFile = None

        # make sure we leave no references behind
        AddonSettings.ClearCachedAddonSettingsObject()
    except:
        if logFile:
            logFile.Critical("Error running plugin", exc_info=True)
        raise
Ejemplo n.º 14
0
def run_plugin():
    """ Runs Retrospect as a Video Add-On """

    log_file = None

    try:
        from retroconfig import Config
        from helpers.sessionhelper import SessionHelper

        # get a logger up and running
        from logger import Logger

        # only append if there are no active sessions
        if not SessionHelper.is_session_active():
            # first call in the session, so do not append the log
            append_log_file = False
        else:
            append_log_file = True

        log_file = Logger.create_logger(
            os.path.join(Config.profileDir, Config.logFileNameAddon),
            Config.appName,
            append=append_log_file,
            dual_logger=lambda x, y=4: xbmc.log(x, y))

        from urihandler import UriHandler

        from addonsettings import AddonSettings
        AddonSettings.set_language()

        from textures import TextureHandler

        # update the loglevel
        Logger.instance().minLogLevel = AddonSettings.get_log_level()

        use_caching = AddonSettings.cache_http_responses()
        cache_dir = None
        if use_caching:
            cache_dir = Config.cacheDir

        ignore_ssl_errors = AddonSettings.ignore_ssl_errors()
        UriHandler.create_uri_handler(cache_dir=cache_dir,
                                      cookie_jar=os.path.join(
                                          Config.profileDir, "cookiejar.dat"),
                                      ignore_ssl_errors=ignore_ssl_errors)

        # start texture handler
        TextureHandler.set_texture_handler(Config, Logger.instance(),
                                           UriHandler.instance())

        # run the plugin
        import plugin
        plugin.Plugin(sys.argv[0], sys.argv[2], sys.argv[1])

        # make sure we leave no references behind
        AddonSettings.clear_cached_addon_settings_object()
        # close the log to prevent locking on next call
        Logger.instance().close_log()
        log_file = None

    except:
        if log_file:
            log_file.critical("Error running plugin", exc_info=True)
            log_file.close_log()
        raise
Ejemplo n.º 15
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.

        """

        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
Ejemplo n.º 16
0
    def __init__(self, cdnUrl, logger):
        TextureHandler.__init__(self, logger)

        self.__cdnUrl = cdnUrl
        if not self.__cdnUrl:
            self.__cdnUrl = "http://www.rieter.net/net.rieter.xot.cdn/"
Ejemplo n.º 17
0
    def __init__(self, cdn_url, logger):
        TextureHandler.__init__(self, logger)

        self.__cdnUrl = cdn_url
        if not self.__cdnUrl:
            self.__cdnUrl = "https://cdn.rieter.net/plugin.video.retrospect.cdn/"
Ejemplo n.º 18
0
    def __init__(self, channelInfo):
        """Initialisation of the class.

        Arguments:
        channelInfo: ChannelInfo - The channel info object to base this channel on.

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

        """

        Logger.Info("Initializing channel (__init__): %s", channelInfo)

        self.mainListItems = []
        self.parentItem = None

        # The proxy to be used for this channel
        self.proxy = AddonSettings.GetProxyForChannel(channelInfo)

        # 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 = channelInfo.guid

        self.channelName = channelInfo.channelName
        self.safeName = channelInfo.safeName
        self.channelCode = channelInfo.channelCode
        self.channelDescription = channelInfo.channelDescription
        self.moduleName = channelInfo.moduleName
        self.compatiblePlatforms = channelInfo.compatiblePlatforms
        self.sortOrder = channelInfo.sortOrder
        self.category = channelInfo.category
        self.language = channelInfo.language
        self.path = channelInfo.path

        # get the textures from the channelinfo and get their full uri's.
        self.icon = TextureHandler.Instance().GetTextureUri(self, channelInfo.icon)
        self.fanart = TextureHandler.Instance().GetTextureUri(self, channelInfo.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.passWord = ""
        self.userName = ""
        self.logonUrl = ""
        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 CreateFolderItem
        self.folderItemJson = None      # : used for the CreateFolderItem
        self.mediaUrlRegex = ''         # : used for the UpdateVideoItem
        self.mediaUrlJson = None        # : used for the UpdateVideoItem

        """
            The ProcessPageNavigation method will parse the current data using the pageNavigationRegex. It will
            create a pageItem using the CreatePageItem method. If no CreatePageItem 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
Ejemplo n.º 19
0
    def __init__(self, channelInfo):
        """Initialisation of the class.

        Arguments:
        channelInfo: ChannelInfo - The channel info object to base this channel on.

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

        """

        chn_class.Channel.__init__(self, channelInfo)

        # ============== 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"

        episodeRegex = '<a[^>]+href="(?<url>/vrtnu[^"]+)"[^>]*>(?:\W*<div[^>]*>\W*){2}' \
                       '<picture[^>]*>\W+(?:<[^>]+>\W*){3}<source[^>]+srcset="(?<thumburl>[^ ]+)' \
                       '[\w\W]{0,1000}?<h3[^>]+>(?<title>[^<]+)</h3>\W*<hr[^>]*>\W*' \
                       '(?:<div[^>]*>|<div[^>]*><p>)(?<description>[^<]+)(?:<br[^>]*>)?' \
                       '(?<descriptionMore>[^<]*)?(?:</div>|</p></div>)(?:\W*</div>){1}\W+' \
                       '(?:<div class="tile__brand"[^>]+>\W+<svg[^>]+>\W+<title[^<]+</title>\W+' \
                       '<use xlink:href="[^"]*#logo-(?<channel>[^"]+)"><.use>\W+</svg>\W+' \
                       '</div>){0,1}\W+</a>'
        episodeRegex = Regexer.FromExpresso(episodeRegex)
        self._AddDataParser(self.mainListUri, name="Main A-Z listing",
                            preprocessor=self.AddCategories,
                            matchType=ParserData.MatchExact,
                            parser=episodeRegex, creator=self.CreateEpisodeItem)

        self._AddDataParser("#channels", name="Main channel name listing",
                            preprocessor=self.ListChannels)

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

        self._AddDataParser("https://services.vrt.be/videoplayer/r/live.json", json=True,
                            name="Live streams parser",
                            parser=(), creator=self.CreateLiveStream)
        self._AddDataParser("http://live.stream.vrt.be/",
                            name="Live streams updater",
                            updater=self.UpdateLiveVideo)
        self._AddDataParser("https://live-[^/]+\.vrtcdn\.be",
                            matchType=ParserData.MatchRegex,
                            name="Live streams updater",
                            updater=self.UpdateLiveVideo)

        catregex = '<a[^>]+href="(?<url>/vrtnu/categorieen/(?<catid>[^"]+)/)"[^>]*>(?:\W*<div[^>]' \
                   '*>\W*){2}<picture[^>]*>\W+(?:<[^>]+>\W*){3}<source[^>]+srcset="' \
                   '(?<thumburl>[^ ]+)[\w\W]{0,2000}?<h3[^>]+>(?<title>[^<]+)'
        catregex = Regexer.FromExpresso(catregex)
        self._AddDataParser("https://www.vrt.be/vrtnu/categorieen/", name="Category parser",
                            matchType=ParserData.MatchExact,
                            parser=catregex,
                            creator=self.CreateCategory)

        folderRegex = '<option[^>]+data-href="/(?<url>[^"]+)">(?<title>[^<]+)</option>'
        folderRegex = Regexer.FromExpresso(folderRegex)
        self._AddDataParser("*", name="Folder/Season parser",
                            parser=folderRegex, creator=self.CreateFolderItem)

        videoRegex = '<a[^>]+href="(?<url>/vrtnu[^"]+)"[^>]*>(?:\W*<div[^>]*>\W*){2}<picture[^>]' \
                     '*>\W+(?:<[^>]+>\W*){3}<source[^>]+srcset="(?<thumburl>[^ ]+)[^>]*>\W*' \
                     '(?:<[^>]+>\W*){3}<img[^>]+>\W*(?:</\w+>\W*)+<div[^>]+>\W*<h3[^>]+>' \
                     '(?<title>[^<]+)</h3>[\w\W]{0,1000}?(?:<span[^>]+class="tile__broadcastdate' \
                     '--mobile[^>]*>(?<day>\d+)/(?<month>\d+)/?(?<year>\d+)?</span><span[^>]+' \
                     'tile__broadcastdate--other[^>]+>(?<subtitle_>[^<]+)</span></div>\W*<div>)?' \
                     '[^<]*<abbr[^>]+title'
        # No need for a subtitle for now as it only includes the textual date
        videoRegex = Regexer.FromExpresso(videoRegex)
        self._AddDataParser("*", name="Video item parser",
                            parser=videoRegex, creator=self.CreateVideoItem)

        # needs to be after the standard video item regex
        singleVideoRegex = '<picture[^>]*>\W+(?:<[^>]+>\W*){3}<source[^>]+srcset="(?<thumburl>' \
                           '[^ ]+)[\w\W]{0,4000}<span[^>]+id="title"[^>]*>(?<title>[^<]+)</span>' \
                           '\W*<span[^>]+>(?<description>[^<]+)'
        singleVideoRegex = Regexer.FromExpresso(singleVideoRegex)
        self._AddDataParser("*", name="Single video item parser",
                            parser=singleVideoRegex, creator=self.CreateVideoItem)

        self._AddDataParser("*", updater=self.UpdateVideoItem, requiresLogon=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().GetTextureUri(self, "mnmfanart.jpg"),
                "thumb": TextureHandler.Instance().GetTextureUri(self, "mnmimage.jpg"),
                "icon": TextureHandler.Instance().GetTextureUri(self, "mnmicon.png"),
            },
            "vualto_stubru": {
                "title": "Studio Brussel",
                "metaCode": "stubru",
                "fanart": TextureHandler.Instance().GetTextureUri(self, "stubrufanart.jpg"),
                "thumb": TextureHandler.Instance().GetTextureUri(self, "stubruimage.jpg"),
                "icon": TextureHandler.Instance().GetTextureUri(self, "stubruicon.png"),
            },
            "vualto_een": {
                "title": "E&eacute;n",
                "metaCode": "een",
                "fanart": TextureHandler.Instance().GetTextureUri(self, "eenfanart.jpg"),
                "thumb": TextureHandler.Instance().GetTextureUri(self, "eenimage.png"),
                "icon": TextureHandler.Instance().GetTextureUri(self, "eenlarge.png")
            },
            "vualto_canvas": {
                "title": "Canvas",
                "metaCode": "canvas",
                "fanart": TextureHandler.Instance().GetTextureUri(self, "canvasfanart.png"),
                "thumb": TextureHandler.Instance().GetTextureUri(self, "canvasimage.png"),
                "icon": TextureHandler.Instance().GetTextureUri(self, "canvaslarge.png")
            },
            "vualto_ketnet": {
                "title": "KetNet",
                "metaCode": "ketnet",
                "fanart": TextureHandler.Instance().GetTextureUri(self, "ketnetfanart.jpg"),
                "thumb": TextureHandler.Instance().GetTextureUri(self, "ketnetimage.png"),
                "icon": TextureHandler.Instance().GetTextureUri(self, "ketnetlarge.png")
            },
            "vualto_sporza": {  # not in the channel filter maps, so no metaCode
                "title": "Sporza",
                "fanart": TextureHandler.Instance().GetTextureUri(self, "sporzafanart.jpg"),
                "thumb": TextureHandler.Instance().GetTextureUri(self, "sporzaimage.png"),
                "icon": TextureHandler.Instance().GetTextureUri(self, "sporzalarge.png")
            },
            "ketnet-jr": {  # Not in the live channels
                "title": "KetNet Junior",
                "metaCode": "ketnet-jr",
                "fanart": TextureHandler.Instance().GetTextureUri(self, "ketnetfanart.jpg"),
                "thumb": TextureHandler.Instance().GetTextureUri(self, "ketnetimage.png"),
                "icon": TextureHandler.Instance().GetTextureUri(self, "ketnetlarge.png")
            }
        }

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

        # ====================================== Actual channel setup STOPS here =======================================
        return
Ejemplo n.º 20
0
 def __init__(self, logger):
     TextureHandler.__init__(self, logger)
Ejemplo n.º 21
0
 def purge_texture_cache(self, channel):
     TextureHandler.purge_texture_cache(self, channel)
Ejemplo n.º 22
0
    def __init__(self, cdnUrl, logger):
        TextureHandler.__init__(self, logger)

        self.__cdnUrl = cdnUrl
        if not self.__cdnUrl:
            self.__cdnUrl = "http://www.rieter.net/net.rieter.xot.cdn/"
Ejemplo n.º 23
0
    def __init__(self, resource_add_on, logger):
        TextureHandler.__init__(self, logger)

        self.__resource_add_on = resource_add_on