def listOnDemandCategories(self, _handle, _url, category = False): apiUrl = "https://static3.mediasetplay.mediaset.it/cataloglisting/azListing.json" response = urllib2.urlopen(apiUrl) data = json.load(response) if category == False: list_item = xbmcgui.ListItem(label="Tutti i programmi") is_folder = True url = utils.get_url(_url, action='list', type='ondemand', category="Tutti i programmi") xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder) for m in data['metadata']['categories']: list_item = xbmcgui.ListItem(label=m) is_folder = True url = utils.get_url(_url, action='list', type='ondemand', category=m) xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder) else: search = category.replace('Tutti i programmi', 'nofilter') for m in data['data'][search]: list_item = xbmcgui.ListItem(label=m.upper()) is_folder = True url = utils.get_url(_url, action='list', type='ondemand', category=category, startswith=m) xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
def displayLiveChannelsList(self, _handle, _url): apiUrl = 'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-stations?bycallsign=&range=1-1000&fields=guid,title,callSign,thumbnails,mediasetstation$pageUrl' response = urllib2.urlopen(apiUrl) data = json.load(response) if 'entries' in data: for entry in data['entries']: if 'channel_logo-100x100' in entry['thumbnails']: icon = entry['thumbnails']['channel_logo-100x100']['url'] else: icon = 'DefaultVideo.png' list_item = xbmcgui.ListItem(label=entry['title']) list_item.setInfo('video', { 'title': entry['title'], }) list_item.setArt({'thumb': icon, 'icon': icon, 'fanart': icon}) list_item.setProperty('IsPlayable', 'true') is_folder = False url = utils.get_url(_url, action='play', type='live', callSign = entry['callSign']) xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder) # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_VIDEO_TITLE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
def getChannels(self, _url, channel_url, fetched_channels): response = urllib2.urlopen(channel_url) data = json.load(response) channels = [] if 'entries' in data: for entry in data['entries']: if any( d.get('title', None) == entry['title'] for d in fetched_channels): #fetched_channel = [item for item in fetched_channels if item.get('title', None) == entry['title']] fetched_channel = next( (x for x in fetched_channels if x.get('title', None) == entry['title']), None) if 'channel_logo-100x100' in entry['thumbnails']: icon = entry['thumbnails']['channel_logo-100x100'][ 'url'] else: icon = 'DefaultVideo.png' title = entry['title'] url = utils.get_url(_url, action='play', type='live', channel=self.__class__.__name__, callSign=entry['callSign']) epg = fetched_channel.get('epg', None) lcn = fetched_channel.get('lcn', None) channel = Channel(icon, title, url, lcn, epg) channels.append(channel) return channels
def listInfoVideos(self, _handle, _url): apiUrl = 'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs?byCustomValue={mediasetprogram$brandId}{640991|630990|620989|8252083|152488|591607|10412642|8212078|1192474}&byProgramType=episode&sort=mediasetprogram$publishInfo_lastPublished|desc&range=0-100' # To Fix SSL: CERTIFICATE_VERIFY_FAILED on Kodi 17.6 ssl._create_default_https_context = ssl._create_unverified_context response = urllib2.urlopen(apiUrl) data = json.load(response) for entry in data['entries']: entry['title'] = entry['mediasetprogram$brandTitle'].upper() + ' - ' + entry['title'] if not 'description' in entry: entry['description'] = '' else: soup = BeautifulSoup(entry['description'], "html.parser") entry['description'] = soup.text # get best thumbnail available thumbs = []; for thumb in entry['thumbnails']: if thumb.find('image_keyframe_poster-') != -1: thumb = thumb.replace('image_keyframe_poster-', '') thumbs.append(int(thumb.split('x')[0])) thumbs.sort(reverse=True) biggestThumb = '' if thumbs[0]: for thumb in entry['thumbnails']: if thumb.find('image_keyframe_poster-' + str(thumbs[0])) != -1 and 'url' in entry['thumbnails'][thumb]: biggestThumb = entry['thumbnails'][thumb]['url'] break if len(biggestThumb) < 1: iconimage = '' else: iconimage = biggestThumb liz = xbmcgui.ListItem(entry['title'], iconImage="DefaultVideo.png", thumbnailImage=iconimage) liz.setArt({'thumb': iconimage, 'icon': iconimage}) liz.setArt({'poster': iconimage}) liz.setArt({'fanart': iconimage}) liz.setProperty('IsPlayable', 'true') url = utils.get_url(_url, action='play',type="info", url=entry['media'][0]['publicUrl']) liz.setInfo(type="Video", infoLabels={"Title": entry['title'], "plot": entry['description'], "plotoutline": entry['description'], 'duration': entry['mediasetprogram$duration']}) xbmcplugin.addDirectoryItem(_handle, url, liz, isFolder=False) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
def listCultVideos(self, _handle, _url, _feedUrl): apiUrl = _feedUrl # LOAD JSON # To Fix SSL: CERTIFICATE_VERIFY_FAILED on Kodi 17.6 ssl._create_default_https_context = ssl._create_unverified_context response = urllib2.urlopen(apiUrl) data = json.load(response) for entry in data['entries']: # get best thumbnail available thumbs = []; for thumb in entry['thumbnails']: if thumb.find('image_keyframe_poster-') != -1: thumb = thumb.replace('image_keyframe_poster-', '') thumbs.append(int(thumb.split('x')[0])) thumbs.sort(reverse=True) biggestThumb = '' if thumbs[0]: for thumb in entry['thumbnails']: if thumb.find('image_keyframe_poster-' + str(thumbs[0])) != -1 and 'url' in entry['thumbnails'][thumb]: biggestThumb = entry['thumbnails'][thumb]['url'] break if len(biggestThumb) < 1: iconimage = '' else: iconimage = biggestThumb liz = xbmcgui.ListItem(entry['title'], iconImage="DefaultVideo.png", thumbnailImage=iconimage) liz.setArt({'thumb': iconimage, 'icon': iconimage}) liz.setArt({'poster': iconimage}) liz.setArt({'fanart': iconimage}) liz.setProperty('IsPlayable', 'true') url = utils.get_url(_url, action='play',type="cult", url=entry['media'][0]['publicUrl']) liz.setInfo(type="Video", infoLabels={"Title": entry['title'], "plot": entry['description'], "plotoutline": entry['description'], 'duration': entry['mediasetprogram$duration']}) xbmcplugin.addDirectoryItem(_handle, url, liz, isFolder=False) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
def getOnDemandProgramDetailsCategory(self, _handle, _url, brandId, subBrandId): apiUrl = 'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs?byCustomValue={brandId}{%brandId%},{subBrandId}{%subBrandId%}&sort=mediasetprogram$publishInfo_lastPublished|desc&count=true&entries=true&range=0-200'.replace('%brandId%', brandId).replace('%subBrandId%', subBrandId) # LOAD JSON # To Fix SSL: CERTIFICATE_VERIFY_FAILED on Kodi 17.6 ssl._create_default_https_context = ssl._create_unverified_context response = urllib2.urlopen(apiUrl) data = json.load(response) for entry in data['entries']: # get best thumbnail available thumbs = []; for thumb in entry['thumbnails']: if thumb.find('image_keyframe_poster-') != -1: thumb = thumb.replace('image_keyframe_poster-', '') thumbs.append(int(thumb.split('x')[0])) thumbs.sort(reverse=True) biggestThumb = '' if thumbs[0]: for thumb in entry['thumbnails']: if thumb.find('image_keyframe_poster-' + str(thumbs[0])) != -1 and 'url' in entry['thumbnails'][thumb]: biggestThumb = entry['thumbnails'][thumb]['url'] break if len(biggestThumb) < 1: iconimage = '' else: iconimage = biggestThumb liz = xbmcgui.ListItem(entry['title'], iconImage="DefaultVideo.png", thumbnailImage=iconimage) liz.setArt({'thumb': iconimage, 'icon': iconimage}) liz.setArt({'poster': iconimage}) liz.setArt({'fanart': iconimage}) liz.setProperty('IsPlayable', 'true') url = utils.get_url(_url, action='play',type="ondemand", url=entry['media'][0]['publicUrl']) liz.setInfo(type="Video", infoLabels={"Title": entry['title'], "plot": entry['description'], "plotoutline": entry['description'], 'duration': entry['mediasetprogram$duration']}) xbmcplugin.addDirectoryItem(_handle, url, liz, isFolder=False) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
def listCultCategories(self, _handle, _url): apiUrl = "https://api.one.accedo.tv/content/entries?id=5c0ff3961de1c4001a25b90a%2C5c13c4f41de1c4001911ef76%2C5c13bfb71de1c400198ea30f%2C5c175cbea0e845001ac6e06e%2C5c175dbc1de1c400198ea38a%2C5c175f3e23eec6001a23240c%2C5c175fb223eec6001a0433a6%2C5c175feb23eec6001a3a06ab%2C5c17603da0e845001ba8f300%2C5c17675b23eec6001a1e73b8&locale=it" sessionId = self.accedoApiKey() if sessionId == False: dialog = xbmcgui.Dialog() ok = dialog.ok('Errore!', 'Impossibile ottenere una chiave AccedoTv valida, contattare gli sviluppatori se il problema persiste') apiUrl = apiUrl + '&sessionKey=' + sessionId # LOAD JSON # To Fix SSL: CERTIFICATE_VERIFY_FAILED on Kodi 17.6 ssl._create_default_https_context = ssl._create_unverified_context response = urllib2.urlopen(apiUrl) data = json.load(response) if 'entries' in data: for entry in data['entries']: if 'title' not in entry: continue if 'brandDescription' in entry: soup = BeautifulSoup(entry['brandDescription'], "html.parser") entry['brandDescription'] = soup.text else: entry['brandDescription'] = '' entry['title'] = entry['title'].upper() list_item = xbmcgui.ListItem(label=entry['title']) list_item.setInfo('video', { 'title': entry['title'], 'plot': entry['brandDescription'] }) # list_item.setArt({'thumb': biggestThumb, 'icon': biggestThumb, 'fanart': biggestThumb}) is_folder = True url = utils.get_url(_url, action='list', type='cult', feedUrl = entry['feedurl']) xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder) # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_VIDEO_TITLE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
def getChannels(self, _url, channel_url, fetched_channels): channels = [] fetched_channel = next( (x for x in fetched_channels if x.get('title', None) == 'DMAX'), None) title = 'DMAX' icon = self.noThumbUrl url = utils.get_url(_url, action='play', type='live', channel=self.__class__.__name__, callSign=channel_url) epg = fetched_channel.get('epg', None) lcn = fetched_channel.get('lcn', None) channel = Channel(icon, title, url, lcn, epg) channels.append(channel) return channels
def getChannels(self, _url, channel_url, fetched_channels): data = json.load(urllib2.urlopen(channel_url)) channels = [] if 'streaming_url' in data: if any(d.get('title', None) == 'Cielo' for d in fetched_channels): fetched_channel = next((x for x in fetched_channels if x.get('title', None) == 'Cielo'), None) title = 'Cielo' url = utils.get_url(_url, action='play', type='live', channel=self.__class__.__name__, callSign=data["streaming_url"]) epg = fetched_channel.get('epg', None) lcn = fetched_channel.get('lcn', None) icon = fetched_channel.get('icon', None) channel = Channel(icon, title, url, lcn, epg) channels.append(channel) return channels
def getChannels(self, _url, channel_url, fetched_channels): data = json.load(urllib2.urlopen(channel_url)) channels = [] if 'dirette' in data: for entry in data['dirette']: if any( d.get('title', None) == entry['channel'] for d in fetched_channels): fetched_channel = next( (x for x in fetched_channels if x.get('title', None) == entry['channel']), None) icon = self.getThumbnailUrl(entry["transparent-icon"]) title = entry["channel"] url = utils.get_url(_url, action='play', type='live', channel=self.__class__.__name__, callSign=entry["video"]["contentUrl"]) epg = fetched_channel.get('epg', None) lcn = fetched_channel.get('lcn', None) channel = Channel(icon, title, url, lcn, epg) channels.append(channel) return channels
def getOnDemandProgramDetails(self, _handle, _url, brandId): apiUrl = 'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-brands?byCustomValue={brandId}{%brandId%}&sort=mediasetprogram$order'.replace('%brandId%', brandId) # LOAD JSON # To Fix SSL: CERTIFICATE_VERIFY_FAILED on Kodi 17.6 ssl._create_default_https_context = ssl._create_unverified_context response = urllib2.urlopen(apiUrl) data = json.load(response) for entry in data['entries']: if 'mediasetprogram$subBrandId' in entry: list_item = xbmcgui.ListItem(label=entry['description']) list_item.setInfo('video', { 'title': entry['description'] }) is_folder = True url = utils.get_url(_url, action='list', type='ondemand', brandId=entry['mediasetprogram$brandId'], subBrandId=entry['mediasetprogram$subBrandId']) xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
def listMostViewedVideos(self, _handle, _url): apiData = self.getApiData() apiUrl = "https://api-ott-prod-fe.mediaset.net/PROD/play/rec/cataloguelisting/v1.0?uxReference=CWTOPVIEWEDDAY&platform=pc&traceCid=%traceCid%&cwId=%cwId%".replace('%traceCid%', apiData['traceCid']).replace('%cwId%', apiData['cwId']) # To Fix SSL: CERTIFICATE_VERIFY_FAILED on Kodi 17.6 ssl._create_default_https_context = ssl._create_unverified_context headers = { 't-apigw': apiData['t-apigw'], 't-cts': apiData['t-cts'], 'Accept': 'application/json' } response = requests.get(apiUrl, False, headers=headers) data = json.loads(response.content) if 'isOk' in data and data['isOk']: for entry in data['response']['entries']: if not 'description' in entry: entry['description'] = '' else: soup = BeautifulSoup(entry['description'], "html.parser") entry['description'] = soup.text entry['title'] = entry['mediasetprogram$brandTitle'].upper() + ' - ' + entry['title'] # get best thumbnail available thumbs = []; for thumb in entry['thumbnails']: if thumb.find('image_keyframe_poster-') != -1: thumb = thumb.replace('image_keyframe_poster-', '') thumbs.append(int(thumb.split('x')[0])) thumbs.sort(reverse=True) biggestThumb = '' if thumbs[0]: for thumb in entry['thumbnails']: if thumb.find('image_keyframe_poster-' + str(thumbs[0])) != -1 and 'url' in entry['thumbnails'][thumb]: biggestThumb = entry['thumbnails'][thumb]['url'] break if len(biggestThumb) < 1: iconimage = '' else: iconimage = biggestThumb liz = xbmcgui.ListItem(entry['title'], iconImage="DefaultVideo.png", thumbnailImage=iconimage) liz.setArt({'thumb': iconimage, 'icon': iconimage}) liz.setArt({'poster': iconimage}) liz.setArt({'fanart': iconimage}) liz.setProperty('IsPlayable', 'true') url = utils.get_url(_url, action='play',type="most_viewed", url=entry['media'][0]['publicUrl']) liz.setInfo(type="Video", infoLabels={"Title": entry['title'], "plot": entry['description'], "plotoutline": entry['description'], 'duration': entry['mediasetprogram$duration']}) xbmcplugin.addDirectoryItem(_handle, url, liz, isFolder=False) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
def listOnDemandCatalogue(self, _handle, _url, category, startswith): if startswith == '0': startswith = '-(TitleFullSearch:%7BA%20TO%20*%7D)' else: startswith = 'TitleFullSearch:' + startswith.lower() + '*' apiUrl = "https://api-ott-prod-fe.mediaset.net/PROD/play/rec/azlisting/v1.0?query={startswith}&page=1&hitsPerPage=200".format(startswith=startswith) if category != 'Tutti i programmi': apiUrl = apiUrl + '&categories=' + category apiData = self.getApiData() headers = { 't-apigw': apiData['t-apigw'], 't-cts': apiData['t-cts'], 'Accept': 'application/json' } response = requests.get(apiUrl, False, headers=headers) data = json.loads(response.content) if 'isOk' in data and data['isOk']: for entry in data['response']['entries']: if not 'description' in entry: entry['description'] = '' else: soup = BeautifulSoup(entry['description'], "html.parser") entry['description'] = soup.text # get the best thumbnail available thumbs = []; for thumb in entry['thumbnails']: if thumb.find('brand_logo-') != -1: thumb = thumb.replace('brand_logo-', '') thumbs.append(int(thumb.split('x')[0])) thumbs.sort(reverse=True) biggestThumb = '' if len(thumbs) > 0: for thumb in entry['thumbnails']: if thumb.find('brand_logo-' + str(thumbs[0])) != -1 and 'url' in entry['thumbnails'][thumb]: biggestThumb = entry['thumbnails'][thumb]['url'] break list_item = xbmcgui.ListItem(label=entry['title']) list_item.setInfo('video', { 'title': entry['title'], 'plot': entry['description'] }) list_item.setArt({'thumb': biggestThumb, 'icon': biggestThumb, 'fanart': biggestThumb}) is_folder = True url = utils.get_url(_url, action='list', type='ondemand', category=category, brandId=entry['mediasetprogram$brandId']) xbmcplugin.addDirectoryItem(_handle, url, list_item, is_folder) # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_VIDEO_TITLE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)