Esempio n. 1
0
    def __init__(self):
        # Get the command line arguments
        # Get the plugin url in plugin:// notation
        self.plugin_url = sys.argv[0]
        # Get the plugin handle as an integer number
        self.plugin_handle = int(sys.argv[1])

        # Get plugin settings
        self.VIDEO = SETTINGS.getSetting('video')

        log("ARGV", repr(sys.argv))

        # Parse parameters...
        self.video_page_url = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['video_page_url'][0]
        # Get the title.
        self.title = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['title'][0]
        self.title = str(self.title)

        log("self.video_page_url", self.video_page_url)

        #
        # Play video...
        #
        self.playVideo()
    def __init__(self):
        # Get the command line arguments
        # Get the plugin url in plugin:// notation
        self.plugin_url = sys.argv[0]
        # Get the plugin handle as an integer number
        self.plugin_handle = int(sys.argv[1])

        log("ARGV", repr(sys.argv))

        # Parse parameters...
        self.plugin_category = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['plugin_category'][0]
        self.video_list_page_url = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['url'][0]
        self.next_page_possible = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['next_page_possible'][0]
        self.show_channel = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['show_channel'][0]

        log("self.video_list_page_url", self.video_list_page_url)

        #
        # Get the videos...
        #
        self.getVideos()
    def __init__(self):
        # Get the command line arguments
        # Get the plugin url in plugin:// notation
        self.plugin_url = sys.argv[0]
        # Get the plugin handle as an integer number
        self.plugin_handle = int(sys.argv[1])

        log("ARGV", repr(sys.argv))

        # Parse parameters
        # try:
        self.plugin_category = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['plugin_category'][0]
        self.video_list_page_url = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['url'][0]
        self.next_page_possible = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['next_page_possible'][0]
        self.show_channel = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['show_channel'][0]
        # except KeyError:
        #     self.plugin_category = LANGUAGE(30001)
        #     self.video_list_page_url = "http://uitzendinggemist.net/"
        #     self.next_page_possible = "False"
        #     self.show_channel = "False"

        log("self.video_list_page_url", self.video_list_page_url)

        # if self.next_page_possible == 'True':
        #     # Determine current page number and base_url
        #     # find last slash
        #     pos_of_last_slash = self.video_list_page_url.rfind('/')
        #     # remove last slash
        #     self.video_list_page_url = self.video_list_page_url[0: pos_of_last_slash]
        #     pos_of_last_slash = self.video_list_page_url.rfind('/')
        #     self.base_url = self.video_list_page_url[0: pos_of_last_slash + 1]
        #     self.current_page = self.video_list_page_url[pos_of_last_slash + 1:]
        #     self.current_page = int(self.current_page)
        #     # add last slash
        #     self.video_list_page_url = str(self.video_list_page_url) + "/"
        #
        #     log("self.base_url", self.base_url)

        #
        # Get the videos...
        #
        self.getVideos()
    def __init__(self):
        # Get the command line arguments
        # Get the plugin url in plugin:// notation
        self.plugin_url = sys.argv[0]
        # Get the plugin handle as an integer number
        self.plugin_handle = int(sys.argv[1])

        log("ARGV", repr(sys.argv))

        # Parse parameters...
        self.plugin_category = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['plugin_category'][0]
        self.video_list_page_url = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['url'][0]
        self.next_page_possible = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['next_page_possible'][0]
        self.show_channel = urllib.parse.parse_qs(
            urllib.parse.urlparse(sys.argv[2]).query)['show_channel'][0]

        log("self.video_list_page_url", self.video_list_page_url)

        # # Determine base_url
        # # find last slash
        # pos_of_last_slash = self.video_list_page_url.rfind('/')
        # # remove last slash
        # self.video_list_page_url = self.video_list_page_url[0: pos_of_last_slash]
        # pos_of_last_slash = self.video_list_page_url.rfind('/')
        # self.base_url = self.video_list_page_url[0: pos_of_last_slash + 1]
        # # add last slash
        # self.video_list_page_url = str(self.video_list_page_url) + "/"
        #
        # log("self.base_url", self.base_url)

        #
        # Get the videos...
        #
        self.getVideos()
    def getVideos(self):
        #
        # Init
        #
        # Create a list for our items.
        listing = []

        #
        # Get HTML page
        #
        response = requests.get(self.video_list_page_url)

        html_source = response.text
        html_source = convertToUnicodeString(html_source)

        # Parse response
        soup = getSoup(html_source)

        # <div class="kr_blok_main" style="height: 320px;"><h3 class="kr_blok_title"><a href="https://www.uitzendinggemist.net/aflevering/500114/Ik_Vertrek.html" title="Ik Vertrek">Ik Vertrek</a></h3><div class="kr_blok_thumb"><a href="https://www.uitzendinggemist.net/aflevering/500114/Ik_Vertrek.html" title="Ik Vertrek - Marjon En Vincent - Tsjechië"><img src="https://images.poms.omroep.nl/image/s320/c320x180/1312993.jpg" alt="Ik Vertrek - Marjon En Vincent - Tsjechië" width="180" height="102"></a></div><p class="kr_blok_subtitle">Marjon En Vincent - Tsjechië</p><p class="kr_blok_desc">Dierenwinkelmedewerkster Marjon (32) heeft de droom om met haar eigen beestenboel op het platteland van Tsjechië te wonen. Haar vriend Vincent (37) is nog niet overtuigd. H ... </p><p class="kr_blok_date">28-12-2019</p><p class="kr_blok_host">TROS</p><p class="kr_blok_more"><a href="https://www.uitzendinggemist.net/programmas/328-Ik_Vertrek.html" title="Ik Vertrek Gemist">Alle afleveringen bekijken</a></p><p class="icon"><a href="https://www.uitzendinggemist.net/zenders/Nederland-2.html" title="Nederland 2"><img src="https://www.uitzendinggemist.net/images/nederland-2-xs.png" alt="Nederland 2" width="20" height="18" border="0"></a></p></div>

        items = soup.findAll('div', attrs={'class': re.compile("^" + "kr_blok_main")})

        log("len(items)", len(items))

        for item in items:

            item = convertToUnicodeString(item)

            log("item", item)

            video_page_url = item.a['href']

            log("video_page_url", video_page_url)

            #<div class="kr_blok_main" style="height: 320px;"><h3 class="kr_blok_title"><a href="https://www.uitzendinggemist.net/aflevering/500734/Ik_Vertrek.html" title="Ik Vertrek">Ik Vertrek</a></h3><div class="kr_blok_thumb"><a href="https://www.uitzendinggemist.net/aflevering/500734/Ik_Vertrek.html" title="Ik Vertrek - Milko En Mario In Portugal"><img src="https://images.poms.omroep.nl/image/s320/c320x180/1316596.jpg" alt="Ik Vertrek - Milko En Mario In Portugal" width="180" height="102"></a></div><p class="kr_blok_subtitle">Milko En Mario In Portugal</p><p class="kr_blok_desc">Mario (47) en Milko (54) wonen in een prachtig appartement in Amsterdam Oud-Zuid. De supermarkt is om de hoek, musea zijn op loopafstand en er is altijd leven op straat. Het ste ... </p><p class="kr_blok_date">03-01-2020</p><p class="kr_blok_host">TROS</p><p class="kr_blok_more"><a href="https://www.uitzendinggemist.net/programmas/328-Ik_Vertrek.html" title="Ik Vertrek Gemist">Alle afleveringen bekijken</a></p><p class="icon"><a href="https://www.uitzendinggemist.net/zenders/Nederland-2.html" title="Nederland 2"><img src="https://www.uitzendinggemist.net/images/nederland-2-xs.png" alt="Nederland 2" width="20" height="18" border="0"></a></p></div>

            #<div class="kr_blok_main" style="height: 270px;"><h3 class="kr_blok_title">Chateau Meiland </h3><div class="kr_blok_thumb"><a href="https://www.uitzendinggemist.net/programmas/59250-Chateau_Meiland.html"><img alt="Chateau Meiland " height="102" src="https://img.kijk.nl/media/cache/computer_retina_series_program_header/imgsrc06/images/redactioneel/1085720-LS---20190520112813--0e03ad5aaa47df615ea8e4d6f1204dbd.jpg" width="180"/></a></div><div class="kr_blok_desc">Martien en Erica gaan opnieuw het huwelijksbootje in</div><p class="icon"><a href="https://www.uitzendinggemist.net/zenders/SBS-6.html" title="SBS 6"><img alt="SBS 6" border="0" height="18" src="https://www.uitzendinggemist.net/images/sbs-6-xs.png" width="20"/></a></p></div>

            try:
                title_part1 = item.a['title']

                log("tp1", title_part1)

                title_part2 = item.img['alt']

                log("tp2", title_part2)

                title_part2 = convertToUnicodeString(title_part2)
                title_part2 = title_part2.replace(title_part1, '', 1)
                title_part2 = title_part2.replace(" -", "")
                title = title_part1 + ": " + title_part2
            except:
                try:
                    title = item.select('h3')[0].get_text(strip=True)
                except:
                    title = ""

            if self.show_channel == "True":
                channel = item.select('img')[1]["alt"]

                log("channel", channel)

                channel = str(channel).replace("Nederland", "NL ")

                title = channel + ": " + title

            log("title", title)

            try:
                # Get the text of the second p-tag
                plot = item.select('p')[1].get_text(strip=True)
            except:
                try:
                    # Get the text of the second div-tag
                    plot = item.select('div')[1].get_text(strip=True)
                except:
                    plot = ""

            log("plot", plot)

            if title == "":
                pass
            else:
                title = title + " (" + plot + ")"

            log("title", title)

            thumbnail_url = item.img['src']

            log("thumbnail_url", thumbnail_url)

            context_menu_items = []
            # Add refresh option to context menu
            context_menu_items.append((LANGUAGE(30667), 'Container.Refresh'))

            # Add to list
            list_item = xbmcgui.ListItem(label=title)
            list_item.setInfo("video", {"title": title, "studio": ADDON})
            list_item.setArt({'thumb': thumbnail_url, 'icon': thumbnail_url,
                              'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')})
            list_item.setProperty('IsPlayable', 'true')

            # let's remove any non-ascii characters
            title = title.encode('ascii', 'ignore')

            parameters = {"action": "play-episode", "video_page_url": video_page_url, "title": title}
            url = self.plugin_url + '?' + urllib.parse.urlencode(parameters)
            is_folder = False
            # Add refresh option to context menu
            list_item.addContextMenuItems([('Refresh', 'Container.Refresh')])
            # Add our item to the listing as a 3-element tuple.
            listing.append((url, list_item, is_folder))

        # # Next page entry
        # if self.next_page_possible == 'True':
        #     next_page = self.current_page + 1
        #     thumbnail_url = os.path.join(IMAGES_PATH, 'next-page.png')
        #     list_item = xbmcgui.ListItem(LANGUAGE(30503))
        #     list_item.setArt({'thumb': thumbnail_url, 'icon': thumbnail_url,
        #                       'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')})
        #     list_item.setProperty('IsPlayable', 'false')
        #     parameters = {"action": "list", "plugin_category": self.plugin_category, "url": str(self.next_url),
        #                   "next_page_possible": self.next_page_possible}
        #     url = self.plugin_url + '?' + urllib.parse.urlencode(parameters)
        #     is_folder = True
        #     # Add refresh option to context menu
        #     list_item.addContextMenuItems([('Refresh', 'Container.Refresh')])
        #     # Add our item to the listing as a 3-element tuple.
        #     listing.append((url, list_item, is_folder))

        # Add our listing to Kodi
        # Large lists and/or slower systems benefit from adding all items at once via addDirectoryItems
        # instead of adding one by ove via addDirectoryItem.
        xbmcplugin.addDirectoryItems(self.plugin_handle, listing, len(listing))
        # Disable sorting
        xbmcplugin.addSortMethod(handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE)
        # Finish creating a virtual folder.
        xbmcplugin.endOfDirectory(self.plugin_handle)
