def enable_iptv(): xbmc_path = control.join('special://xbmc', 'addons', 'pvr.iptvsimple') home_path = control.join('special://home', 'addons', 'pvr.iptvsimple') if control.condVisibility('Pvr.HasTVChannels') and ( path.exists(control.transPath(xbmc_path)) or path.exists(control.transPath(home_path)) ) and control.addon_details('pvr.iptvsimple').get('enabled'): control.infoDialog(message=control.lang(30407), time=4000) elif not path.exists(control.join(iptv_folder, 'settings.xml')): control.infoDialog(message=control.lang(30409), time=4000) else: if control.yesnoDialog(line1=control.lang(30406)): control.enable_addon('pvr.iptvsimple') if control.infoLabel( 'System.AddonVersion(xbmc.python)') == '2.24.0': control.execute('StartPVRManager')
def play(url): try: addon_enabled = control.addon_details('inputstream.adaptive').get( 'enabled') except KeyError: addon_enabled = False mimetype = None manifest_type = None leia_plus = control.kodi_version() >= 18.0 stream = resolve(url) if '.m3u8' in stream: manifest_type = 'hls' mimetype = 'application/vnd.apple.mpegurl' elif '.mpd' in stream: manifest_type = 'mpd' dash = addon_enabled and ('.m3u8' in stream or '.mpd' in stream) directory.resolve(stream, dash=dash and leia_plus, mimetype=mimetype, manifest_type=manifest_type)
def check_inputstream_addon(): try: addon_enabled = control.addon_details('inputstream.adaptive').get('enabled') except KeyError: addon_enabled = False leia_plus = control.kodi_version() >= 18.0 first_time_file = control.join(control.dataPath, 'first_time') if not addon_enabled and not file_exists(first_time_file) and leia_plus: try: yes = control.yesnoDialog(control.lang(30014)) if yes: control.enable_addon('inputstream.adaptive') control.infoDialog(control.lang(30402)) with open(first_time_file, 'a'): pass except Exception: pass
def dash_conditionals(stream): try: inputstream_adaptive = control.addon_details( 'inputstream.adaptive').get('enabled') except KeyError: inputstream_adaptive = False m3u8_dash = ('.hls' in stream or '.m3u8' in stream) and control.setting('m3u8_quality_picker') == '2' dash = ('.mpd' in stream or 'dash' in stream or '.ism' in stream or m3u8_dash) and inputstream_adaptive mimetype = None manifest_type = None if dash: if '.hls' in stream or '.m3u8' in stream: manifest_type = 'hls' mimetype = 'application/vnd.apple.mpegurl' elif '.ism' in stream: manifest_type = 'ism' else: manifest_type = 'mpd' log_debug('Activating adaptive parameters for this url: ' + stream) return dash, m3u8_dash, mimetype, manifest_type
def resolve(url): if RADIO_BASE in url: return cached_resolve(url) elif 'plugin://' in url: vid = re.search(r'video_id=([\w-]{11})', url).group(1) streams = yt_resolver(vid) try: addon_enabled = control.addon_details('inputstream.adaptive').get('enabled') except KeyError: addon_enabled = False if not addon_enabled: streams = [s for s in streams if 'mpd' not in s['title'].lower()] stream = streams[0]['url'] return stream else: return cached_resolve(url)
def router(link): if link.startswith(('acestream://', 'sop://')): if 'acestream' in link: stream = 'plugin://program.plexus/?url={0}&mode=1'.format( link.partition('://')[2]) else: stream = 'plugin://program.plexus/?url={0}&mode=2'.format(link) return stream elif 'youtu' in link: yt_mpd_enabled = control.addon(id='plugin.video.youtube').getSetting( 'kodion.video.quality.mpd') == 'true' streams = youtube_resolver.resolve(link) if yt_mpd_enabled: urls = streams else: urls = [s for s in streams if 'dash' not in s['title'].lower()] resolved = urls[0]['url'] return resolved elif 'v.redd.it' in link or 'reddit.com/video' in link: if 'reddit.com/video' in link: link = 'https://v.redd.it/' + link.partition('/')[2] try: dash_on = control.addon_details('inputstream.adaptive').get( 'enabled') except KeyError: dash_on = False if dash_on: stream = link + '/DASHPlaylist.mpd' else: stream = link + '/HLSPlaylist.m3u8' return stream elif resolveurl.HostedMediaFile(link).valid_url(): stream = resolveurl.resolve(link) return stream else: return link
def wrapper(url): if url.endswith('/live'): url = generic(url) if not url: return streams = youtube_resolver.resolve(url) try: addon_enabled = control.addon_details('inputstream.adaptive').get( 'enabled') except KeyError: addon_enabled = False if not addon_enabled: streams = [s for s in streams if 'dash' not in s['title'].lower()] if control.condVisibility('Window.IsVisible(music)') and control.setting( 'audio_only') == 'true': audio_choices = [ u for u in streams if 'dash/audio' in u and 'dash/video' not in u ] if control.setting('yt_quality_picker') == '0': resolved = audio_choices[0]['url'] else: qualities = [i['title'] for i in audio_choices] urls = [i['url'] for i in audio_choices] links = list(zip(qualities, urls)) resolved = stream_picker(links) return resolved elif control.setting('yt_quality_picker') == '1': qualities = [i['title'] for i in streams] urls = [i['url'] for i in streams] links = list(zip(qualities, urls)) resolved = stream_picker(links) return resolved else: resolved = streams[0]['url'] return resolved
def rtmp_enable(): if control.kodi_version() < 17.0: control.infoDialog(control.lang(30322)) return try: enabled = control.addon_details('inputstream.rtmp').get('enabled') except Exception: enabled = False try: if enabled: control.infoDialog(control.lang(30276)) return else: xbmc_path = control.join('special://xbmc', 'addons', 'inputstream.rtmp') home_path = control.join('special://home', 'addons', 'inputstream.rtmp') if path.exists(control.transPath(xbmc_path)) or path.exists( control.transPath(home_path)): yes = control.yesnoDialog(control.lang(30277)) if yes: control.enable_addon('inputstream.rtmp') control.infoDialog(control.lang(30402)) else: try: control.execute('InstallAddon(inputstream.rtmp)') except Exception: control.okDialog(heading='AliveGR', line1=control.lang(30323)) except Exception: control.infoDialog(control.lang(30279))
def wrapper(url): if replace_url: result = re.sub( r'''https?://(?:[0-9A-Z-]+\.)?(?:(youtu\.be|youtube(?:-nocookie)?\.com)/?\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|</a>))[?=&+%\w.-]*''', yt_prefix + r'\2', url, flags=re.I ) if url != result: return result streams = youtube_resolver.resolve(url) try: addon_enabled = control.addon_details('inputstream.adaptive').get('enabled') except KeyError: addon_enabled = False if not addon_enabled: streams = [s for s in streams if 'dash' not in s['title'].lower()] if control.condVisibility('Window.IsVisible(music)') and control.setting('audio_only') == 'true': audio_choices = [u for u in streams if 'dash/audio' in u and 'dash/video' not in u] if control.setting('yt_quality_picker') == '0': resolved = audio_choices[0]['url'] else: qualities = [i['title'] for i in audio_choices] urls = [i['url'] for i in audio_choices] resolved = stream_picker(qualities, urls) return resolved elif control.setting('yt_quality_picker') == '1': qualities = [i['title'] for i in streams] urls = [i['url'] for i in streams] resolved = stream_picker(qualities, urls) return resolved else: resolved = streams[0]['url'] return resolved
def play(url, meta=None, quality=None): if meta: control.busy() stream = resolver(url, quality) try: isa_enabled = control.addon_details('inputstream.adaptive').get( 'enabled') except KeyError: isa_enabled = False dash = ('.mpd' in stream or 'dash' in stream or '.ism' in stream or '.hls' in stream or '.m3u8' in stream) and isa_enabled mimetype = None if isinstance(meta, dict): control.idle() if meta['title'] == 'custom': title = control.inputDialog() meta['title'] = title if dash and control.setting('disable_mpd') == 'false': if '.hls' in stream or 'm3u8' in stream: manifest_type = 'hls' mimetype = 'application/vnd.apple.mpegurl' elif '.ism' in stream: manifest_type = 'ism' else: manifest_type = 'mpd' log_debug('Activating MPEG-DASH for this url: ' + stream) directory.resolve(stream, meta=meta, dash=dash, manifest_type=manifest_type, mimetype=mimetype, resolved_mode=meta is None) else: directory.resolve(stream, meta=meta, resolved_mode=meta is None)
def isa_enable(): if addon_version('xbmc.python') < 2250: control.infoDialog(control.lang(30322)) return try: enabled = control.addon_details('inputstream.adaptive').get('enabled') except Exception: enabled = False try: if enabled: control.infoDialog(control.lang(30254)) return else: xbmc_path = control.join('special://xbmc', 'addons', 'inputstream.adaptive') home_path = control.join('special://home', 'addons', 'inputstream.adaptive') if path.exists(control.transPath(xbmc_path)) or path.exists(control.transPath(home_path)): yes = control.yesnoDialog(control.lang(30252)) if yes: control.enable_addon('inputstream.adaptive') control.infoDialog(control.lang(30402)) else: try: control.execute('InstallAddon(inputstream.adaptive)') except Exception: control.okDialog(heading='AliveGR', line1=control.lang(30323)) except Exception: control.infoDialog(control.lang(30278))
def yt_session(yt_id): streams = yt_resolver(yt_id) try: addon_enabled = control.addon_details('inputstream.adaptive').get('enabled') except KeyError: addon_enabled = False if not addon_enabled: streams = [s for s in streams if 'mpd' not in s['title'].lower()] stream = streams[0]['url'] return stream
def play(self, url): if '.mp4' in url or '.m3u8' in url: stream = url else: html = client.request(url) stream = re.search("video/mp4.+?'(.+?)'", html, re.S).group(1) try: addon_enabled = control.addon_details('inputstream.adaptive').get('enabled') except KeyError: addon_enabled = False dash = '.m3u8' in url and control.kodi_version() >= 18.0 and addon_enabled and control.setting('hls_dash') == 'true' if dash: directory.resolve(stream, dash=dash, mimetype='application/vnd.apple.mpegurl', manifest_type='hls') else: directory.resolve(stream)
def resolve(url, meta=None, icon=None, dash=False, manifest_type=None, inputstream_type='adaptive', headers=None, mimetype=None, resolved_mode=True, live=False): """ Prepares a resolved url into a listitem for playback :param url: Requires a string or unicode, append required urlencoded headers with pipe | :param meta: a dictionary with listitem keys: values :param icon: String :param dash: Boolean :param manifest_type: String :param inputstream_type: String 99.9% of the time it is adaptive :param headers: dictionary or urlencoded string :param mimetype: String :return: None """ from tulip.init import syshandle # Fail gracefully instead of making Kodi complain. if url is None: from kodi_six.xbmc import log log('URL was not provided, failure to resolve stream') return if not headers and '|' in url: url, sep, headers = url.rpartition('|') elif headers: if isinstance(headers, basestring): if headers.startswith('|'): headers = headers[1:] elif isinstance(headers, dict): headers = urlencode(headers) if not dash and headers: url = '|'.join([url, headers]) item = control.item(path=url) if icon is not None: item.setArt({'icon': icon, 'thumb': icon}) if meta is not None: item.setInfo(type='Video', infoLabels=meta) krypton_plus = int( control.infoLabel('System.AddonVersion(xbmc.python)').replace( '.', '')) >= 2250 try: isa_enabled = control.addon_details('inputstream.adaptive').get( 'enabled') except KeyError: isa_enabled = False if dash and krypton_plus and isa_enabled: if not manifest_type: manifest_type = 'mpd' if not mimetype: mimetype = 'application/xml+dash' item.setContentLookup(False) item.setMimeType('{0}'.format(mimetype)) item.setProperty('inputstreamaddon', 'inputstream.{}'.format(inputstream_type)) item.setProperty( 'inputstream.{0}.manifest_type'.format(inputstream_type), manifest_type) if headers: item.setProperty( "inputstream.{0}.stream_headers".format(inputstream_type), headers) elif mimetype: item.setContentLookup(False) item.setMimeType('{0}'.format(mimetype)) if dash and live: item.setProperty( 'inputstream.{}.manifest_update_parameter'.format( inputstream_type), '&start_seq=$START_NUMBER$') if resolved_mode: control.resolve(syshandle, True, item) else: control.player().play(url, item)
def info(self): separator = '[CR]' if control.setting('wrap_labels') == '0' else ' ' try: disclaimer = control.addonInfo('disclaimer').decode('utf-8') except (UnicodeEncodeError, UnicodeDecodeError, AttributeError): disclaimer = control.addonInfo('disclaimer') self.list = [ { 'title': control.lang(30331), 'action': 'welcome', 'icon': control.addonInfo('icon'), 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30105), 'action': 'dmca', 'plot': disclaimer, 'icon': control.addonmedia( addonid=ART_ID, theme='icons', icon='dmca.png', media_subfolder=False ), 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30290), 'action': 'pp', 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30295), 'action': 'toggle_debug', 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30341), 'action': 'kodi_log_upload', 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30296), 'action': 'force', 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30260).format(separator), 'action': 'open_link', 'url': SUPPORT, 'plot': 'Git repo', 'icon': control.addonmedia( addonid=ART_ID, theme='icons', icon='bitbucket.png', media_subfolder=False ), 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30141) + ': [COLOR cyan]' + PAYPAL + '[/COLOR]', 'action': 'open_link', 'url': PAYPAL, 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30142) + ': [COLOR cyan]' + PATREON + '[/COLOR]', 'action': 'open_link', 'url': PATREON, 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30256).format(separator, control.addonInfo('version')), 'action': 'force', 'plot': control.lang(30265), 'icon': control.addonInfo('icon'), 'isFolder': 'False', 'isPlayable': 'False' } , { 'title': control.lang(30257).format(separator, control.addon('script.module.tulip').getAddonInfo('version')), 'action': 'force', 'plot': control.lang(30265), 'icon': control.addon('script.module.tulip').getAddonInfo('icon'), 'isFolder': 'False', 'isPlayable': 'False' } # , # { # 'title': control.lang(30294).format(separator, control.addon('script.module.streamlink.base').getAddonInfo('version')), # 'action': 'force', # 'image': control.addon('script.module.streamlink.base').getAddonInfo('icon'), # 'plot': control.lang(30265), # 'isFolder': 'False', # 'isPlayable': 'False' # } , { 'title': control.lang(30258).format(separator, control.kodi_version()), 'action': 'system_info', 'plot': control.lang(30263), 'icon': control.addonmedia(addonid=ART_ID, theme='icons', icon='kodi.png', media_subfolder=False), 'isFolder': 'False', 'isPlayable': 'False' } ] try: rurl_enabled = control.addon_details('script.module.resolveurl').get('enabled') except Exception: rurl_enabled = False if rurl_enabled: resolveurl = { 'title': control.lang(30264).format(separator, control.addon('script.module.resolveurl').getAddonInfo('version')), 'action': 'other_addon_settings', 'query': 'script.module.resolveurl', 'plot': control.lang(30265), 'icon': control.addon('script.module.resolveurl').getAddonInfo('icon'), 'isFolder': 'False', 'isPlayable': 'False' } self.list.insert(-2, resolveurl) directory.add(self.list, content='movies')