def get_videos(self, url): import scraper_vod as scraper videos, next_page = cache.get(scraper.get_videos, 1, url) sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) for video in videos: meta = video sysmeta = urllib.quote_plus(json.dumps(meta)) isFolder = False brplayprovider = 'globosat' #'sexyhot' id_sexyhot = video['id_sexyhot'] title = video['title'] action_url = '%s?action=playvod&provider=%s&id_globo_videos=%s&isFolder=%s&meta=%s' % ( sysaddon, brplayprovider, id_sexyhot, isFolder, sysmeta) item = control.item(label=title) art = { 'poster': video['poster'], 'fanart': video['fanart'], 'thumb': video['thumb'], } item.setArt(art) item.setProperty('IsPlayable', 'true') item.setInfo(type='video', infoLabels=control.filter_info_labels(meta)) control.addItem(handle=syshandle, url=action_url, listitem=item, isFolder=isFolder) if next_page: action_url = '%s?action=getVideos&provider=sexyhot&page=%s' % (sysaddon, next_page) title = 'Page ' + str(next_page) item = control.item(label=title) art = { 'logo': os.path.join(artPath, 'logo_sexyhot.png'), 'thumb': NEXT_ICON, 'fanart': os.path.join(artPath, 'fanart_sexyhot.png'), } item.setArt(art) item.setProperty('IsPlayable', 'false') item.setInfo(type='video', infoLabels={'title': title}) control.addItem(handle=syshandle, url=action_url, listitem=item, isFolder=True) # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_LABEL_IGNORE_FOLDERS) control.content(syshandle, 'videos') control.directory(syshandle, cacheToDisc=False)
def playlive(self, id, meta): meta = meta or {} control.log("Oi Play - play_stream: id=%s | meta=%s" % (id, meta)) if id is None: return provider = meta.get('provider') self.isLive = meta.get('livefeed', False) data = self.individualize(self.isLive, id, provider) if not data or 'individualization' not in data: error_message = '%s: %s' % ( data.get('reason'), data.get('detail')) if data and data.get( 'reason') else control.lang(34100).encode('utf-8') control.infoDialog(error_message, icon='ERROR') return encrypted = 'drm' in data and 'licenseUrl' in data['drm'] if encrypted and not control.is_inputstream_available(): control.okDialog(u'Oi Play', control.lang(34103).encode('utf-8')) return url = data['individualization']['url'] # info = data.get('token', {}).get('cmsChannelItem') or data.get('token', {}).get('cmsContentItem') control.log("live media url: %s" % url) self.offset = float(meta['milliseconds_watched'] ) / 1000.0 if 'milliseconds_watched' in meta else 0 parsed_url = urlparse(url) if ".m3u8" in parsed_url.path: self.url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth( url) else: self.url = url mime_type, stopEvent, cookies = 'video/mp4', None, None if self.url is None: if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return control.log("Resolved URL: %s" % repr(self.url)) control.log("Parsed URL: %s" % repr(parsed_url)) if control.supports_offscreen: item = control.item(path=self.url, offscreen=True) else: item = control.item(path=self.url) item.setArt(meta.get('art', {})) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) if ".mpd" in parsed_url.path: mime_type = 'application/dash+xml' item.setProperty('inputstream.adaptive.manifest_type', 'mpd') if self.isLive: item.setProperty( 'inputstream.adaptive.manifest_update_parameter', 'full') else: item.setProperty('inputstream.adaptive.manifest_type', 'hls') if encrypted: control.log("DRM: com.widevine.alpha") # licence_url = data['drm']['licenseUrl'] + '&token=' + data['drm']['jwtToken'] if data.get('drm', {}).get('jwtToken'): licence_url = '%s&token=%s' % (data.get( 'drm', {}).get('licenseUrl'), data.get('drm', {}).get('jwtToken')) else: licence_url = data.get('drm', {}).get('licenseUrl') item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') item.setProperty('inputstream.adaptive.license_key', licence_url + "||R{SSM}|") if mime_type: item.setMimeType(mime_type) control.log("MIME TYPE: %s" % repr(mime_type)) if not cookies and control.is_inputstream_available(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') # if 'subtitles' in info and info['subtitles'] and len(info['subtitles']) > 0: # control.log("FOUND SUBTITLES: %s" % repr([sub['url'] for sub in info['subtitles']])) # item.setSubtitles([sub['url'] for sub in info['subtitles']]) control.resolve(int(sys.argv[1]), True, item) self.stopPlayingEvent = threading.Event() self.stopPlayingEvent.clear() first_run = True # last_time = 0.0 while not self.stopPlayingEvent.isSet(): if control.monitor.abortRequested(): control.log("Abort requested") break if self.isPlaying(): if first_run: self.showSubtitles(False) first_run = False # if not self.isLive: # current_time = self.getTime() # if current_time - last_time > 5 or (last_time == 0 and current_time > 1): # last_time = current_time # self.save_video_progress(self.token, self.video_id, current_time) control.sleep(1000) if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.log("Done playing. Quitting...")
def channel_directory(self, items): if items is None or len(items) == 0: control.idle() sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) try: isOld = False control.item().getArt('type') except: isOld = True refreshMenu = control.lang(32072).encode('utf-8') list_items = [] for order, channel in enumerate(items): label = channel['name'] meta = channel meta.update({'mediatype': channel['mediatype'] if 'mediatype' in channel else 'tvshow'}) # string - "video", "movie", "tvshow", "season", "episode" or "musicvideo" meta.update({'playcount': 0, 'overlay': 6}) meta.update({'duration': channel['duration']}) if 'duration' in channel else None meta.update({'title': channel['title']}) if 'title' in channel else None meta.update({'tagline': channel['tagline']}) if 'tagline' in channel else None meta.update({'year': channel['year']}) if 'year' in channel else None meta.update({'sorttitle': meta['title']}) meta.update({'title': meta['name']}) sysmeta = urllib.quote_plus(json.dumps(meta)) id_globo_videos = channel['id'] brplayprovider = channel['brplayprovider'] if 'brplayprovider' in channel else None isFolder = channel['isFolder'] == 'true' if 'isFolder' in channel else False isPlayable = channel['playable'] == 'true' if 'playable' in channel else False url = channel['url'] if 'url' in channel else '%s?action=playlive&provider=%s&id_globo_videos=%s&isFolder=%s&meta=%s&t=%s' % (sysaddon, brplayprovider, id_globo_videos, isFolder, sysmeta, self.systime) cm = [(refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)] if isOld is True: cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) fanart = channel['fanart'] art = {'icon': channel['logo'], 'fanart': fanart} if 'poster' in channel: art.update({'poster': channel['poster']}) if 'banner' in channel: art.update({'banner': channel['banner']}) if 'clearart' in channel: art.update({'clearart': channel['clearart']}) if 'clearlogo' in channel: art.update({'clearlogo': channel['clearlogo']}) if 'landscape' in channel: art.update({'landscape': channel['landscape']}) if 'thumb' in channel: art.update({'thumb': channel['thumb']}) item.setArt(art) if 'logo' in channel and 'logo2' in channel: item.setProperty('Logo1', channel['logo']) item.setProperty('Logo2', channel['logo2']) item.setProperty('Initials1', channel['initials1']) item.setProperty('Initials2', channel['initials2']) if 'live' in channel: item.setProperty('Live', str(channel['live'])) if 'gamedetails' in channel: item.setProperty('GameDetails', channel['gamedetails']) item.setProperty('Fanart_Image', fanart) if 'hd' not in channel or channel['hd'] is True: video_info = {'aspect': '1.78', 'width': '1280', 'height': '720'} else: video_info = {'aspect': '1.78', 'width': '720', 'height': '480'} item.addStreamInfo('video', video_info) item.addContextMenuItems(cm) item.setProperty('IsPlayable', 'false' if isFolder or not isPlayable else 'true') item.setInfo(type='video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) if 'duration' in channel and channel['duration'] is not None: duration = float(meta['duration']) startdate = util.strptime_workaround(channel['dateadded'], '%Y-%m-%d %H:%M:%S') if 'dateadded' in channel and channel['dateadded'] else None offset = float(util.get_total_seconds(datetime.datetime.now() - startdate)) if startdate else 0 item.setProperty('Progress', str((offset / duration) * 100) if duration else str(0)) item.setProperty('totaltime', str(duration)) # if not isFolder: # item.setMimeType("application/vnd.apple.mpegurl") list_items.append((url, item, isFolder)) control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_DATEADDED) control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_VIDEO_SORT_TITLE) control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_LABEL_IGNORE_FOLDERS) control.addItems(syshandle, list_items) control.category(handle=syshandle, category=control.lang(32001).encode('utf-8')) content = 'LiveTV' if control.isJarvis else 'tvshows' control.content(syshandle, content) control.directory(syshandle, cacheToDisc=False)
def playlive(self, meta): meta = meta or {} control.log("SBT - play_stream | meta=%s" % meta) self.isLive = True url = self.get_url() control.log("live media url: %s" % url) if not url: control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return if control.proxy_url: http_proxy = MediaProxy(control.proxy_url) self.url = http_proxy.resolve(url) stop_event = http_proxy.stop_event else: self.url = url stop_event = None if self.url is None: if stop_event: control.log("Setting stop event for proxy player") stop_event.set() control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return parsed_url = urlparse(url) control.log("Resolved URL: %s" % repr(self.url)) control.log("Parsed URL: %s" % repr(parsed_url)) if control.supports_offscreen: item = control.item(path=self.url, offscreen=True) else: item = control.item(path=self.url) item.setArt(meta.get('art', {})) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) if parsed_url.path.endswith(".mpd"): mime_type = 'application/dash+xml' item.setProperty('inputstream.adaptive.manifest_type', 'mpd') if self.isLive: item.setProperty( 'inputstream.adaptive.manifest_update_parameter', 'full') else: mime_type = 'application/vnd.apple.mpegurl' item.setProperty('inputstream.adaptive.manifest_type', 'hls') if mime_type: item.setMimeType(mime_type) control.log("MIME TYPE: %s" % repr(mime_type)) if control.is_inputstream_available(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') control.resolve(int(sys.argv[1]), True, item) self.stopPlayingEvent = threading.Event() self.stopPlayingEvent.clear() while not self.stopPlayingEvent.isSet(): if control.monitor.abortRequested(): control.log("Abort requested") break control.sleep(1000) if stop_event: control.log("Setting stop event for proxy player") stop_event.set() control.log("Done playing. Quitting...")
def playlive(self, id, meta): meta = meta or {} control.log("Now Online - play_stream: id=%s | meta=%s" % (id, meta)) if id is None: return self.isLive = meta.get('livefeed', False) try: url, avs_cookie, login_info, xsrf, device_id, sc_id, cdn_token = self.get_cdn( id, self.isLive) except Exception as ex: control.log(traceback.format_exc(), control.LOGERROR) control.okDialog(u'Now Online', ex.message) return encrypted = True if encrypted and not control.is_inputstream_available(): control.okDialog(u'Now Online', control.lang(34103).encode('utf-8')) return control.log("live media url: %s" % url) thumb = meta['thumb'] if 'thumb' in meta else None self.url = url if control.supports_offscreen: item = control.item(path=self.url, offscreen=True) else: item = control.item(path=self.url) item.setArt({'icon': thumb, 'thumb': thumb}) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) item.setProperty('inputstream.adaptive.manifest_type', 'mpd') # if self.isLive: # item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full') if encrypted: item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') licence_url = 'https://proxy.claro01.verspective.net/multirights/widevine?deviceId={deviceId}'.format( deviceId=base64.urlsafe_b64encode(device_id)) key_headers = { 'Referer': 'https://www.nowonline.com.br/', 'Origin': 'https://www.nowonline.com.br', } video_type = 'LIVE' if self.isLive else 'VOD' if not self.isLive: url_id = 'https://www.nowonline.com.br/avsclient/contents/product/{id}?channel={platform}'.format( id=id, platform=PLATFORM) header = { 'referer': 'https://www.nowonline.com.br/', } if PLATFORM == 'PCTV': header['x-xsrf-token'] = xsrf cookies = {'avs_cookie': avs_cookie, 'LoginInfo': login_info} control.log('GET VOD ID: %s' % url_id) response = requests.get(url_id, headers=header, cookies=cookies, proxies=proxy).json() control.log(response) available = response.get('response', {}).get('watch', {}).get('available', False) if not available: control.okDialog(u'Now Online', 'Content not available') return cp_id = response.get('response', {}).get('cpId', -1) else: cp_id = id if PLATFORM == 'PCTV': account_device_id = '|accountDeviceId=1234567' if not self.isLive else '' key_headers[ 'privateData'] = 'cookie={avs_cookie}|avs_id={id}|platform={platform}|videoType={videoType}|session={cdn_token}|x-xsrf-token={xsrf}{account_device_id}'.format( avs_cookie=avs_cookie, id=cp_id, xsrf=xsrf, platform=PLATFORM, videoType=video_type, account_device_id=account_device_id, cdn_token=cdn_token) user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36' else: key_headers[ 'privateData'] = 'cookie={avs_cookie}|avs_id={id}|platform={platform}|videoType={videoType}|accountDeviceId={deviceId}||isDownload=Y'.format( avs_cookie=avs_cookie, id=cp_id, deviceId=device_id, platform=PLATFORM, videoType=video_type) user_agent = 'NOW/1 CFNetwork/1197 Darwin/20.0.0' key_headers['User-Agent'] = user_agent key_headers['content-type'] = 'application/octet-stream' license_key = '%s|%s|R{SSM}|' % (licence_url, urllib.urlencode(key_headers)) item.setProperty('inputstream.adaptive.license_key', license_key) item.setProperty('inputstream.adaptive.stream_headers', user_agent) control.log('license_key: %s' % license_key) if control.is_inputstream_available(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') control.resolve(int(sys.argv[1]), True, item) control.log("Done playing. Quitting...")
def playlive(self, id, meta): control.log("Oi Play - play_stream: id=%s | meta=%s" % (id, meta)) if id is None: return data = self.individualize(id) encrypted = 'drm' in data and 'licenseUrl' in data['drm'] if encrypted and not control.is_inputstream_available(): control.okDialog(u'Oi Play', control.lang(34103).encode('utf-8')) return url = data['individualization']['url'] url = url.replace('https://', 'http://') # hack info = data['token']['cmsChannelItem'] title = info['title'] control.log("live media url: %s" % url) try: meta = json.loads(meta) except: meta = { "playcount": 0, "overlay": 6, "title": title, "thumb": info['positiveLogoUrl'], "mediatype": "video", "aired": None, "genre": info["categoryName"], "plot": title, "plotoutline": title } # meta.update({ # "genre": info["categoryName"], # "plot": title, # "plotoutline": title # }) # poster = meta['poster'] if 'poster' in meta else control.addonPoster() thumb = meta['thumb'] if 'thumb' in meta else info['positiveLogoUrl'] self.offset = float(meta['milliseconds_watched'] ) / 1000.0 if 'milliseconds_watched' in meta else 0 self.isLive = info['isLive'] parsed_url = urlparse(url) if ".m3u8" in parsed_url.path: self.url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth( url) else: self.url = url mime_type, stopEvent, cookies = 'video/mp4', None, None if self.url is None: if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return control.log("Resolved URL: %s" % repr(self.url)) control.log("Parsed URL: %s" % repr(parsed_url)) item = control.item(path=self.url) item.setArt({'icon': thumb, 'thumb': thumb}) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) if ".mpd" in parsed_url.path: mime_type = 'application/dash+xml' item.setProperty('inputstream.adaptive.manifest_type', 'mpd') if self.isLive: item.setProperty( 'inputstream.adaptive.manifest_update_parameter', 'full') else: item.setProperty('inputstream.adaptive.manifest_type', 'hls') if encrypted: control.log("DRM: com.widevine.alpha") licence_url = data['drm']['licenseUrl'] + '&token=' + data['drm'][ 'jwtToken'] item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') item.setProperty('inputstream.adaptive.license_key', licence_url + "||R{SSM}|") if mime_type: item.setMimeType(mime_type) control.log("MIME TYPE: %s" % repr(mime_type)) if not cookies and control.is_inputstream_available(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') # if 'subtitles' in info and info['subtitles'] and len(info['subtitles']) > 0: # control.log("FOUND SUBTITLES: %s" % repr([sub['url'] for sub in info['subtitles']])) # item.setSubtitles([sub['url'] for sub in info['subtitles']]) control.resolve(int(sys.argv[1]), True, item) self.stopPlayingEvent = threading.Event() self.stopPlayingEvent.clear() first_run = True # last_time = 0.0 while not self.stopPlayingEvent.isSet(): if control.monitor.abortRequested(): control.log("Abort requested") break if self.isPlaying(): if first_run: self.showSubtitles(False) first_run = False # if not self.isLive: # current_time = self.getTime() # if current_time - last_time > 5 or (last_time == 0 and current_time > 1): # last_time = current_time # self.save_video_progress(self.token, self.video_id, current_time) control.sleep(1000) if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.log("Done playing. Quitting...")
def create_directory(items, current=None, cache_to_disk=True): if current is None: current = {} succeeded = True custom_title = None try: media_types = {} content = None sort_methods = set() for data in items: label = data.get('label', '') if control.supports_offscreen: item = control.item(label=label, offscreen=True) else: item = control.item(label=label) art = data.get('art', {}) or {} item.setArt(art) properties = data.get('properties', {}) or {} item.setProperties(properties) item.setInfo(type='video', infoLabels=control.filter_info_labels(data)) cm = [(control.lang(32072).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % sysaddon), (control.lang(33501).encode('utf-8'), 'RunPlugin(%s?action=clear)' % sysaddon)] for menu in data.get('context_menu', []) or []: cm.append(menu) item.addContextMenuItems(cm) meta_string = urllib.quote_plus(json.dumps(data)) url = data.get( 'url', None) or '%s?action=generic&meta=%s' % (sysaddon, meta_string) is_playable = data.get('IsPlayable', False) is_folder = data.get('IsFolder', not is_playable) if is_playable: item.setProperty('IsPlayable', 'true') else: item.setProperty('IsPlayable', 'false') media_type = data.get('mediatype', 'None') or 'None' if media_type not in media_types: media_types[media_type] = 1 else: media_types[media_type] = media_types[media_type] + 1 sorts = data.get('sort', []) if sorts: try: for sort in sorts: sort_methods.add(sort) except TypeError: sort_methods.add(sorts) if not content and data.get('content', None): content = data.get('content', None) if not custom_title: custom_title = data.get('custom_title', None) if data.get('setCast', None): item.setCast(data.get('setCast', None)) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=is_folder) for sort in sort_methods: if isinstance(sort, tuple): control.addSortMethod(syshandle, sort[0], sort[1]) else: control.addSortMethod(syshandle, sort) category = custom_title or current.get('label', None) if category: control.category(handle=syshandle, category=category) # content: files, songs, artists, albums, movies, tvshows, episodes, musicvideos if not content and media_types: media_type = max(media_types.iteritems(), key=operator.itemgetter(1))[0] if media_type == 'movie': content = 'movies' elif media_type == 'tvshow': content = 'tvshows' elif media_type == 'episode': content = 'episodes' elif media_type == 'season': content = 'tvshows' elif media_type == 'musicvideo': content = 'musicvideos' if content and content != 'default': control.content(syshandle, content) except: control.log(traceback.format_exc(), control.LOGERROR) succeeded = False finally: control.directory(syshandle, succeeded=succeeded, updateListing=False, cacheToDisc=cache_to_disk)
def play_vod(self, id, meta): self.retry = 0 control.log("PLAY SEXYHOT - ID: %s" % id) if id is None: return id = self.__get_globo_id(id) control.log('globo_midia_id: %s' % str(id)) if id is None: return meta = json.loads(meta) if 'url' not in meta or meta['url'] is None: return token = self.__get_token(meta['url']) info = self.__get_video_info(id, token) if info is None: return signed_hashes = get_signed_hashes(info['hash']) query_string = re.sub(r'{{(\w*)}}', r'%(\1)s', info['query_string_template']) query_string = query_string % { 'hash': signed_hashes[0], 'key': 'app', 'openClosed': 'F' if info['subscriber_only'] else 'A', 'user': info["user"] if info['subscriber_only'] else '' } self.url = '?'.join([info['url'], query_string]) control.log("live media url: %s" % self.url) meta.update({ "genre": info["category"], }) poster = meta['poster'] if 'poster' in meta else control.addonPoster() thumb = meta['thumb'] if 'thumb' in meta else info["thumbUri"] url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth(self.url) control.log("Resolved URL: %s" % repr(url)) if self.url is None: if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return item = control.item(path=url) item.setArt({'icon': thumb, 'thumb': thumb, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster}) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) if mime_type: item.setMimeType(mime_type) if not cookies: item.setProperty('inputstream.adaptive.manifest_type', 'hls') item.setProperty('inputstreamaddon', 'inputstream.adaptive') # if cookies: # item.setProperty('inputstream.adaptive.stream_headers', 'Cookie=' + cookies) control.resolve(int(sys.argv[1]), id is not None, item) self.stopPlayingEvent = threading.Event() self.stopPlayingEvent.clear() while not self.stopPlayingEvent.isSet(): if control.monitor.abortRequested(): control.log("Abort requested") break control.sleep(100) if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set()
def playlive(self, id, meta, encrypted=False): control.log("TNT Play - play_stream: id=%s | meta=%s" % (id, meta)) if id is None: return try: url = self.geturl(id, encrypted=encrypted) except Exception as ex: control.log(traceback.format_exc(), control.LOGERROR) control.okDialog(u'TNT Play', str(ex)) return if encrypted and not control.is_inputstream_available(): control.okDialog(u'TNT Play', control.lang(34103).encode('utf-8')) return control.log("live media url: %s" % url) try: meta = json.loads(meta) except: meta = { "playcount": 0, "overlay": 6, } poster = meta['poster'] if 'poster' in meta else None thumb = meta['thumb'] if 'thumb' in meta else None self.offset = float(meta['milliseconds_watched'] ) / 1000.0 if 'milliseconds_watched' in meta else 0 self.isLive = not encrypted parsed_url = urlparse(url) if ".m3u8" in parsed_url.path: self.url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth( url) else: self.url = url mime_type, stopEvent, cookies = None, None, None if self.url is None: if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return control.log("Resolved URL: %s" % repr(self.url)) control.log("Parsed URL: %s" % repr(parsed_url)) item = control.item(path=self.url) item.setArt({'icon': thumb, 'thumb': thumb, 'poster': poster}) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) manifest_type = 'hls' if parsed_url.path.endswith(".m3u8") else 'mpd' if encrypted: control.log("DRM: com.widevine.alpha") licence_url = 'https://widevine.license.istreamplanet.com/widevine/api/license/7837c2c6-8fe4-4db0-9900-1bd66c21ffa3' item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') item.setProperty('inputstream.adaptive.manifest_type', manifest_type) cookie = get_token() retry = 1 token = '' while retry >= 0: retry = retry - 1 headers = { 'Accept': 'application/json', 'cookie': 'avs_cookie=' + cookie, 'User-Agent': 'Tnt/2.2.13.1908061505 CFNetwork/1107.1 Darwin/19.0.0' } drm_url = 'https://api.tntgo.tv/AGL/1.0/A/{lang}/{platform}/TNTGO_LATAM_BR/CONTENT/GETDRMTOKEN/{id}'.format( lang=LANGUAGE, platform=vod_platform, id=id) control.log('TNT DRM GET %s' % drm_url) control.log(headers) drm_response = requests.get( drm_url, headers=headers, proxies=proxy).json() or {} control.log(drm_response) if drm_response.get('resultCode', 'KO') == u'OK': token = drm_response.get('resultObj') break if drm_response.get('message', '') == 'Token not valid': cookie = get_token(True) else: logout() control.infoDialog(drm_response.get( 'message', u'DRM ERROR'), icon='ERROR') return key_headers = 'x-isp-token=%s&Origin=https://www.tntgo.tv' % token license_key = '%s|%s|R{SSM}|' % (licence_url, key_headers) item.setProperty('inputstream.adaptive.license_key', license_key) else: item.setProperty('inputstream.adaptive.manifest_type', 'hls') # mime_type = 'application/vnd.apple.mpegurl' # item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full') if mime_type: item.setMimeType(mime_type) control.log("MIME TYPE: %s" % repr(mime_type)) if not cookies and control.is_inputstream_available(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') item.setProperty('inputstream', 'inputstream.adaptive') # Kodi 19 control.resolve(int(sys.argv[1]), True, item) control.log("Done playing. Quitting...")
def playlive(self, id, meta): meta = meta or {} control.log("Globosat Play - play_stream: id=%s | meta=%s" % (id, meta)) if id is None: return self.isLive = meta.get('livefeed', False) cdn = control.setting('globosat_cdn') if cdn: cdn = cdn.lower() if cdn.lower() != 'auto' else None if meta.get('geofencing') and meta.get('lat') and meta.get('long'): info = resourceshelper.get_geofence_video_info( id, meta.get('lat'), meta.get('long'), auth_helper.get_credentials(), cdn) elif not meta.get('router', True) or cdn: info = resourceshelper.get_video_info(id, cdn=cdn) else: info = resourceshelper.get_video_router(id, self.isLive, cdn) if not info: info = resourceshelper.get_video_info(id, cdn=cdn) control.log("INFO: %s" % repr(info)) if not info or info is None or 'channel' not in info: return try: hash_token = info.get('hash_token') user = info.get('user') if not hash_token: control.log('Signing resource: %s' % info['resource_id']) hash_token, user, credentials = self.sign_resource( info['provider_id'], info['resource_id'], id, info['player'], info['version'], cdn) except Exception as ex: control.log(traceback.format_exc(), control.LOGERROR) control.log("PLAYER ERROR: %s" % repr(ex)) return encrypted = 'encrypted' in info and info['encrypted'] if encrypted and not control.is_inputstream_available(): control.okDialog(control.lang(31200), control.lang(34103).encode('utf-8')) return query_string = re.sub(r'{{(\w*)}}', r'%(\1)s', info['query_string_template']) query_string = query_string % { 'hash': hash_token, 'key': 'app', 'openClosed': 'F' if info['subscriber_only'] and user else 'A', 'user': user if info['subscriber_only'] and user else '', 'token': hash_token } url = '?'.join([info['url'], query_string]) control.log("live media url: %s" % url) self.offset = float(meta['milliseconds_watched'] ) / 1000.0 if 'milliseconds_watched' in meta else 0 parsed_url = urlparse(url) if parsed_url.path.endswith(".m3u8"): self.url, mime_type, stop_event, cookies = hlshelper.pick_bandwidth( url) elif parsed_url.path.endswith(".mpd") and not self.isLive: proxy_handler = MediaProxy() self.url = proxy_handler.resolve(url) stop_event = proxy_handler.stop_event mime_type = None cookies = None else: self.url = url mime_type, stop_event, cookies = 'video/mp4', None, None if self.url is None: if stop_event: control.log("Setting stop event for proxy player") stop_event.set() control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return control.log("Resolved URL: %s" % repr(self.url)) control.log("Parsed URL: %s" % repr(parsed_url)) if control.supports_offscreen: item = control.item(path=self.url, offscreen=True) else: item = control.item(path=self.url) item.setArt(meta.get('art', {})) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) if parsed_url.path.endswith(".mpd"): mime_type = 'application/dash+xml' item.setProperty('inputstream.adaptive.manifest_type', 'mpd') if self.isLive: item.setProperty( 'inputstream.adaptive.manifest_update_parameter', 'full') elif parsed_url.path.endswith(".ism/manifest"): mime_type = 'application/vnd.ms-sstr+xml' item.setProperty('inputstream.adaptive.manifest_type', 'ism') else: item.setProperty('inputstream.adaptive.manifest_type', 'hls') if encrypted: control.log("DRM: %s" % info['drm_scheme']) licence_url = info['protection_url'] item.setProperty('inputstream.adaptive.license_type', info['drm_scheme']) if info['drm_scheme'] == 'com.widevine.alpha' or info[ 'drm_scheme'] == 'com.microsoft.playready': item.setProperty('inputstream.adaptive.license_key', licence_url + "||R{SSM}|") if mime_type: item.setMimeType(mime_type) control.log("MIME TYPE: %s" % repr(mime_type)) if not cookies and control.is_inputstream_available(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') # reqCookies = client.request(url=self.url,output='cookiejar',headRequest=True) # cookie_string = "; ".join([str(x) + "=" + str(y) for x, y in reqCookies.items()]) # item.setProperty('inputstream.adaptive.stream_headers', 'cookie=%s' % cookie_string) # control.log("COOKIE STRING: %s" % cookie_string) if 'subtitles' in info and info['subtitles'] and len( info['subtitles']) > 0: control.log("FOUND SUBTITLES: %s" % repr([sub['url'] for sub in info['subtitles']])) item.setSubtitles([sub['url'] for sub in info['subtitles']]) control.resolve(int(sys.argv[1]), True, item) self.stopPlayingEvent = threading.Event() self.stopPlayingEvent.clear() self.token = auth_helper.get_globosat_token() self.video_id = info['id'] if 'id' in info else None first_run = True last_time = 0.0 while not self.stopPlayingEvent.isSet(): if control.monitor.abortRequested(): control.log("Abort requested") break if self.isPlaying(): if first_run: self.showSubtitles(False) first_run = False if not self.isLive: current_time = self.getTime() if current_time - last_time > 5 or (last_time == 0 and current_time > 1): last_time = current_time self.save_video_progress(self.token, self.video_id, current_time) control.sleep(1000) if stop_event: control.log("Setting stop event for proxy player") stop_event.set() control.log("Done playing. Quitting...")
def playlive(self, id, meta, encrypted=False): meta = meta or {} control.log("TNT Play - play_stream: id=%s | meta=%s" % (id, meta)) if id is None: return try: url = self.geturl(id, encrypted=encrypted) except Exception as ex: control.log(traceback.format_exc(), control.LOGERROR) control.okDialog(u'TNT Play', str(ex)) return if encrypted and not control.is_inputstream_available(): control.okDialog(u'TNT Play', control.lang(34103).encode('utf-8')) self.stop_content(id, encrypted=encrypted) return control.log("media url: %s" % url) self.offset = float(meta['milliseconds_watched']) / 1000.0 if 'milliseconds_watched' in meta else 0 self.isLive = not encrypted parsed_url = urlparse(url) # if ".m3u8" in parsed_url.path: # self.url, mime_type, stop_event, cookies = hlshelper.pick_bandwidth(url) # else: # self.url = url # mime_type, stop_event, cookies = None, None, None proxy_handler = MediaProxy(control.proxy_url) self.url = proxy_handler.resolve(url) stop_event = proxy_handler.stop_event mime_type = None cookies = None if self.url is None: if stop_event: control.log("Setting stop event for proxy player") stop_event.set() control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return control.log("Resolved URL: %s" % repr(self.url)) control.log("Parsed URL: %s" % repr(parsed_url)) if control.supports_offscreen: item = control.item(path=self.url, offscreen=True) else: item = control.item(path=self.url) item.setArt(meta.get('art', {})) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) manifest_type = 'hls' if parsed_url.path.endswith(".m3u8") else 'mpd' if encrypted: control.log("DRM: com.widevine.alpha") licence_url = 'https://widevine.license.istreamplanet.com/widevine/api/license/7837c2c6-8fe4-4db0-9900-1bd66c21ffa3' item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') item.setProperty('inputstream.adaptive.manifest_type', manifest_type) cookie = get_token() retry = 1 token = '' while retry >= 0: retry = retry - 1 headers = { 'Accept': 'application/json', 'cookie': 'avs_cookie=' + cookie, 'User-Agent': 'Tnt/2.2.13.1908061505 CFNetwork/1107.1 Darwin/19.0.0' } drm_url = 'https://api.tntgo.tv/AGL/1.0/A/{lang}/{platform}/TNTGO_LATAM_BR/CONTENT/GETDRMTOKEN/{id}'.format(lang=LANGUAGE, platform=vod_platform, id=id) control.log('TNT DRM GET %s' % drm_url) control.log(headers) drm_response = requests.get(drm_url, headers=headers, proxies=proxy).json() or {} control.log(drm_response) if drm_response.get('resultCode', 'KO') == u'OK': token = drm_response.get('resultObj') break if drm_response.get('message', '') == 'Token not valid': cookie = get_token(True) else: logout() control.infoDialog(drm_response.get('message', u'DRM ERROR'), icon='ERROR') self.stop_content(id, encrypted=encrypted) return headers = { 'user-agent': 'Tnt/2.2.13.1908061505 CFNetwork/1107.1 Darwin/19.0.0', 'x-isp-token': token, 'Origin': 'https://www.tntgo.tv', 'content-type': 'application/octet-stream' } license_key = '%s|%s|R{SSM}|' % (licence_url, urllib.urlencode(headers)) item.setProperty('inputstream.adaptive.license_key', license_key) stream_headers = { 'user-agent': 'Tnt/2.2.13.1908061505 CFNetwork/1107.1 Darwin/19.0.0', 'Origin': 'https://www.tntgo.tv' } item.setProperty('inputstream.adaptive.stream_headers', urllib.urlencode(stream_headers)) else: item.setProperty('inputstream.adaptive.manifest_type', 'hls') # mime_type = 'application/vnd.apple.mpegurl' # item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full') if mime_type: item.setMimeType(mime_type) control.log("MIME TYPE: %s" % repr(mime_type)) if control.is_inputstream_available(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') item.setProperty('inputstream', 'inputstream.adaptive') # Kodi 19 control.resolve(int(sys.argv[1]), True, item) self.stopPlayingEvent = threading.Event() self.stopPlayingEvent.clear() while not self.stopPlayingEvent.isSet(): if control.monitor.abortRequested(): control.log("Abort requested") break if self.isPlaying(): self.current_time = self.getTime() control.sleep(100) if stop_event: control.log("Setting stop event for proxy player") stop_event.set() self.stop_content(id, encrypted=encrypted) control.log("Done playing. Quitting...")
def __get_list_item(self, meta, info, pick_bandwidth=True): hash_token = info['hash'] user = info['user'] query_string = re.sub(r'{{(\w*)}}', r'%(\1)s', info['query_string_template']) query_string = query_string % { 'hash': hash_token, 'key': 'app', 'openClosed': 'F' if info['subscriber_only'] and user else 'A', 'user': user if info['subscriber_only'] and user else '', 'token': hash_token } url = '?'.join([info['url'], query_string]) control.log("live media url: %s" % url) parsed_url = urlparse(url) if parsed_url.path.endswith(".m3u8"): if pick_bandwidth: url, mime_type, stop_event, cookies = hlshelper.pick_bandwidth( url) else: mime_type, stop_event, cookies = None, None, None elif parsed_url.path.endswith(".mpd"): proxy_handler = MediaProxy() url = proxy_handler.resolve(url) stop_event = proxy_handler.stop_event mime_type = None cookies = None else: mime_type, stop_event, cookies = 'video/mp4', None, None if url is None: if stop_event: control.log("Setting stop event for proxy player") stop_event.set() control.infoDialog(message=control.lang(34100).encode('utf-8'), icon='ERROR') return None, None, None control.log("Resolved URL: %s" % repr(url)) if control.supports_offscreen: item = control.item(path=url, offscreen=True) else: item = control.item(path=url) item.setInfo(type='video', infoLabels=control.filter_info_labels(meta)) item.setArt(meta.get('art', {})) item.setProperty('IsPlayable', 'true') item.setContentLookup(False) user_agent = 'User-Agent=Globo Play/0 (iPhone)' if parsed_url.path.endswith(".mpd"): mime_type = 'application/dash+xml' if control.enable_inputstream_adaptive: control.log("Using inputstream.adaptive MPD") item.setProperty('inputstream.adaptive.manifest_type', 'mpd') item.setProperty('inputstream.adaptive.stream_headers', user_agent) item.setProperty('inputstreamaddon', 'inputstream.adaptive') if mime_type: item.setMimeType(mime_type) elif not cookies: item.setMimeType('application/vnd.apple.mpegurl') if control.enable_inputstream_adaptive: control.log("Using inputstream.adaptive HLS") item.setProperty('inputstream.adaptive.manifest_type', 'hls') item.setProperty('inputstream.adaptive.stream_headers', user_agent) item.setProperty('inputstreamaddon', 'inputstream.adaptive') encrypted = info.get('encrypted', False) if encrypted and not control.is_inputstream_available(): control.okDialog(control.lang(31200), control.lang(34103).encode('utf-8')) return if encrypted: control.log("DRM: %s" % info['drm_scheme']) licence_url = info['protection_url'] item.setProperty('inputstream.adaptive.license_type', info['drm_scheme']) if info['drm_scheme'] == 'com.widevine.alpha' or info[ 'drm_scheme'] == 'com.microsoft.playready': item.setProperty('inputstream.adaptive.license_key', licence_url + "||R{SSM}|") # if self.offset > 0: # duration = float(meta['duration']) if 'duration' in meta else 0 # if duration > 0: # item.setProperty('StartPercent', str((self.offset / duration) * 100)) # if self.offset > 0: # item.setProperty('resumetime', str(self.offset)) # duration = float(meta['duration']) if 'duration' in meta else self.offset # duration = duration * 1000.0 # item.setProperty('totaltime', str(duration)) if 'subtitles' in info and info['subtitles'] and len( info['subtitles']) > 0: item.setSubtitles([sub['url'] for sub in info['subtitles']]) return item, url, stop_event
def playlive(self, path, meta): control.log("Telecine Play - play_stream: path=%s | meta=%s" % (path, meta)) if path is None: return if not control.is_inputstream_available(): control.okDialog('Telecine Play', control.lang(34103).encode('utf-8')) return try: url, license_url = self.get_stream(path) except: control.log(traceback.format_exc(), control.LOGERROR) exc_type, exc_value, exc_traceback = sys.exc_info() control.okDialog('Telecine Play', str(exc_value)) return if '.mpd' not in url: response = requests.get(url, proxies=proxy) url = response.url control.log("media url: %s" % url) control.log("license url: %s" % license_url) try: meta = json.loads(meta) except: meta = { "playcount": 0, "overlay": 6, "mediatype": "video", } if control.supports_offscreen: item = control.item(path=url, offscreen=True) else: item = control.item(path=url) art = meta.get('art', {}) or {} item.setArt(art) properties = meta.get('properties', {}) or {} item.setProperties(properties) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) item.setMimeType('application/dash+xml') item.setProperty('inputstream.adaptive.manifest_type', 'mpd') if license_url: headers = { 'user-agent': 'Telecine_iOS/2.5.10 (br.com.telecineplay; build:37; iOS 14.1.0) Alamofire/5.2.2', 'x-device': 'Mobile-iOS', 'x-version': '2.5.10', 'content-type': 'application/octet-stream' } item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') item.setProperty( 'inputstream.adaptive.license_key', "%s|%s|R{SSM}|" % (license_url, urllib.urlencode(headers))) item.setProperty('inputstreamaddon', 'inputstream.adaptive') # if 'subtitles' in info and info['subtitles'] and len(info['subtitles']) > 0: # control.log("FOUND SUBTITLES: %s" % repr([sub['url'] for sub in info['subtitles']])) # item.setSubtitles([sub['url'] for sub in info['subtitles']]) syshandle = int(sys.argv[1]) control.resolve(syshandle, True, item) control.log("Done playing. Quitting...")
def playlive(self, id, meta): control.log("Globosat Play - play_stream: id=%s | meta=%s" % (id, meta)) if id is None: return info = resourceshelper.get_video_info(id) control.log("INFO: %s" % repr(info)) if not info or info is None or 'channel' not in info: return try: hash, user, credentials = self.sign_resource(info['provider_id'], info['resource_id'], id, info['player'], info['version']) except Exception as ex: control.log("ERROR: %s" % repr(ex)) return encrypted = 'encrypted' in info and info['encrypted'] if encrypted and not control.is_inputstream_available(): control.okDialog(control.lang(31200), control.lang(34103).encode('utf-8')) return title = info['channel'] query_string = re.sub(r'{{(\w*)}}', r'%(\1)s', info['query_string_template']) query_string = query_string % { 'hash': hash, 'key': 'app', 'openClosed': 'F' if info['subscriber_only'] else 'A', 'user': user if info['subscriber_only'] else '' } url = '?'.join([info['url'], query_string]) control.log("live media url: %s" % url) try: meta = json.loads(meta) except: meta = { "playcount": 0, "overlay": 6, "title": title, "thumb": info["thumbUri"], "mediatype": "video", "aired": info["exhibited_at"] } meta.update({ "genre": info["category"], "plot": info["title"], "plotoutline": info["title"] }) poster = meta['poster'] if 'poster' in meta else control.addonPoster() thumb = meta['thumb'] if 'thumb' in meta else info["thumbUri"] self.offset = float(meta['milliseconds_watched']) / 1000.0 if 'milliseconds_watched' in meta else 0 self.isLive = 'livefeed' in meta and meta['livefeed'] == 'true' parsed_url = urlparse(url) if parsed_url.path.endswith(".m3u8"): self.url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth(url) else: self.url = url mime_type, stopEvent, cookies = 'video/mp4', None, None if self.url is None: if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return control.log("Resolved URL: %s" % repr(self.url)) control.log("Parsed URL: %s" % repr(parsed_url)) item = control.item(path=self.url) item.setArt({'icon': thumb, 'thumb': thumb, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster}) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) if parsed_url.path.endswith(".mpd"): mime_type = 'application/dash+xml' item.setProperty('inputstream.adaptive.manifest_type', 'mpd') if self.isLive: item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full') elif parsed_url.path.endswith(".ism/manifest"): mime_type = 'application/vnd.ms-sstr+xml' item.setProperty('inputstream.adaptive.manifest_type', 'ism') else: item.setProperty('inputstream.adaptive.manifest_type', 'hls') if encrypted: control.log("DRM: %s" % info['drm_scheme']) licence_url = info['protection_url'] item.setProperty('inputstream.adaptive.license_type', info['drm_scheme']) if info['drm_scheme'] == 'com.widevine.alpha' or info['drm_scheme'] == 'com.microsoft.playready': item.setProperty('inputstream.adaptive.license_key', licence_url + "||R{SSM}|") if mime_type: item.setMimeType(mime_type) control.log("MIME TYPE: %s" % repr(mime_type)) if not cookies and control.is_inputstream_available(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') # reqCookies = client.request(url=self.url,output='cookiejar',headRequest=True) # cookie_string = "; ".join([str(x) + "=" + str(y) for x, y in reqCookies.items()]) # item.setProperty('inputstream.adaptive.stream_headers', 'cookie=%s' % cookie_string) # control.log("COOKIE STRING: %s" % cookie_string) if 'subtitles' in info and info['subtitles'] and len(info['subtitles']) > 0: control.log("FOUND SUBTITLES: %s" % repr([sub['url'] for sub in info['subtitles']])) item.setSubtitles([sub['url'] for sub in info['subtitles']]) control.resolve(int(sys.argv[1]), True, item) self.stopPlayingEvent = threading.Event() self.stopPlayingEvent.clear() self.token = auth_helper.get_globosat_token() self.video_id = info['id'] if 'id' in info else None first_run = True last_time = 0.0 while not self.stopPlayingEvent.isSet(): if control.monitor.abortRequested(): control.log("Abort requested") break if self.isPlaying(): if first_run: self.showSubtitles(False) first_run = False if not self.isLive: current_time = self.getTime() if current_time - last_time > 5 or (last_time == 0 and current_time > 1): last_time = current_time self.save_video_progress(self.token, self.video_id, current_time) control.sleep(1000) if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.log("Done playing. Quitting...")
def playlive(self, id, meta): control.log("Oi Play - play_stream: id=%s | meta=%s" % (id, meta)) if id is None: return try: url = self.geturl(id) except Exception as ex: control.okDialog(control.lang(31200), str(ex)) return encrypted = False # 'drm' in data and 'licenseUrl' in data['drm'] if encrypted: print('DRM Video!') if encrypted and not control.is_inputstream_available(): control.okDialog(control.lang(31200), control.lang(34103).encode('utf-8')) return # url = data['individualization']['url'] # url = url.replace('https://', 'http://') # hack # info = data['token']['cmsChannelItem'] # title = info['title'] control.log("live media url: %s" % url) try: meta = json.loads(meta) except: meta = { "playcount": 0, "overlay": 6, # "title": title, # "thumb": info['positiveLogoUrl'], # "mediatype": "video", # "aired": None, # "genre": info["categoryName"], # "plot": title, # "plotoutline": title } poster = meta['poster'] if 'poster' in meta else None thumb = meta['thumb'] if 'thumb' in meta else None self.offset = float(meta['milliseconds_watched']) / 1000.0 if 'milliseconds_watched' in meta else 0 self.isLive = True # info['isLive'] parsed_url = urlparse(url) if ".m3u8" in parsed_url.path: self.url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth(url) else: self.url = url mime_type, stopEvent, cookies = 'video/mp4', None, None if self.url is None: if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR') return control.log("Resolved URL: %s" % repr(self.url)) control.log("Parsed URL: %s" % repr(parsed_url)) item = control.item(path=self.url) item.setArt({'icon': thumb, 'thumb': thumb, 'poster': poster}) item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta)) item.setContentLookup(False) # if ".mpd" in parsed_url.path: # mime_type = 'application/dash+xml' # item.setProperty('inputstream.adaptive.manifest_type', 'mpd') # if self.isLive: # item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full') # # else: item.setProperty('inputstream.adaptive.manifest_type', 'hls') if encrypted: control.log("DRM: com.widevine.alpha") # licence_url = data['drm']['licenseUrl'] + '&token=' + data['drm']['jwtToken'] # item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') # item.setProperty('inputstream.adaptive.license_key', licence_url + "||R{SSM}|") # if mime_type: # item.setMimeType(mime_type) # control.log("MIME TYPE: %s" % repr(mime_type)) if not cookies and control.is_inputstream_available(): item.setProperty('inputstreamaddon', 'inputstream.adaptive') item.setProperty('inputstream', 'inputstream.adaptive') # Kodi 19 control.resolve(int(sys.argv[1]), True, item) control.log("Done playing. Quitting...")
def __get_list_item(self, meta, info, pick_bandwidth=True): hash = info['hash'] user = info['user'] title = info['title'] # or meta['title'] if 'title' in meta else None query_string = re.sub(r'{{(\w*)}}', r'%(\1)s', info['query_string_template']) query_string = query_string % { 'hash': hash, 'key': 'app', 'openClosed': 'F' if info['subscriber_only'] else 'A', 'user': user if info['subscriber_only'] else '' } url = '?'.join([info['url'], query_string]) control.log("live media url: %s" % url) meta.update({ "genre": info["category"], "plot": info["title"], "plotoutline": info["title"], "title": title }) poster = meta['poster'] if 'poster' in meta else control.addonPoster() thumb = meta['thumb'] if 'thumb' in meta else info["thumbUri"] parsed_url = urlparse(url) if parsed_url.path.endswith(".m3u8"): if pick_bandwidth: url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth( url) else: mime_type, stopEvent, cookies = None, None, None else: # self.url = url mime_type, stopEvent, cookies = 'video/mp4', None, None if url is None: if stopEvent: control.log("Setting stop event for proxy player") stopEvent.set() control.infoDialog(message=control.lang(34100).encode('utf-8'), icon='ERROR') return None, None, None control.log("Resolved URL: %s" % repr(url)) item = control.item(path=url) item.setInfo(type='video', infoLabels=control.filter_info_labels(meta)) item.setArt({ 'icon': thumb, 'thumb': thumb, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster }) item.setProperty('IsPlayable', 'true') item.setContentLookup(False) if parsed_url.path.endswith(".mpd"): mime_type = 'application/dash+xml' if not control.disable_inputstream_adaptive: control.log("Using inputstream.adaptive MPD") item.setProperty('inputstream.adaptive.manifest_type', 'mpd') item.setProperty('inputstreamaddon', 'inputstream.adaptive') if mime_type: item.setMimeType(mime_type) elif not cookies: item.setMimeType('application/vnd.apple.mpegurl') if not control.disable_inputstream_adaptive: control.log("Using inputstream.adaptive HLS") item.setProperty('inputstream.adaptive.manifest_type', 'hls') item.setProperty('inputstreamaddon', 'inputstream.adaptive') encrypted = 'encrypted' in info and info['encrypted'] if encrypted and not control.is_inputstream_available(): control.okDialog(control.lang(31200), control.lang(34103).encode('utf-8')) return if encrypted: control.log("DRM: %s" % info['drm_scheme']) licence_url = info['protection_url'] item.setProperty('inputstream.adaptive.license_type', info['drm_scheme']) if info['drm_scheme'] == 'com.widevine.alpha' or info[ 'drm_scheme'] == 'com.microsoft.playready': item.setProperty('inputstream.adaptive.license_key', licence_url + "||R{SSM}|") # if self.offset > 0: # duration = float(meta['duration']) if 'duration' in meta else 0 # if duration > 0: # item.setProperty('StartPercent', str((self.offset / duration) * 100)) # if self.offset > 0: # item.setProperty('resumetime', str(self.offset)) # duration = float(meta['duration']) if 'duration' in meta else self.offset # duration = duration * 1000.0 # item.setProperty('totaltime', str(duration)) if 'subtitles' in info and info['subtitles'] and len( info['subtitles']) > 0: item.setSubtitles([sub['url'] for sub in info['subtitles']]) return item, url, stopEvent