Esempio n. 6
0
    def playVideo(self):
        #
        # Init
        #
        no_url_found = False
        unplayable_media_file = False
        have_valid_url = False
        video_unavailable = False

        dialog_wait = xbmcgui.DialogProgress()

        #
        # Get current list item details...
        #
        # title = convertToUnicodeString(xbmc.getInfoLabel("list_item.Title"))
        # thumbnail_url = convertToUnicodeString(xbmc.getInfoImage("list_item.Thumb"))
        # studio = convertToUnicodeString(xbmc.getInfoLabel("list_item.Studio"))
        # plot = convertToUnicodeString(xbmc.getInfoLabel("list_item.Plot"))
        # genre = convertToUnicodeString(xbmc.getInfoLabel("list_item.Genre"))

        stream_video_url = ''

        # We still need to find out the video-url
        #
        # Get HTML page
        #
        try:
            response = requests.get(self.video_page_url)
        except urllib.error.HTTPError as error:

            log("first HTTPError", error)

            # Retry to (hopefully) get rid of a time-out http error
            try:
                response = requests.get(self.video_page_url)
            except urllib.error.HTTPError as error:

                log("second HTTPError", error)

                dialog_wait.close()
                del dialog_wait
                xbmcgui.Dialog().ok(LANGUAGE(30000),
                                    LANGUAGE(30507) % (str(error)))
                exit(1)

        html_source = response.text
        html_source = convertToUnicodeString(html_source)

        # Parse response
        soup = getSoup(html_source)

        # log("html_source", html_source)

        # <a "="" href="#" onclick="window.open('http://www.npo.nl/aa-aa/01-01-2015/AT_2119244','winname',...
        items = soup.findAll('a',
                             attrs={'onclick': re.compile("^" + "window")})

        log("len(items)", len(items))

        for item in items:

            # log('item', item)

            item = convertToUnicodeString(item)

            start_pos_url = str(item).find("http")
            end_pos_url = str(item).find("'", start_pos_url)
            url = str(item)[start_pos_url:end_pos_url]

            # log("url", url)

            pos_last_slash = url.rfind("/")
            api_url_middle_part = url[pos_last_slash + 1:]

            # log("aump:", api_url_middle_part)

            # https://api.rtl.nl/watch/play/api/play/xl/9ed0c3a7-b43c-3dad-9099-8c7ab3f7e938?device=web&format=hls
            api_url = "https://api.rtl.nl/watch/play/api/play/xl/" + api_url_middle_part + "?device=web&format=hls"

            #
            # Get HTML page
            #
            try:
                response = requests.get(api_url)
            except urllib.error.HTTPError as error:

                log("first HTTPError", error)

            json_source = response.text
            json_source = convertToUnicodeString(json_source)

            log("json_source", json_source)

            #{"canPlay":true,"manifest":"https://cdn-rtlvod-h4.akamaized.net/d126579c-7897-4396-bf0d-e9913da04cf9/4cf1064e-7c33-33c5-a6d4-9baea9f515c7.ism/manifest(format=m3u8-aapl,encryption=cbc,Filter=Quality)","token":"eyJhbGciOiJSUzI1NiIsImtpZCI6IkRGMUEwNzYwODRFRTE4NDM5NTYwMjdCM0UxODIxMkZBRTA0OUM3NTgiLCJ0eXAiOiJKV1QifQ.eyJ1dWlkIjoiNGNmMTA2NGUtN2MzMy0zM2M1LWE2ZDQtOWJhZWE5ZjUxNWM3IiwidGVuYW50IjoiWGwiLCJuYmYiOjE1NzgwNzI2MzYsImV4cCI6MTU3ODA3NjIzNiwiaWF0IjoxNTc4MDcyNjM2LCJpc3MiOiJodHRwczovL2VudGl0bGVtZW50LnJ0bC5ubCIsImF1ZCI6IlJUTCJ9.OzRTzM7kfCYcU-nIe8L3uzeDnYfJFKog8gmlQh3IUmqoxxY5pcjG8lZe_HloxJJBTRbQDAhFG3f6yiwDzCg_bLYY0QvpiS_gpsKBaTyVZ9KxMi7mq5vcD1eGAL6jaOXNzmrm68zJ0ufNlPZ5dAzIcYABWfLqBH9C-iVr8lHAW6jfrtHqRvIV3r2-lezI5_qhxNThR6NyEjO7WvRdTqdBbMpa7_eVLTpvzFdtc-UKrRNViPPaTAKwMHEssjYkjwEvBkvoSRQZy-P9ahqq4B5KGo9x03kIUFXd5XgbMT4rMli_hTmRQDFBrt5Mo5JRApVp1x7BgiAJqAFvQk0zDvWnsA","kid":"1e444b87-1beb-431e-ae3c-4463bdbf2dcd","licenseUrl":"https://api.rtl.nl/watch/license/aes/?kid=1e444b87-1beb-431e-ae3c-4463bdbf2dcd"}

            data = json.loads(json_source)

            # can_play = data["canPlay"]
            #
            # log("can_play", can_play)

            manifest_url = data["manifest"]

            # log("manifest_url", manifest_url)

            have_valid_url = True
            unplayable_media_file = False
            video_url = manifest_url

            # if can_play:
            #     have_valid_url = True
            #     unplayable_media_file = False
            #     video_url = manifest_url
            # else:
            #
            #     log("skipping video that cannot be played", manifest_url)
            #
            #     have_valid_url = False
            #     video_unavailable = True
            #     video_url = ""

        log("have_valid_url", have_valid_url)

        log("video_url", video_url)

        if have_valid_url:
            list_item = xbmcgui.ListItem(path=video_url)
            xbmcplugin.setResolvedUrl(self.plugin_handle, True, list_item)

        #
        # Alert user
        #
        elif no_url_found:
            xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30505))
        elif unplayable_media_file:
            xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30506))
        elif video_unavailable:
            xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30666))
    def search(self):
        #
        # Init
        #
        list_item = ''
        is_folder = False
        self.next_page_possible = False
        # Create a list for our items.
        listing = []

        dialog_wait = xbmcgui.DialogProgress()

        # https://www.uitzendinggemist.net/index.php?page=ajax&start=0&source=&what=spek
        # Get the search-string from the user
        keyboard = xbmc.Keyboard('', LANGUAGE(30004))
        keyboard.doModal()
        if keyboard.isConfirmed():
            self.search_string = keyboard.getText()
            self.url = self.url + self.search_string

        log("self.url", self.url)

        self.video_page_url = self.url

        # We still need to find out the video-url
        #
        # Get HTML page
        #
        try:
            response = requests.get(self.video_page_url)
        except urllib.error.HTTPError as error:

            log("first HTTPError", error)

            # Retry to (hopefully) get rid of a time-out http error
            try:
                response = requests.get(self.video_page_url)
            except urllib.error.HTTPError as error:

                log("second HTTPError", error)

                dialog_wait.close()
                del dialog_wait
                xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30507) % (str(error)))
                exit(1)

        html_source = response.text
        html_source = convertToUnicodeString(html_source)

        # Parse response
        soup = getSoup(html_source)

        # log("html_source", html_source)

        # <a "="" href="#" onclick="window.open('http://www.npo.nl/aa-aa/01-01-2015/AT_2119244','winname',...
        # items = soup.findAll('a', attrs={'onclick': re.compile("^" + "window")})

        items = soup.findAll('div', attrs={'class': re.compile("^" + "kr_blok_main")})

        log("len(items)", len(items))

        for item in items:

            item = convertToUnicodeString(item)

            log("item", item)

            video_page_url = item.a['href']

            log("video_page_url", video_page_url)

            #<div class="kr_blok_main" style="height: 320px;"><h3 class="kr_blok_title"><a href="https://www.uitzendinggemist.net/aflevering/500734/Ik_Vertrek.html" title="Ik Vertrek">Ik Vertrek</a></h3><div class="kr_blok_thumb"><a href="https://www.uitzendinggemist.net/aflevering/500734/Ik_Vertrek.html" title="Ik Vertrek - Milko En Mario In Portugal"><img src="https://images.poms.omroep.nl/image/s320/c320x180/1316596.jpg" alt="Ik Vertrek - Milko En Mario In Portugal" width="180" height="102"></a></div><p class="kr_blok_subtitle">Milko En Mario In Portugal</p><p class="kr_blok_desc">Mario (47) en Milko (54) wonen in een prachtig appartement in Amsterdam Oud-Zuid. De supermarkt is om de hoek, musea zijn op loopafstand en er is altijd leven op straat. Het ste ... </p><p class="kr_blok_date">03-01-2020</p><p class="kr_blok_host">TROS</p><p class="kr_blok_more"><a href="https://www.uitzendinggemist.net/programmas/328-Ik_Vertrek.html" title="Ik Vertrek Gemist">Alle afleveringen bekijken</a></p><p class="icon"><a href="https://www.uitzendinggemist.net/zenders/Nederland-2.html" title="Nederland 2"><img src="https://www.uitzendinggemist.net/images/nederland-2-xs.png" alt="Nederland 2" width="20" height="18" border="0"></a></p></div>

            #<div class="kr_blok_main" style="height: 270px;"><h3 class="kr_blok_title">Chateau Meiland </h3><div class="kr_blok_thumb"><a href="https://www.uitzendinggemist.net/programmas/59250-Chateau_Meiland.html"><img alt="Chateau Meiland " height="102" src="https://img.kijk.nl/media/cache/computer_retina_series_program_header/imgsrc06/images/redactioneel/1085720-LS---20190520112813--0e03ad5aaa47df615ea8e4d6f1204dbd.jpg" width="180"/></a></div><div class="kr_blok_desc">Martien en Erica gaan opnieuw het huwelijksbootje in</div><p class="icon"><a href="https://www.uitzendinggemist.net/zenders/SBS-6.html" title="SBS 6"><img alt="SBS 6" border="0" height="18" src="https://www.uitzendinggemist.net/images/sbs-6-xs.png" width="20"/></a></p></div>

            try:
                title_part1 = item.a['title']

                log("tp1", title_part1)

                title_part2 = item.img['alt']

                log("tp2", title_part2)

                title_part2 = convertToUnicodeString(title_part2)
                title_part2 = title_part2.replace(title_part1, '', 1)
                title_part2 = title_part2.replace(" -", "")
                title = title_part1 + ": " + title_part2
            except:
                try:
                    title = item.select('h3')[0].get_text(strip=True)
                except:
                    title = ""

            log("title", title)

            try:
                # Get the text of the second p-tag
                plot = item.select('p')[1].get_text(strip=True)
            except:
                try:
                    # Get the text of the second div-tag
                    plot = item.select('div')[1].get_text(strip=True)
                except:
                    plot = ""

            log("plot", plot)

            if title == "":
                pass
            else:
                title = title + " (" + plot + ")"

            log("title", title)

            if self.show_channel == "True":
                channel = item.select('img')[1]["alt"]

                log("channel", channel)

                channel = str(channel).replace("Nederland", "NL ")

                title = channel + ": " + title

            thumbnail_url = item.img['src']

            log("thumbnail_url", thumbnail_url)

            # Add to list
            list_item = xbmcgui.ListItem(label=title)
            list_item.setInfo("video", {"title": title, "studio": ADDON})
            list_item.setArt({'thumb': thumbnail_url, 'icon': thumbnail_url,
                              'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')})
            list_item.setProperty('IsPlayable', 'true')

            # let's remove any non-ascii characters
            title = title.encode('ascii', 'ignore')

            parameters = {"action": "play", "video_page_url": video_page_url}
            url = self.plugin_url + '?' + urllib.parse.urlencode(parameters)
            is_folder = False
            # Add refresh option to context menu
            list_item.addContextMenuItems([('Refresh', 'Container.Refresh')])
            # Add our item to the listing as a 3-element tuple.
            listing.append((url, list_item, is_folder))

        # # Next page entry
        # if self.next_page_possible == 'True':
        #     next_page = self.current_page + 1
        #     thumbnail_url = os.path.join(IMAGES_PATH, 'next-page.png')
        #     list_item = xbmcgui.ListItem(LANGUAGE(30503))
        #     list_item.setArt({'thumb': thumbnail_url, 'icon': thumbnail_url,
        #                       'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')})
        #     list_item.setProperty('IsPlayable', 'false')
        #     parameters = {"action": "list", "plugin_category": self.plugin_category, "url": str(self.next_url),
        #                   "next_page_possible": self.next_page_possible}
        #     url = self.plugin_url + '?' + urllib.parse.urlencode(parameters)
        #     is_folder = True
        #     # Add refresh option to context menu
        #     list_item.addContextMenuItems([('Refresh', 'Container.Refresh')])
        #     # Add our item to the listing as a 3-element tuple.
        #     listing.append((url, list_item, is_folder))

        # Add our listing to Kodi
        # Large lists and/or slower systems benefit from adding all items at once via addDirectoryItems
        # instead of adding one by ove via addDirectoryItem.
        xbmcplugin.addDirectoryItems(self.plugin_handle, listing, len(listing))
        # Disable sorting
        xbmcplugin.addSortMethod(handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE)
        # Finish creating a virtual folder.
        xbmcplugin.endOfDirectory(self.plugin_handle)
    def getVideos(self):
        #
        # Init
        #
        current_page = 1
        # title = ""
        thumbnail_url = ""
        list_item = ''
        is_folder = False
        # Create a list for our items.
        listing = []

        #
        # Get HTML page
        #
        response = requests.get(self.video_list_page_url)

        html_source = response.text
        html_source = convertToUnicodeString(html_source)

        # log("html_source", html_source)

        # Parse response
        soup = getSoup(html_source)

        #<a href="https://www.uitzendinggemist.net/programmas/5339-1_April_Met_Jack_De_Aap.html" title="1 April Met Jack De Aap">1 April Met Jack De Aap</a>
        tv_shows = soup.findAll(
            'a',
            attrs={
                'href':
                re.compile("^https://www.uitzendinggemist.net/programmas/")
            })

        for tv_show in tv_shows:

            log("tv_show", tv_show)

            video_page_url = tv_show['href']

            log("video_page_url", video_page_url)

            last_part_of_video_url = str(video_page_url).replace(
                "https://www.uitzendinggemist.net/programmas/", "")

            log("last_part_of_video_url", last_part_of_video_url)

            if last_part_of_video_url == "":

                log(
                    "skipping video_page_url with empty last_part_of_video_url after https://www.uitzendinggemist.net/programmas/ in url",
                    video_page_url)

                continue

            letter_or_number = last_part_of_video_url[0:1]
            slash_or_no_slash = last_part_of_video_url[1:2]

            if letter_or_number.isalpha():

                log(
                    "skipping video_page_url with letter after https://www.uitzendinggemist.net/programmas/ in url",
                    video_page_url)

                continue

            if slash_or_no_slash == "/":

                log(
                    "skipping video_page_url with slash after number after https://www.uitzendinggemist.net/programmas/ in url",
                    video_page_url)

                continue

            title = tv_show["title"]

            if self.show_channel == "True":
                channel = tv_show.select('img')[1]["alt"]

                log("channel", channel)

                channel = str(channel).replace("Nederland", "NL ")

                title = channel + ": " + title

            log("title", title)

            context_menu_items = []
            # Add refresh option to context menu
            context_menu_items.append((LANGUAGE(30667), 'Container.Refresh'))

            # Add to list
            list_item = xbmcgui.ListItem(label=title)
            list_item.setInfo("video", {"title": title, "studio": ADDON})
            list_item.setArt({
                'thumb':
                thumbnail_url,
                'icon':
                thumbnail_url,
                'fanart':
                os.path.join(IMAGES_PATH, 'fanart-blur.jpg')
            })
            list_item.setProperty('IsPlayable', 'true')

            # let's remove any non-ascii characters
            title = title.encode('ascii', 'ignore')

            parameters = {"action": "play", "video_page_url": video_page_url}
            url = self.plugin_url + '?' + urllib.parse.urlencode(parameters)
            is_folder = False
            # Add refresh option to context menu
            list_item.addContextMenuItems([('Refresh', 'Container.Refresh')])
            # Add our item to the listing as a 3-element tuple.
            listing.append((url, list_item, is_folder))

        # # Next page entry
        # if self.next_page_possible == 'True':
        #     next_page = self.current_page + 1
        #     thumbnail_url = os.path.join(IMAGES_PATH, 'next-page.png')
        #     list_item = xbmcgui.ListItem(LANGUAGE(30503))
        #     list_item.setArt({'thumb': thumbnail_url, 'icon': thumbnail_url,
        #                       'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')})
        #     list_item.setProperty('IsPlayable', 'false')
        #     parameters = {"action": "list", "plugin_category": self.plugin_category, "url": str(self.next_url),
        #                   "next_page_possible": self.next_page_possible}
        #     url = self.plugin_url + '?' + urllib.parse.urlencode(parameters)
        #     is_folder = True
        #     # Add refresh option to context menu
        #     list_item.addContextMenuItems([('Refresh', 'Container.Refresh')])
        #     # Add our item to the listing as a 3-element tuple.
        #     listing.append((url, list_item, is_folder))

        # Add our listing to Kodi
        # Large lists and/or slower systems benefit from adding all items at once via addDirectoryItems
        # instead of adding one by ove via addDirectoryItem.
        xbmcplugin.addDirectoryItems(self.plugin_handle, listing, len(listing))
        # Disable sorting
        xbmcplugin.addSortMethod(handle=self.plugin_handle,
                                 sortMethod=xbmcplugin.SORT_METHOD_NONE)
        # Finish creating a virtual folder.
        xbmcplugin.endOfDirectory(self.plugin_handle)
    def getVideos(self):
        #
        # Init
        #
        current_page = 1
        # Create a list for our items.
        listing = []

        #
        # Get HTML page
        #

        response = requests.get(self.video_list_page_url)

        html_source = response.text
        html_source = convertToUnicodeString(html_source)

        # log("html_source", html_source)

        # Parse response
        soup = getSoup(html_source)

        #<div class="col-xs-6 col-sm-4 col-md-3 col-lg-5ths"><div class="kr_blok_main" style="height: 320px;"><h3 class="kr_blok_title"><a class="iframe2_Removethis" href="https://www.uitzendinggemist.net/aflevering/500774/The_Voice_Of_Holland.html" title="Afl. 9">Afl. 9</a></h3><div class="kr_blok_thumb"><a class="iframe_Removethis" href="https://www.uitzendinggemist.net/aflevering/500774/The_Voice_Of_Holland.html" title="The Voice Of Holland - Afl. 9"><img src="https://screenshots.rtl.nl/system/thumb/sz=355x200/uuid=0bf9b7ee-8cd7-3a2a-ad2f-dd1b5ed079bb" alt="The Voice Of Holland - Afl. 9" width="180" height="102"></a></div><p class="kr_blok_desc">Spectaculaire muzikale zoektocht van coaches Ali B, Waylon, Anouk en Lil Kleine naar de beste nieuwe zangstem van Nederland. Presentatie: Martijn Krabbé en Chantal Janzen. </p><p class="kr_blok_date">03-01-2020</p><p class="kr_blok_host">RTL4</p><p class="kr_blok_more"><a href="https://www.uitzendinggemist.net/programmas/3902-The_Voice_Of_Holland.html" title="The Voice Of Holland Gemist">Alle afleveringen bekijken</a></p><p class="icon"><a href="https://www.uitzendinggemist.net/zenders/RTL-4.html" title="RTL 4"><img src="https://www.uitzendinggemist.net/images/rtl-4-xs.png" alt="RTL 4" width="20" height="18" border="0"></a></p></div></div>

        tv_shows = soup.findAll(
            'div', attrs={'class': re.compile("^" + "kr_blok_main")})

        log("len(tv_shows)", len(tv_shows))

        for tv_show in tv_shows:

            tv_show = convertToUnicodeString(tv_show)

            log("tv_show", tv_show)

            video_page_url = tv_show.a['href']

            log("video_page_url", video_page_url)

            #<div class="kr_blok_main" style="height: 320px;"><h3 class="kr_blok_title"><a href="https://www.uitzendinggemist.net/aflevering/500734/Ik_Vertrek.html" title="Ik Vertrek">Ik Vertrek</a></h3><div class="kr_blok_thumb"><a href="https://www.uitzendinggemist.net/aflevering/500734/Ik_Vertrek.html" title="Ik Vertrek - Milko En Mario In Portugal"><img src="https://images.poms.omroep.nl/image/s320/c320x180/1316596.jpg" alt="Ik Vertrek - Milko En Mario In Portugal" width="180" height="102"></a></div><p class="kr_blok_subtitle">Milko En Mario In Portugal</p><p class="kr_blok_desc">Mario (47) en Milko (54) wonen in een prachtig appartement in Amsterdam Oud-Zuid. De supermarkt is om de hoek, musea zijn op loopafstand en er is altijd leven op straat. Het ste ... </p><p class="kr_blok_date">03-01-2020</p><p class="kr_blok_host">TROS</p><p class="kr_blok_more"><a href="https://www.uitzendinggemist.net/programmas/328-Ik_Vertrek.html" title="Ik Vertrek Gemist">Alle afleveringen bekijken</a></p><p class="icon"><a href="https://www.uitzendinggemist.net/zenders/Nederland-2.html" title="Nederland 2"><img src="https://www.uitzendinggemist.net/images/nederland-2-xs.png" alt="Nederland 2" width="20" height="18" border="0"></a></p></div>

            #<div class="kr_blok_main" style="height: 270px;"><h3 class="kr_blok_title">Chateau Meiland </h3><div class="kr_blok_thumb"><a href="https://www.uitzendinggemist.net/programmas/59250-Chateau_Meiland.html"><img alt="Chateau Meiland " height="102" src="https://img.kijk.nl/media/cache/computer_retina_series_program_header/imgsrc06/images/redactioneel/1085720-LS---20190520112813--0e03ad5aaa47df615ea8e4d6f1204dbd.jpg" width="180"/></a></div><div class="kr_blok_desc">Martien en Erica gaan opnieuw het huwelijksbootje in</div><p class="icon"><a href="https://www.uitzendinggemist.net/zenders/SBS-6.html" title="SBS 6"><img alt="SBS 6" border="0" height="18" src="https://www.uitzendinggemist.net/images/sbs-6-xs.png" width="20"/></a></p></div>

            try:
                title_part1 = tv_show.a['title']
                log("tp1", title_part1)
                title_part2 = tv_show.img['alt']
                log("tp2", title_part2)
                title_part2 = convertToUnicodeString(title_part2)
                title_part2 = title_part2.replace(title_part1, '', 1)
                title_part2 = title_part2.replace(" -", "")
                title = title_part1 + ": " + title_part2
            except:
                try:
                    title = tv_show.select('h3')[0].get_text(strip=True)
                except:
                    title = ""

            if self.show_channel == "True":
                channel = tv_show.select('img')[1]["alt"]

                log("channel", channel)

                channel = str(channel).replace("Nederland", "NL ")

                title = channel + ": " + title

            log("title", title)

            try:
                # Get the text of the second p-tag
                plot = tv_show.select('p')[1].get_text(strip=True)
            except:
                try:
                    plot = tv_show.select('div')[1].get_text(strip=True)
                except:
                    plot = ""

            log("plot", plot)

            thumbnail_url = tv_show.img['src']

            log("thumbnail_url", thumbnail_url)

            log("title", title)

            context_menu_items = []
            # Add refresh option to context menu
            context_menu_items.append((LANGUAGE(30667), 'Container.Refresh'))

            # Add to list
            list_item = xbmcgui.ListItem(label=title)
            list_item.setInfo("video", {"title": title, "studio": ADDON})
            list_item.setArt({
                'thumb':
                thumbnail_url,
                'icon':
                thumbnail_url,
                'fanart':
                os.path.join(IMAGES_PATH, 'fanart-blur.jpg')
            })
            list_item.setProperty('IsPlayable', 'true')

            # let's remove any non-ascii characters
            title = title.encode('ascii', 'ignore')

            parameters = {
                "action": "list-episodes",
                "plugin_category": title,
                "url": video_page_url,
                "next_page_possible": "False",
                "show_channel": self.show_channel,
                "title": title
            }
            url = self.plugin_url + '?' + urllib.parse.urlencode(parameters)
            is_folder = True
            # Add refresh option to context menu
            list_item.addContextMenuItems([('Refresh', 'Container.Refresh')])
            # Add our item to the listing as a 3-element tuple.
            listing.append((url, list_item, is_folder))

        # # Next page entry
        # if self.next_page_possible == 'True':
        #     next_page = self.current_page + 1
        #     thumbnail_url = os.path.join(IMAGES_PATH, 'next-page.png')
        #     list_item = xbmcgui.ListItem(LANGUAGE(30503))
        #     list_item.setArt({'thumb': thumbnail_url, 'icon': thumbnail_url,
        #                       'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')})
        #     list_item.setProperty('IsPlayable', 'false')
        #     parameters = {"action": "list", "plugin_category": self.plugin_category, "url": str(self.next_url),
        #                   "next_page_possible": self.next_page_possible}
        #     url = self.plugin_url + '?' + urllib.parse.urlencode(parameters)
        #     is_folder = True
        #     # Add refresh option to context menu
        #     list_item.addContextMenuItems([('Refresh', 'Container.Refresh')])
        #     # Add our item to the listing as a 3-element tuple.
        #     listing.append((url, list_item, is_folder))

        # Add our listing to Kodi
        # Large lists and/or slower systems benefit from adding all items at once via addDirectoryItems
        # instead of adding one by ove via addDirectoryItem.
        xbmcplugin.addDirectoryItems(self.plugin_handle, listing, len(listing))
        # Disable sorting
        xbmcplugin.addSortMethod(handle=self.plugin_handle,
                                 sortMethod=xbmcplugin.SORT_METHOD_NONE)
        # Finish creating a virtual folder.
        xbmcplugin.endOfDirectory(self.plugin_handle)