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] # Try and get the title. # When starting a video with a browser (f.e. in chrome the 'send to kodi'-extension) the url will be # something like this: # plugin://plugin.video.dumpert/?action=play&video_page_url=http%3A%2F%2Fwww.dumpert.nl%2Fmediabase%2F7095997%2F1f72985c%2Fmevrouw_heeft_internetje_thuis.html # and there won't be a title available. try: self.title = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['title'][0] self.title = str(self.title) except KeyError: 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)) # Get search term from user keyboard = xbmc.Keyboard('', LANGUAGE(30508)) keyboard.doModal() if keyboard.isConfirmed(): search_term = keyboard.getText() sys.argv[2] = convertToUnicodeString(sys.argv[2]) # Converting URL argument to proper query string like 'http://www.dumpert.nl/search/ALL/fiets/1/' sys.argv[2] = sys.argv[2] + "/ALL/" + search_term + "/1/'" log("sys.argv[2]", sys.argv[2]) import dumpert_list as plugin plugin.Main()
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)) # Get search term from user keyboard = xbmc.Keyboard('', LANGUAGE(30508)) keyboard.doModal() if keyboard.isConfirmed(): search_term = keyboard.getText() sys.argv[2] = convertToUnicodeString(sys.argv[2]) # Converting URL argument to proper query string like 'http://legacy.dumpert.nl/search/ALL/fiets/1/' sys.argv[2] = sys.argv[2] + "/ALL/" + search_term + "/1/'" log("sys.argv[2]", sys.argv[2]) import dumpert_list as plugin plugin.Main()
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] # Try and get the title. # When starting a video with a browser (f.e. in chrome the 'send to kodi'-extension) the url will be # something like this: # plugin://plugin.video.dumpert/?action=play&video_page_url=http%3A%2F%2Flegacy.dumpert.nl%2Fmediabase%2F7095997%2F1f72985c%2Fmevrouw_heeft_internetje_thuis.html # and there won't be a title available. try: self.title = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['title'][0] self.title = str(self.title) except KeyError: 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]) # Get plugin settings self.VIDEO = SETTINGS.getSetting('video') log("ARGV", repr(sys.argv)) # Parse parameters... self.file = urllib.parse.parse_qs(urllib.parse.urlparse(sys.argv[2]).query)['file'][0] log("self.file",self.file) # # 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] log("self.video_list_page_url", self.video_list_page_url) # Determine base_url # http://www.dumpert.nl/ # 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 __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] except KeyError: self.plugin_category = LANGUAGE(30001) self.video_list_page_url = "http://legacy.dumpert.nl/1/" self.next_page_possible = "True" log("self.video_list_page_url", self.video_list_page_url) # Determine current page number and base_url # http://legacy.dumpert.nl/toppers/ # http://legacy.dumpert.nl/ # http://legacy.dumpert.nl/<thema>/ # 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 = 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 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] except KeyError: self.plugin_category = LANGUAGE(30001) self.video_list_page_url = "http://www.dumpert.nl/1/" self.next_page_possible = "True" log("self.video_list_page_url", self.video_list_page_url) # Determine current page number and base_url # http://www.dumpert.nl/toppers/ # http://www.dumpert.nl/ # http://www.dumpert.nl/<thema>/ # 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 = 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] log("self.video_list_page_url", self.video_list_page_url) # Determine base_url # http://legacy.dumpert.nl/ # 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 __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)) date = xbmcgui.Dialog().numeric(1, LANGUAGE(30509)) if not date is None: date = date.replace(' ', '') try: try: date = datetime.strptime(date, '%d/%m/%Y') except TypeError: date = datetime(*(time.strptime(date, '%d/%m/%Y')[0:6])) except ValueError: date = datetime.now() else: date = datetime.now() if date > datetime.now() or date < datetime(2006, 1, 1): date = datetime.now() #f.e. http://dumpert.nl/mobile_api/json/top5/dag/2016-03-20/0/ daytop = 'http://dumpert.nl/mobile_api/json/top5/%s/%s/0/' % ( 'dag', date.strftime('%Y-%m-%d')) weektop = 'http://dumpert.nl/mobile_api/json/top5/%s/%s%s/0/' % ( 'week', date.strftime('%Y'), date.isocalendar()[1]) monthtop = 'http://dumpert.nl/mobile_api/json/top5/%s/%s/0/' % ( 'maand', date.strftime('%Y%m')) title = LANGUAGE(30510) % date.strftime('%d %b %Y') # Next page is not available for top5 parameters = { "action": "json", "plugin_category": title, "url": daytop, "next_page_possible": "False" } url = self.plugin_url + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(title, iconImage="DefaultFolder.png") is_folder = True list_item.setArt( {'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') xbmcplugin.addDirectoryItem(handle=self.plugin_handle, url=url, listitem=list_item, isFolder=is_folder) title = LANGUAGE(30511) % date.strftime('%d %b %Y') # Next page is not available for top5 parameters = { "action": "json", "plugin_category": title, "url": weektop, "next_page_possible": "False" } url = self.plugin_url + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(title, iconImage="DefaultFolder.png") is_folder = True list_item.setArt( {'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') xbmcplugin.addDirectoryItem(handle=self.plugin_handle, url=url, listitem=list_item, isFolder=is_folder) title = LANGUAGE(30512) % date.strftime('%d %b %Y') # Next page is not available for top5 parameters = { "action": "json", "plugin_category": title, "url": monthtop, "next_page_possible": "False" } url = self.plugin_url + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(title, iconImage="DefaultFolder.png") is_folder = True list_item.setArt( {'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') xbmcplugin.addDirectoryItem(handle=self.plugin_handle, url=url, listitem=list_item, isFolder=is_folder) # Disable sorting xbmcplugin.addSortMethod(handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(self.plugin_handle)
def playVideo(self): # # Init # no_url_found = False unplayable_media_file = False have_valid_url = False # # 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")) # # Show wait dialog while parsing data... # dialog_wait = xbmcgui.DialogProgress() dialog_wait.create(LANGUAGE(30504), self.title) # wait 1 second xbmc.sleep(1000) try: if SETTINGS.getSetting('nsfw') == 'true': response = requests.get(self.video_page_url, cookies={'nsfw': '1'}) else: response = requests.get(self.video_page_url) html_source = response.text html_source = convertToUnicodeString(html_source) except urllib.error.HTTPError as error: log('HTTPError', error) dialog_wait.close() del dialog_wait xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30507) % (str(error))) exit(1) # Parse response soup = getSoup(html_source) video_url = '' # <div class="videoplayer" id="video1" data-files="eyJmbHYiOiJodHRwOlwvXC9tZWRpYS5kdW1wZXJ0Lm5sXC9mbHZcLzI4OTE2NWRhXzEwMjU1NzUyXzYzODMxODA4OTU1NDc2MV84MTk0MzU3MDVfbi5tcDQuZmx2IiwidGFibGV0IjoiaHR0cDpcL1wvbWVkaWEuZHVtcGVydC5ubFwvdGFibGV0XC8yODkxNjVkYV8xMDI1NTc1Ml82MzgzMTgwODk1NTQ3NjFfODE5NDM1NzA1X24ubXA0Lm1wNCIsIm1vYmlsZSI6Imh0dHA6XC9cL21lZGlhLmR1bXBlcnQubmxcL21vYmlsZVwvMjg5MTY1ZGFfMTAyNTU3NTJfNjM4MzE4MDg5NTU0NzYxXzgxOTQzNTcwNV9uLm1wNC5tcDQiLCJzdGlsbCI6Imh0dHA6XC9cL3N0YXRpYy5kdW1wZXJ0Lm5sXC9zdGlsbHNcLzY1OTM1MjRfMjg5MTY1ZGEuanBnIn0="></div></div> video_urls = soup.findAll('div', attrs={'class': re.compile("video")}, limit=1) if len(video_urls) == 0: # maybe it's a youtube url # <iframe class='yt-iframe' style='width: 100%' src='https://www.youtube.com/embed/9L0iOZmdS6s?showInfo=0&rel=0' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe> video_urls = soup.findAll('iframe', attrs={'src': re.compile("^http")}, limit=1) if len(video_urls) == 0: no_url_found = True else: url = video_urls[0]['src'] start_pos_youtube_id = str(url).rfind("/") + len("/") end_pos_youtube_id = str(url).find("?", start_pos_youtube_id) youtube_id = url[start_pos_youtube_id:end_pos_youtube_id] youtube_url = 'plugin://plugin.video.youtube/play/?video_id=%s' % youtube_id video_url = youtube_url have_valid_url = True log("video_url1", video_url) else: video_url_enc = video_urls[0]['data-files'] # base64 decode video_url_dec = convertToUnicodeString(base64.b64decode(video_url_enc)) # {"flv":"http:\/\/media.dumpert.nl\/flv\/5770e490_Jumbo_KOOP_DAN__Remix.avi.flv","tablet":"http:\/\/media.dumpert.nl\/tablet\/5770e490_Jumbo_KOOP_DAN__Remix.avi.mp4","mobile":"http:\/\/media.dumpert.nl\/mobile\/5770e490_Jumbo_KOOP_DAN__Remix.avi.mp4","720p":"http:\/\/media.dumpert.nl\/720p\/5770e490_Jumbo_KOOP_DAN__Remix.avi.mp4","still":"http:\/\/static.dumpert.nl\/stills\/6593503_5770e490.jpg"} # or # {"embed":"youtube:U89fl5fZETE","still":"http:\/\/static.dumpert.nl\/stills\/6650228_24eed546.jpg"} log("video_url_dec", video_url_dec) # convert string to dictionary video_url_dec_dict = ast.literal_eval(video_url_dec) try: video_url_stream = convertToUnicodeString(video_url_dec_dict['stream']) stream_found = True except KeyError: stream_found = False if stream_found: video_url = video_url_stream video_url = video_url.replace('\/', '/') have_valid_url = True log("video_url2", video_url) else: try: video_url_embed = convertToUnicodeString(video_url_dec_dict['embed']) embed_found = True except KeyError: embed_found = False if embed_found: # make youtube plugin url youtube_id = video_url_embed.replace("youtube:", "") youtube_url = 'plugin://plugin.video.youtube/play/?video_id=%s' % youtube_id video_url = youtube_url have_valid_url = True log("video_url3", video_url) else: # matching the desired and available quality if self.VIDEO == '0': try: video_url = str(video_url_dec_dict['mobile']) except KeyError: no_url_found = True elif self.VIDEO == '1': try: video_url = str(video_url_dec_dict['tablet']) except KeyError: try: video_url = str(video_url_dec_dict['mobile']) except KeyError: no_url_found = True elif self.VIDEO == '2': try: video_url = str(video_url_dec_dict['720p']) except KeyError: try: video_url = str(video_url_dec_dict['tablet']) except KeyError: try: video_url = str(video_url_dec_dict['mobile']) except KeyError: no_url_found = True if no_url_found: pass else: video_url = video_url.replace('\/', '/') log("video_url4", video_url) # The need for speed: let's guess that the video-url exists have_valid_url = True # Play video... 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))
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)) date = xbmcgui.Dialog().numeric(1, LANGUAGE(30509)) if not date is None: date = date.replace(' ', '') try: try: date = datetime.strptime(date, '%d/%m/%Y') except TypeError: date = datetime(*(time.strptime(date, '%d/%m/%Y')[0:6])) except ValueError: date = datetime.now() else: date = datetime.now() if date > datetime.now() or date < datetime(2006, 1, 1): date = datetime.now() #f.e. http://dumpert.nl/mobile_api/json/top5/dag/2016-03-20/0/ daytop = 'http://dumpert.nl/mobile_api/json/top5/%s/%s/0/' % ('dag', date.strftime('%Y-%m-%d')) weektop = 'http://dumpert.nl/mobile_api/json/top5/%s/%s%s/0/' % ( 'week', date.strftime('%Y'), date.isocalendar()[1]) monthtop = 'http://dumpert.nl/mobile_api/json/top5/%s/%s/0/' % ('maand', date.strftime('%Y%m')) title = LANGUAGE(30510) % date.strftime('%d %b %Y') # Next page is not available for top5 parameters = {"action": "json", "plugin_category": title, "url": daytop, "next_page_possible": "False"} url = self.plugin_url + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(title, iconImage="DefaultFolder.png") is_folder = True list_item.setArt({'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') xbmcplugin.addDirectoryItem(handle=self.plugin_handle, url=url, listitem=list_item, isFolder=is_folder) title = LANGUAGE(30511) % date.strftime('%d %b %Y') # Next page is not available for top5 parameters = {"action": "json", "plugin_category": title, "url": weektop, "next_page_possible": "False"} url = self.plugin_url + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(title, iconImage="DefaultFolder.png") is_folder = True list_item.setArt({'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') xbmcplugin.addDirectoryItem(handle=self.plugin_handle, url=url, listitem=list_item, isFolder=is_folder) title = LANGUAGE(30512) % date.strftime('%d %b %Y') # Next page is not available for top5 parameters = {"action": "json", "plugin_category": title, "url": monthtop, "next_page_possible": "False"} url = self.plugin_url + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(title, iconImage="DefaultFolder.png") is_folder = True list_item.setArt({'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') xbmcplugin.addDirectoryItem(handle=self.plugin_handle, url=url, listitem=list_item, isFolder=is_folder) # 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 # thumbnail_urls_index = 0 # # Get HTML page... # if SETTINGS.getSetting('nsfw') == 'true': response = requests.get(self.video_list_page_url, cookies={'nsfw': '1'}) else: response = requests.get(self.video_list_page_url) html_source = response.text html_source = convertToUnicodeString(html_source) # Parse response soup = getSoup(html_source) # <img src="http://static.dumpert.nl/s/trailerts_gr.jpg" alt="" /> thumbnail_urls = soup.findAll( 'img', attrs={'src': re.compile("^http://static.dumpert.nl/")}) log("len(thumbnail_urls)", len(thumbnail_urls)) # <a href="/themas/uit_het_archief/" class="themalink big"> # <a href="/themas/liev/" class="themalink"> video_page_urls = soup.findAll( 'a', attrs={'class': re.compile("^themalink")}) log("len(video_page_urls)", len(video_page_urls)) for video_page_url in video_page_urls: video_page_url = video_page_url['href'] # remove '/themas/' video_page_url = video_page_url.replace('/themas/', '') # http://legacy.dumpert.nl/<thema>/ theme_base_url = str(self.base_url) + str(video_page_url) current_page = 1 log("theme_base_url", theme_base_url) # Make title # http://static.dumpert.nl/themas/politiek_kl.jpg title = str(video_page_url) pos_of_last_slash = title.rfind('/') # remove last slash title = title[0:pos_of_last_slash] pos_of_last_slash = title.rfind('/') title = title[pos_of_last_slash + 1:] title = title.capitalize() title = title.replace('-', ' ') title = title.replace('/', ' ') title = title.replace('_kl', '') title = title.replace('_', ' ') log("title", title) if thumbnail_urls_index >= len(thumbnail_urls): thumbnail_url = '' else: thumbnail_url = thumbnail_urls[thumbnail_urls_index]['src'] # let's remove any non-ascii characters from the title, to prevent errors with urllib.parse.parse_qs of the parameters title = title.encode('ascii', 'ignore') # Add to list... parameters = { "action": "list", "plugin_category": self.plugin_category, "url": str(theme_base_url) + str(current_page) + '/', "next_page_possible": "True", "title": title } url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(title, thumbnailImage=thumbnail_url) list_item.setInfo("video", {"Title": title, "Studio": "Dumpert"}) list_item.setArt({ 'thumb': thumbnail_url, 'icon': thumbnail_url, 'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg') }) list_item.setProperty('IsPlayable', 'false') is_folder = True # Add refresh option to context menu list_item.addContextMenuItems([('Refresh', 'Container.Refresh')]) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=list_item, isFolder=is_folder) thumbnail_urls_index = thumbnail_urls_index + 1 # Next page entry... if self.next_page_possible == 'True': next_page = current_page + 1 parameters = { "action": "list", "plugin_category": self.plugin_category, "url": str(theme_base_url) + str(next_page) + '/', "next_page_possible": self.next_page_possible } url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(LANGUAGE(30503), thumbnailImage=os.path.join( IMAGES_PATH, 'next-page.png')) list_item.setArt( {'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') is_folder = True # Add refresh option to context menu list_item.addContextMenuItems([('Refresh', 'Container.Refresh')]) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=list_item, isFolder=is_folder) log("next url", url) # Sort on labels... xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL) # End of directory... xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
def getVideos(self): # # Init # shownsfw = (SETTINGS.getSetting('nsfw') == 'true') listing = [] # # Get HTML page # response = requests.get(self.video_list_page_url) # response.status json_source = response.text json_source = convertToUnicodeString(json_source) data = json.loads(json_source) if not data['success']: xbmcplugin.endOfDirectory(self.plugin_handle) return for item in data['items']: title = item['title'] description = item['description'] thumbnail_url = item['stills']['still-large'] for i in item['media']: duration = i.get('duration', False) nsfw = item['nsfw'] if not nsfw or shownsfw: # {"id":"6737324_36df9881","title":"Hardcore brei-oma","thumbnail":"http:\/\/media.dumpert.nl\/sq_thumbs\/6737324_36df9881.jpg", # "still":"http:\/\/media.dumpert.nl\/stills\/6737324_36df9881.jpg","description":"Heeft vroeger wat uitgevroten... WTF?","date":"2016-03-18T19:35:56+01:00", # "tags":"dwdd oma wtf breien oud","nsfw":false,"nopreroll":false,"stats":{"views_total":466917,"views_today":32706,"kudos_total":4916,"kudos_today":343}, # "stills":{"thumb":"http:\/\/media.dumpert.nl\/sq_thumbs\/6737324_36df9881.jpg","thumb-medium":"http:\/\/media.dumpert.nl\/sq_thumbs\/medium\/6737324_36df9881.jpg", # "still":"http:\/\/media.dumpert.nl\/stills\/6737324_36df9881.jpg","still-medium":"http:\/\/media.dumpert.nl\/stills\/medium\/6737324_36df9881.jpg", # "still-large":"http:\/\/media.dumpert.nl\/stills\/large\/6737324_36df9881.jpg"},"media":[{"description":"","mediatype":"VIDEO","duration":55, # "variants":[{"version":"tablet","uri":"http:\/\/media.dumpert.nl\/tablet\/36df9881_VID_20160318_WA0000.mp4.mp4.mp4"},{"version":"mobile", # "uri":"http:\/\/media.dumpert.nl\/mobile\/36df9881_VID_20160318_WA0000.mp4.mp4.mp4"}]}]} # # grab first item (tablet) # skip embedded (youtube links) for now {"version":"embed","uri":"youtube:wOeZB7bnoxw"} if item['media'][0]['mediatype'] == 'VIDEO' and item['media'][ 0]['variants'][0]['version'] != 'embed': file = item['media'][0]['variants'][0]['uri'] log("json file", file) list_item = xbmcgui.ListItem(label=title, thumbnailImage=thumbnail_url) list_item.setInfo( "video", { "title": title, "studio": "Dumpert", "mediatype": "video", "plot": description }) list_item.setArt({ 'thumb': thumbnail_url, 'icon': thumbnail_url, 'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg') }) list_item.setProperty('IsPlayable', 'true') parameters = {"action": "play-file", "file": file} 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 list_item = xbmcgui.ListItem(LANGUAGE(30503), thumbnailImage=os.path.join( IMAGES_PATH, 'next-page.png')) list_item.setArt( {'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') parameters = { "action": "json", "plugin_category": self.plugin_category, "url": str(self.base_url) + str(next_page) + '/', "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 one 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 # titles_and_thumbnail_urls_index = 0 # Create a list for our items. listing = [] # # Get HTML page # if SETTINGS.getSetting('nsfw') == 'true': response = requests.get(self.video_list_page_url, cookies={'nsfw': '1'}) else: response = requests.get(self.video_list_page_url) html_source = response.text html_source = convertToUnicodeString(html_source) # Parse response soup = getSoup(html_source) # Find titles and thumnail-urls # img src="http://static.dumpert.nl/sq_thumbs/2245331_272bd4c3.jpg" alt="Turnlulz" title="Turnlulz" width="100" height="100" /> # titles_and_thumbnail_urls = soup.findAll('img', attrs={'src': re.compile("^http://static.dumpert.nl/")} ) titles_and_thumbnail_urls = soup.findAll( 'img', attrs={'src': re.compile("thumb")}) log("titles_and_thumbnail_urls", titles_and_thumbnail_urls) # Find video page urls # <a href="http://legacy.dumpert.nl/mediabase/2245331/272bd4c3/turnlulz.html" class="dumpthumb" title="Turnlulz"> video_page_urls = soup.findAll( 'a', attrs={'class': re.compile("dumpthumb")}) log("len(video_page_urls)", len(video_page_urls)) # in thema pages the first thumbnail is a thumbnail of the thema itself and not of a video # if that's the case: skip the first thumbnail if len(titles_and_thumbnail_urls) == len(video_page_urls) + 1: titles_and_thumbnail_urls_index = titles_and_thumbnail_urls_index + 1 for video_page_url in video_page_urls: pos_of_video_tag = str(video_page_url).find('class="video"') if pos_of_video_tag >= 0: pass else: # skip video page url without a video log("skipped video_page_url without video", video_page_url) titles_and_thumbnail_urls_index = titles_and_thumbnail_urls_index + 1 continue video_page_url = video_page_url['href'] log("video_page_url", video_page_url) # if link doesn't contain 'html': skip the link ('continue') if video_page_url.find('html') >= 0: pass else: log("skipped video_page_url without html", video_page_url) titles_and_thumbnail_urls_index = titles_and_thumbnail_urls_index + 1 continue description = '...' #<a href="http://legacy.dumpert.nl/mediabase/6721593/46f416fa/stukje_snowboarden.html?thema=bikini" class="dumpthumb" title="Stukje snowboarden"> # <img src="http://media.dumpert.nl/sq_thumbs/6721593_46f416fa.jpg" alt="Stukje snowboarden" title="Stukje snowboarden" width="100" height="100" /> # <span class="video"></span> # <div class="details"> # <h1>Stukje snowboarden</h1> # <date>5 februari 2016 10:32</date> # <p class="stats">views: 63687 kudos: 313</p> # <p class="description">F**k winterkleding </p> # </div> #</a> try: description = titles_and_thumbnail_urls[ titles_and_thumbnail_urls_index].parent.find( "p", "description").string except: pass # Make title try: title = titles_and_thumbnail_urls[ titles_and_thumbnail_urls_index]['title'] # <a href="http://legacy.dumpert.nl/mediabase/1958831/21e6267f/pixar_s_up_inspreken.html?thema=animatie" class="dumpthumb" title="Pixar's "Up" inspreken "> except KeyError: # http://legacy.dumpert.nl/mediabase/6532392/82471b66/dumpert_heeft_talent.html title = str(video_page_url) pos_last_slash = title.rfind('/') pos_last_dot = title.rfind('.') title = title[pos_last_slash + 1:pos_last_dot] title = title.capitalize() except UnicodeDecodeError: pass title = title.replace('-', ' ') title = title.replace('/', ' ') title = title.replace('_', ' ') log("title", title) if titles_and_thumbnail_urls_index >= len( titles_and_thumbnail_urls): thumbnail_url = '' else: thumbnail_url = titles_and_thumbnail_urls[ titles_and_thumbnail_urls_index]['src'].replace( "sq_thumbs", "stills/large") list_item = xbmcgui.ListItem(label=title, thumbnailImage=thumbnail_url) list_item.setInfo( "video", { "title": title, "studio": "Dumpert", "mediatype": "video", "plot": description }) 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 from the title, to prevent errors with urllib.parse.parse_qs of the parameters title = title.encode('ascii', 'ignore') parameters = { "action": "play", "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)) titles_and_thumbnail_urls_index = titles_and_thumbnail_urls_index + 1 # Next page entry if self.next_page_possible == 'True': next_page = self.current_page + 1 list_item = xbmcgui.ListItem(LANGUAGE(30503), thumbnailImage=os.path.join( IMAGES_PATH, 'next-page.png')) list_item.setArt( {'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.base_url) + str(next_page) + '/', "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 # thumbnail_urls_index = 0 # # Get HTML page... # if SETTINGS.getSetting('nsfw') == 'true': response = requests.get(self.video_list_page_url, cookies={'nsfw': '1'}) else: response = requests.get(self.video_list_page_url) html_source = response.text html_source = convertToUnicodeString(html_source) # Parse response soup = getSoup(html_source) # <img src="http://static.dumpert.nl/s/trailerts_gr.jpg" alt="" /> thumbnail_urls = soup.findAll('img', attrs={'src': re.compile("^http://static.dumpert.nl/")}) log("len(thumbnail_urls)", len(thumbnail_urls)) # <a href="/themas/uit_het_archief/" class="themalink big"> # <a href="/themas/liev/" class="themalink"> video_page_urls = soup.findAll('a', attrs={'class': re.compile("^themalink")}) log("len(video_page_urls)", len(video_page_urls)) for video_page_url in video_page_urls: video_page_url = video_page_url['href'] # remove '/themas/' video_page_url = video_page_url.replace('/themas/', '') # http://www.dumpert.nl/<thema>/ theme_base_url = str(self.base_url) + str(video_page_url) current_page = 1 log("theme_base_url", theme_base_url) # Make title # http://static.dumpert.nl/themas/politiek_kl.jpg title = str(video_page_url) pos_of_last_slash = title.rfind('/') # remove last slash title = title[0: pos_of_last_slash] pos_of_last_slash = title.rfind('/') title = title[pos_of_last_slash + 1:] title = title.capitalize() title = title.replace('-', ' ') title = title.replace('/', ' ') title = title.replace('_kl', '') title = title.replace('_', ' ') log("title", title) if thumbnail_urls_index >= len(thumbnail_urls): thumbnail_url = '' else: thumbnail_url = thumbnail_urls[thumbnail_urls_index]['src'] # let's remove any non-ascii characters from the title, to prevent errors with urllib.parse.parse_qs of the parameters title = title.encode('ascii', 'ignore') # Add to list... parameters = {"action": "list", "plugin_category": self.plugin_category, "url": str(theme_base_url) + str(current_page) + '/', "next_page_possible": "True", "title": title} url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(title, thumbnailImage=thumbnail_url) list_item.setInfo("video", {"Title": title, "Studio": "Dumpert"}) list_item.setArt({'thumb': thumbnail_url, 'icon': thumbnail_url, 'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') is_folder = True # Add refresh option to context menu list_item.addContextMenuItems([('Refresh', 'Container.Refresh')]) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=list_item, isFolder=is_folder) thumbnail_urls_index = thumbnail_urls_index + 1 # Next page entry... if self.next_page_possible == 'True': next_page = current_page + 1 parameters = {"action": "list", "plugin_category": self.plugin_category, "url": str(theme_base_url) + str(next_page) + '/', "next_page_possible": self.next_page_possible} url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters) list_item = xbmcgui.ListItem(LANGUAGE(30503), thumbnailImage=os.path.join(IMAGES_PATH, 'next-page.png')) list_item.setArt({'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') is_folder = True # Add refresh option to context menu list_item.addContextMenuItems([('Refresh', 'Container.Refresh')]) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=list_item, isFolder=is_folder) log("next url", url) # Sort on labels... xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_LABEL) # End of directory... xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
def getVideos(self): # # Init # shownsfw = (SETTINGS.getSetting('nsfw') == 'true') listing = [] # # Get HTML page # response = requests.get(self.video_list_page_url) # response.status json_source = response.text json_source = convertToUnicodeString(json_source) data = json.loads(json_source) if not data['success']: xbmcplugin.endOfDirectory(self.plugin_handle) return for item in data['items']: title = item['title'] description = item['description'] thumbnail_url = item['stills']['still-large'] for i in item['media']: duration = i.get('duration',False) nsfw = item['nsfw'] if not nsfw or shownsfw: # {"id":"6737324_36df9881","title":"Hardcore brei-oma","thumbnail":"http:\/\/media.dumpert.nl\/sq_thumbs\/6737324_36df9881.jpg", # "still":"http:\/\/media.dumpert.nl\/stills\/6737324_36df9881.jpg","description":"Heeft vroeger wat uitgevroten... WTF?","date":"2016-03-18T19:35:56+01:00", # "tags":"dwdd oma wtf breien oud","nsfw":false,"nopreroll":false,"stats":{"views_total":466917,"views_today":32706,"kudos_total":4916,"kudos_today":343}, # "stills":{"thumb":"http:\/\/media.dumpert.nl\/sq_thumbs\/6737324_36df9881.jpg","thumb-medium":"http:\/\/media.dumpert.nl\/sq_thumbs\/medium\/6737324_36df9881.jpg", # "still":"http:\/\/media.dumpert.nl\/stills\/6737324_36df9881.jpg","still-medium":"http:\/\/media.dumpert.nl\/stills\/medium\/6737324_36df9881.jpg", # "still-large":"http:\/\/media.dumpert.nl\/stills\/large\/6737324_36df9881.jpg"},"media":[{"description":"","mediatype":"VIDEO","duration":55, # "variants":[{"version":"tablet","uri":"http:\/\/media.dumpert.nl\/tablet\/36df9881_VID_20160318_WA0000.mp4.mp4.mp4"},{"version":"mobile", # "uri":"http:\/\/media.dumpert.nl\/mobile\/36df9881_VID_20160318_WA0000.mp4.mp4.mp4"}]}]} # # grab first item (tablet) # skip embedded (youtube links) for now {"version":"embed","uri":"youtube:wOeZB7bnoxw"} if item['media'][0]['mediatype'] == 'VIDEO' and item['media'][0]['variants'][0]['version'] != 'embed': file = item['media'][0]['variants'][0]['uri'] log("json file", file) list_item = xbmcgui.ListItem(label=title, thumbnailImage=thumbnail_url) list_item.setInfo("video", {"title": title, "studio": "Dumpert", "mediatype": "video", "plot": description}) list_item.setArt({'thumb': thumbnail_url, 'icon': thumbnail_url, 'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'true') parameters = {"action": "play-file", "file": file} 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 list_item = xbmcgui.ListItem(LANGUAGE(30503), thumbnailImage=os.path.join(IMAGES_PATH, 'next-page.png')) list_item.setArt({'fanart': os.path.join(IMAGES_PATH, 'fanart-blur.jpg')}) list_item.setProperty('IsPlayable', 'false') parameters = {"action": "json", "plugin_category": self.plugin_category, "url": str(self.base_url) + str(next_page) + '/', "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 one 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 # titles_and_thumbnail_urls_index = 0 # Create a list for our items. listing = [] # # Get HTML page # if SETTINGS.getSetting('nsfw') == 'true': response = requests.get(self.video_list_page_url, cookies={'nsfw': '1'}) else: response = requests.get(self.video_list_page_url) html_source = response.text html_source = convertToUnicodeString(html_source) # Parse response soup = getSoup(html_source) # Find titles and thumnail-urls # img src="http://static.dumpert.nl/sq_thumbs/2245331_272bd4c3.jpg" alt="Turnlulz" title="Turnlulz" width="100" height="100" /> # titles_and_thumbnail_urls = soup.findAll('img', attrs={'src': re.compile("^http://static.dumpert.nl/")} ) titles_and_thumbnail_urls = soup.findAll('img', attrs={'src': re.compile("thumb")}) log("titles_and_thumbnail_urls", titles_and_thumbnail_urls) # Find video page urls # <a href="http://www.dumpert.nl/mediabase/2245331/272bd4c3/turnlulz.html" class="dumpthumb" title="Turnlulz"> video_page_urls = soup.findAll('a', attrs={'class': re.compile("dumpthumb")}) log("len(video_page_urls)", len(video_page_urls)) # in thema pages the first thumbnail is a thumbnail of the thema itself and not of a video # if that's the case: skip the first thumbnail if len(titles_and_thumbnail_urls) == len(video_page_urls) + 1: titles_and_thumbnail_urls_index = titles_and_thumbnail_urls_index + 1 for video_page_url in video_page_urls: pos_of_video_tag = str(video_page_url).find('class="video"') if pos_of_video_tag >= 0: pass else: # skip video page url without a video log("skipped video_page_url without video", video_page_url) titles_and_thumbnail_urls_index = titles_and_thumbnail_urls_index + 1 continue video_page_url = video_page_url['href'] log("video_page_url", video_page_url) # if link doesn't contain 'html': skip the link ('continue') if video_page_url.find('html') >= 0: pass else: log("skipped video_page_url without html", video_page_url) titles_and_thumbnail_urls_index = titles_and_thumbnail_urls_index + 1 continue description = '...' #<a href="http://www.dumpert.nl/mediabase/6721593/46f416fa/stukje_snowboarden.html?thema=bikini" class="dumpthumb" title="Stukje snowboarden"> # <img src="http://media.dumpert.nl/sq_thumbs/6721593_46f416fa.jpg" alt="Stukje snowboarden" title="Stukje snowboarden" width="100" height="100" /> # <span class="video"></span> # <div class="details"> # <h1>Stukje snowboarden</h1> # <date>5 februari 2016 10:32</date> # <p class="stats">views: 63687 kudos: 313</p> # <p class="description">F**k winterkleding </p> # </div> #</a> try: description = titles_and_thumbnail_urls[titles_and_thumbnail_urls_index].parent.find("p","description").string except: pass # Make title try: title = titles_and_thumbnail_urls[titles_and_thumbnail_urls_index]['title'] # <a href="http://www.dumpert.nl/mediabase/1958831/21e6267f/pixar_s_up_inspreken.html?thema=animatie" class="dumpthumb" title="Pixar's "Up" inspreken "> except KeyError: # http://www.dumpert.nl/mediabase/6532392/82471b66/dumpert_heeft_talent.html title = str(video_page_url) pos_last_slash = title.rfind('/') pos_last_dot = title.rfind('.') title = title[pos_last_slash + 1:pos_last_dot] title = title.capitalize() except UnicodeDecodeError: pass title = title.replace('-', ' ') title = title.replace('/', ' ') title = title.replace('_', ' ') log("title", title) if titles_and_thumbnail_urls_index >= len(titles_and_thumbnail_urls): thumbnail_url = '' else: thumbnail_url = titles_and_thumbnail_urls[titles_and_thumbnail_urls_index]['src'].replace("sq_thumbs","stills/large") list_item = xbmcgui.ListItem(label=title, thumbnailImage=thumbnail_url) list_item.setInfo("video", {"title": title, "studio": "Dumpert", "mediatype": "video", "plot": description}) 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 from the title, to prevent errors with urllib.parse.parse_qs of the parameters title = title.encode('ascii', 'ignore') parameters = {"action": "play", "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)) titles_and_thumbnail_urls_index = titles_and_thumbnail_urls_index + 1 # Next page entry if self.next_page_possible == 'True': next_page = self.current_page + 1 list_item = xbmcgui.ListItem(LANGUAGE(30503), thumbnailImage=os.path.join(IMAGES_PATH, 'next-page.png')) list_item.setArt({'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.base_url) + str(next_page) + '/', "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)