Python xbmc.getCondVisibility() Examples

The following are 30 code examples of xbmc.getCondVisibility(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xbmc , or try the search function .
Example #1
Source File: kodi.py    From script.module.urlresolver with GNU General Public License v2.0 6 votes vote down vote up
def __create_dialog(self, line1, line2, line3):
        if self.background:
            pd = xbmcgui.DialogProgressBG()
            msg = line1 + line2 + line3
            pd.create(self.heading, msg)
        else:
            if xbmc.getCondVisibility('Window.IsVisible(progressdialog)'):
                pd = CustomProgressDialog.ProgressDialog()
            else:
                pd = xbmcgui.DialogProgress()
            if six.PY2:
                pd.create(self.heading, line1, line2, line3)
            else:
                pd.create(self.heading,
                          line1 + '\n'
                          + line2 + '\n'
                          + line3)
        return pd 
Example #2
Source File: script.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 6 votes vote down vote up
def wait_for_id(self, to_close=False, window_id=None, call_id=None, poll=1, timeout=30):
        """
        Waits for matching ID to open before continuing
        Set to_close flag to wait for matching ID to close instead
        Returns True if successful.

        """
        if not window_id:
            return True

        t = 0
        is_instance = self.get_instance(call_id)
        is_visible = xbmc.getCondVisibility("Window.IsVisible({})".format(window_id))

        while (
                not self.monitor.abortRequested() and t < timeout and is_instance
                and ((to_close and is_visible) or (not to_close and not is_visible))):
            self.monitor.waitForAbort(poll)
            is_instance = self.get_instance(call_id)
            is_visible = xbmc.getCondVisibility("Window.IsVisible({})".format(window_id))
            t += poll

        return True if is_instance and t < timeout else False 
Example #3
Source File: client.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
def get_platform():

    if xbmc.getCondVisibility('system.platform.osx'):
        return "OSX"
    elif xbmc.getCondVisibility('system.platform.atv2'):
        return "ATV2"
    elif xbmc.getCondVisibility('system.platform.ios'):
        return "iOS"
    elif xbmc.getCondVisibility('system.platform.windows'):
        return "Windows"
    elif xbmc.getCondVisibility('system.platform.android'):
        return "Linux/Android"
    elif xbmc.getCondVisibility('system.platform.linux.raspberrypi'):
        return "Linux/RPi"
    elif xbmc.getCondVisibility('system.platform.linux'):
        return "Linux"
    else:
        return "Unknown" 
Example #4
Source File: vpnapi.py    From script.tvguide.fullscreen with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self):
        # Class initialisation.  Fails with a RuntimeError exception if VPN Manager add-on is not available, or too old
        self.filtered_addons = []
        self.filtered_windows = []
        self.primary_vpns = []
        self.last_updated = 0
        self.refreshLists()
        self.default = self.getConnected()
        xbmc.log("VPN Mgr API : Default is " + self.default, level=xbmc.LOGDEBUG)
        self.timeout = 30
        if not xbmc.getCondVisibility("System.HasAddon(service.vpn.manager)"):
            xbmc.log("VPN Mgr API : VPN Manager is not installed, cannot use filtering", level=xbmc.LOGERROR)
            raise RuntimeError("VPN Manager is not installed")
        else:
            v = int((xbmcaddon.Addon("service.vpn.manager").getAddonInfo("version").strip()).replace(".",""))
            if v < 310:
                raise RuntimeError("VPN Manager " + str(v) + " installed, but needs to be v3.1.0 or later") 
Example #5
Source File: util.py    From romcollectionbrowser with GNU General Public License v2.0 6 votes vote down vote up
def current_os():
    cos = ''
    # FIXME TODO Add other platforms
    # Map between Kodi's platform name (defined in http://kodi.wiki/view/List_of_boolean_conditions)
    # and the os name in emu_autoconfig.xml
    platforms = ('System.Platform.Android',
                 'System.Platform.OSX',
                 'System.Platform.Windows',
                 'System.Platform.Linux')

    for platform in platforms:
        if xbmc.getCondVisibility(platform):
            cos = platform.split('.')[-1]
            break

    return cos 
Example #6
Source File: context.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
def get_media_type(self):

        ''' Get media type based on sys.listitem. If unfilled, base on visible window.
        '''
        media = sys.listitem.getVideoInfoTag().getMediaType() or sys.listitem.getMusicInfoTag().getMediaType()

        if not media:

            if xbmc.getCondVisibility('Container.Content(albums)'):
                media = "album"
            elif xbmc.getCondVisibility('Container.Content(artists)'):
                media = "artist"
            elif xbmc.getCondVisibility('Container.Content(songs)'):
                media = "song"
            elif xbmc.getCondVisibility('Container.Content(pictures)'):
                media = "picture"
            else:
                LOG.info("media is unknown")

        return media.decode('utf-8') 
Example #7
Source File: platform.py    From plugin.video.kmediatorrent with GNU General Public License v3.0 6 votes vote down vote up
def platform():
    ret = {
        "arch": sys.maxsize > 2**32 and "x64" or "x86",
    }

    if xbmc.getCondVisibility("system.platform.android"):
        ret["os"] = "android"
        if "arm" in os.uname()[4]:
            ret["arch"] = "arm"
    elif xbmc.getCondVisibility("system.platform.linux"):
        ret["os"] = "linux"
        if "arm" in os.uname()[4]:
            ret["arch"] = "arm"
    elif xbmc.getCondVisibility("system.platform.xbox"):
        system_platform = "xbox"
        ret["arch"] = ""
    elif xbmc.getCondVisibility("system.platform.windows"):
        ret["os"] = "windows"
    elif xbmc.getCondVisibility("system.platform.osx"):
        ret["os"] = "darwin"
    elif xbmc.getCondVisibility("system.platform.ios"):
        ret["os"] = "ios"
        ret["arch"] = "arm"

    return ret 
Example #8
Source File: library.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
def run(self):

        while True:

            try:
                item = self.queue.get(timeout=3)
            except Queue.Empty:
                break

            time = self.music_time if item[0] == 'Audio' else self.video_time

            if time and (not self.player.isPlayingVideo() or xbmc.getCondVisibility('VideoPlayer.Content(livetv)')):
                dialog("notification", heading="%s %s" % (_(33049), item[0]), message=item[1],
                       icon="{emby}", time=time, sound=False)

            self.queue.task_done()

            if window('emby_should_stop.bool'):
                break

        LOG.info("--<[ q:notify/%s ]", id(self))
        self.is_done = True 
Example #9
Source File: menu.py    From plugin.program.openwizard with GNU General Public License v3.0 6 votes vote down vote up
def check_for_fm():
    if not xbmc.getCondVisibility('System.HasAddon(script.kodi.android.update)'):
        from resources.libs.gui import addon_menu
        addon_menu.install_from_kodi('script.kodi.android.update')
    
    try:
        updater = xbmcaddon.Addon('script.kodi.android.update')
    except RuntimeError as e:
        return False
        
    fm = int(updater.getSetting('File_Manager'))
    apps = xbmcvfs.listdir('androidapp://sources/apps/')[1]
    
    if fm == 0 and 'com.android.documentsui' not in apps:
        dialog = xbmcgui.Dialog()
        choose = dialog.yesno(CONFIG.ADDONTITLE, 'It appears your device has no default file manager. Would you like to set one now?')
        if not choose:
            dialog.ok(CONFIG.ADDONTITLE, 'If an APK downloads, but doesn\'t open for installation, try changing your file manager in {}\'s "Install Settings".'.format(CONFIG.ADDONTITLE))
        else:
            from resources.libs import install
            install.choose_file_manager()
            
    return True 
Example #10
Source File: window.py    From plugin.program.openwizard with GNU General Public License v3.0 6 votes vote down vote up
def while_window(window, active=False, count=0, counter=15):
    windowopen = xbmc.getCondVisibility('Window.IsActive({0})'.format(window))
    logging.log("{0} is {1}".format(window, windowopen))
    while not windowopen and count < counter:
        logging.log("{0} is {1}({2})".format(window, windowopen, count))
        windowopen = xbmc.getCondVisibility('Window.IsActive({0})'.format(window))
        count += 1
        xbmc.sleep(500)

    while windowopen:
        active = True
        logging.log("{0} is {1}".format(window, windowopen))
        windowopen = xbmc.getCondVisibility('Window.IsActive({0})'.format(window))
        xbmc.sleep(250)
        
    return active 
Example #11
Source File: tools.py    From plugin.program.openwizard with GNU General Public License v3.0 6 votes vote down vote up
def platform():
    if xbmc.getCondVisibility('system.platform.android'):
        return 'android'
    elif xbmc.getCondVisibility('system.platform.linux'):
        return 'linux'
    elif xbmc.getCondVisibility('system.platform.linux.Raspberrypi'):
        return 'linux'
    elif xbmc.getCondVisibility('system.platform.windows'):
        return 'windows'
    elif xbmc.getCondVisibility('system.platform.osx'):
        return 'osx'
    elif xbmc.getCondVisibility('system.platform.atv2'):
        return 'atv2'
    elif xbmc.getCondVisibility('system.platform.ios'):
        return 'ios'
    elif xbmc.getCondVisibility('system.platform.darwin'):
        return 'ios' 
Example #12
Source File: script.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 6 votes vote down vote up
def wait_for_update(self, call_id=None, poll=1, timeout=60):
        """
        Wait for container to update.
        Returns True if successful
        """
        is_instance = self.get_instance(call_id)
        is_updating = xbmc.getCondVisibility("Container(9999).IsUpdating")
        num_items = utils.try_parse_int(xbmc.getInfoLabel("Container(9999).NumItems"))

        t = 0
        while not self.monitor.abortRequested() and t < timeout and is_instance and (is_updating or not num_items):
            self.monitor.waitForAbort(poll)
            is_instance = self.get_instance(call_id)
            is_updating = xbmc.getCondVisibility("Container(9999).IsUpdating")
            num_items = utils.try_parse_int(xbmc.getInfoLabel("Container(9999).NumItems"))
            t += poll

        return True if is_instance and t < timeout else False 
Example #13
Source File: kodi.py    From script.module.urlresolver with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, heading, line1='', line2='', line3='', active=True, countdown=60, interval=5):
        self.heading = heading
        self.countdown = countdown
        self.interval = interval
        self.line1 = line1
        self.line2 = line2
        self.line3 = line3
        if active:
            if xbmc.getCondVisibility('Window.IsVisible(progressdialog)'):
                pd = CustomProgressDialog.ProgressDialog()
            else:
                pd = xbmcgui.DialogProgress()
            if not self.line3:
                line3 = 'Expires in: %s seconds' % countdown
            if six.PY2:
                pd.create(self.heading, line1, line2, line3)
            else:
                pd.create(self.heading,
                          line1 + '\n'
                          + line2 + '\n'
                          + line3)
            pd.update(100)
            self.pd = pd
        else:
            self.pd = None 
Example #14
Source File: player_monitor.py    From plugin.audio.spotify with GNU General Public License v3.0 6 votes vote down vote up
def update_info(self, force):
        cur_playback = self.__sp.current_playback()
        if cur_playback:
            if cur_playback["is_playing"] and (not xbmc.getCondVisibility("Player.Paused") or force):
                player_title = None
                if self.isPlaying():
                    player_title = self.getMusicInfoTag().getTitle().decode("utf-8")
                
                trackdetails = cur_playback["item"]
                if trackdetails is not None and (not player_title or player_title != trackdetails["name"]):
                    log_msg("Next track requested by Spotify Connect player")
                    self.start_playback(trackdetails["id"])
            elif cur_playback["is_playing"] and xbmc.getCondVisibility("Player.Paused"):
                log_msg("Playback resumed from pause requested by Spotify Connect")
                self.__skip_events = True
                self.play()
            elif not xbmc.getCondVisibility("Player.Paused"):
                log_msg("Pause requested by Spotify Connect")
                self.__skip_events = True
                self.pause()
        else:
            self.__skip_events = True
            self.stop() 
Example #15
Source File: advancedfunctions.py    From program.plexus with GNU General Public License v2.0 6 votes vote down vote up
def set_acestream_engine_cache_folder(url):
	if not xbmc.getCondVisibility('system.platform.windows'):
		opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70011))
	else: opcao = ''
	if opcao:
		if not xbmc.getCondVisibility('system.platform.Android'):
			acestream_settings_file = os.path.join(os.getenv("HOME"),'.ACEStream','playerconf.pickle')
		else:
			acestream_settings_file = os.path.join('/sdcard','.ACEStream','playerconf.pickle')
		settings_content = readfile(acestream_settings_file)
		cachefolder = xbmcgui.Dialog().browse(3, translate(70012) , 'myprograms','')
		if cachefolder:
			settings_content = settings_content.replace(url,cachefolder)
			save(acestream_settings_file, settings_content)
			settings.setSetting('acestream_cachefolder',cachefolder)
			xbmc.executebuiltin("Notification(%s,%s,%i,%s)" % (translate(40000), translate(600026), 1,addonpath+"/icon.png"))
			xbmc.executebuiltin("Container.Refresh") 
Example #16
Source File: vpnapi.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self):
        # Class initialisation.  Fails with a RuntimeError exception if add-on is not available, or too old
        self.filtered_addons = []
        self.filtered_windows = []
        self.primary_vpns = []
        self.last_updated = 0
        self.addon_name = ""        
        self.timeout = 30
        if xbmc.getCondVisibility("System.HasAddon(service.vpn.manager)"):
            self.addon_name = "service.vpn.manager"
        elif xbmc.getCondVisibility("System.HasAddon(service.nord.vpn)"):
            self.addon_name = "service.nord.vpn"
        if self.addon_name == "":
            xbmc.log("VPN API : A VPN add-on is not installed, cannot use filtering", level=xbmc.LOGERROR)
            raise RuntimeError("VPN add-on is not installed")
        else:
            v = int((xbmcaddon.Addon(self.addon_name).getAddonInfo("version").strip()).replace(".",""))
            if v < 310:
                raise RuntimeError("VPN add-on version " + str(v) + " installed, but needs to be v3.1.0 or later")
        self.refreshLists()
        self.default = self.getConnected()
        xbmc.log("VPN API : Default is " + self.default, level=xbmc.LOGDEBUG) 
Example #17
Source File: config_wizard.py    From plugin.video.netflix with MIT License 6 votes vote down vote up
def run_addon_configuration(show_end_msg=False):
    """
    Add-on configuration wizard,
    automatically configures profiles and add-ons dependencies, based on user-supplied data and device characteristics
    """
    system = get_system_platform()
    debug('Running add-on configuration wizard ({})', system)
    g.settings_monitor_suspend(True, False)
    is_4k_capable = is_device_4k_capable()

    _set_profiles(system, is_4k_capable)
    _set_kodi_settings(system)
    _set_isa_addon_settings(is_4k_capable, system == 'android')

    # This settings for now used only with android devices and it should remain disabled (keep it for test),
    # in the future it may be useful for other platforms or it may be removed
    g.ADDON.setSettingBool('enable_force_hdcp', False)

    # Enable UpNext if it is installed and enabled
    g.ADDON.setSettingBool('UpNextNotifier_enabled', getCondVisibility('System.AddonIsEnabled(service.upnext)'))

    g.settings_monitor_suspend(False)
    if show_end_msg:
        show_ok_dialog(get_local_string(30154), get_local_string(30157)) 
Example #18
Source File: device_utils.py    From plugin.video.netflix with MIT License 6 votes vote down vote up
def get_system_platform():
    if not hasattr(get_system_platform, 'cached'):
        platform = "unknown"
        if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.android'):
            if xbmc.getCondVisibility('system.platform.linux.raspberrypi'):
                platform = "linux raspberrypi"
            else:
                platform = "linux"
        elif xbmc.getCondVisibility('system.platform.linux') and xbmc.getCondVisibility('system.platform.android'):
            platform = "android"
        elif xbmc.getCondVisibility('system.platform.uwp'):
            platform = "uwp"
        elif xbmc.getCondVisibility('system.platform.windows'):
            platform = "windows"
        elif xbmc.getCondVisibility('system.platform.osx'):
            platform = "osx"
        elif xbmc.getCondVisibility('system.platform.ios'):
            platform = "ios"
        elif xbmc.getCondVisibility('system.platform.tvos'):  # Supported only on Kodi 19.x
            platform = "tvos"
        get_system_platform.cached = platform
    return get_system_platform.cached 
Example #19
Source File: clear.py    From plugin.program.openwizard with GNU General Public License v3.0 6 votes vote down vote up
def clear_function_cache(over=False):
    dialog = xbmcgui.Dialog()

    if not over:
        if dialog.yesno(CONFIG.ADDONTITLE,
                            '[COLOR {0}]Would you like to clear resolver function caches?[/COLOR]'.format(CONFIG.COLOR2),
                            nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]',
                            yeslabel='[B][COLOR springgreen]Clear Cache[/COLOR][/B]'):
            clear = True
    else:
        clear = True
        
    if clear:
        if xbmc.getCondVisibility('System.HasAddon(script.module.resolveurl)'):
                xbmc.executebuiltin('RunPlugin(plugin://script.module.resolveurl/?mode=reset_cache)')
        if xbmc.getCondVisibility('System.HasAddon(script.module.urlresolver)'):
            xbmc.executebuiltin('RunPlugin(plugin://script.module.urlresolver/?mode=reset_cache)') 
Example #20
Source File: advancedfunctions.py    From program.plexus with GNU General Public License v2.0 6 votes vote down vote up
def set_acestream_engine_cache_folder(url):
	if not xbmc.getCondVisibility('system.platform.windows'):
		opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70011))
	else: opcao = ''
	if opcao:
		if not xbmc.getCondVisibility('system.platform.Android'):
			acestream_settings_file = os.path.join(os.getenv("HOME"),'.ACEStream','playerconf.pickle')
		else:
			acestream_settings_file = os.path.join('/sdcard','.ACEStream','playerconf.pickle')
		settings_content = readfile(acestream_settings_file)
		cachefolder = xbmcgui.Dialog().browse(3, translate(70012) , 'myprograms','')
		if cachefolder:
			settings_content = settings_content.replace(url,cachefolder)
			save(acestream_settings_file, settings_content)
			settings.setSetting('acestream_cachefolder',cachefolder)
			xbmc.executebuiltin("Notification(%s,%s,%i,%s)" % (translate(40000), translate(600026), 1,addonpath+"/icon.png"))
			xbmc.executebuiltin("Container.Refresh") 
Example #21
Source File: config.py    From tvalacarta with GNU General Public License v3.0 5 votes vote down vote up
def get_system_platform():
    """ fonction: pour recuperer la platform que xbmc tourne """
    import xbmc
    platform = "unknown"
    if xbmc.getCondVisibility( "system.platform.linux" ):
        platform = "linux"
    elif xbmc.getCondVisibility( "system.platform.xbox" ):
        platform = "xbox"
    elif xbmc.getCondVisibility( "system.platform.windows" ):
        platform = "windows"
    elif xbmc.getCondVisibility( "system.platform.osx" ):
        platform = "osx"
    return platform 
Example #22
Source File: config.py    From tvalacarta with GNU General Public License v3.0 5 votes vote down vote up
def get_system_platform():
	""" fonction: pour recuperer la platform que xbmc tourne """
	platform = "unknown"
	if xbmc.getCondVisibility( "system.platform.linux" ):
		platform = "linux"
	elif xbmc.getCondVisibility( "system.platform.xbox" ):
		platform = "xbox"
	elif xbmc.getCondVisibility( "system.platform.windows" ):
		platform = "windows"
	elif xbmc.getCondVisibility( "system.platform.osx" ):
		platform = "osx"
	return platform 
Example #23
Source File: config.py    From tvalacarta with GNU General Public License v3.0 5 votes vote down vote up
def get_system_platform():
	""" fonction: pour recuperer la platform que xbmc tourne """
	platform = "unknown"
	if xbmc.getCondVisibility( "system.platform.linux" ):
		platform = "linux"
	elif xbmc.getCondVisibility( "system.platform.xbox" ):
		platform = "xbox"
	elif xbmc.getCondVisibility( "system.platform.windows" ):
		platform = "windows"
	elif xbmc.getCondVisibility( "system.platform.osx" ):
		platform = "osx"
	return platform 
Example #24
Source File: config.py    From tvalacarta with GNU General Public License v3.0 5 votes vote down vote up
def get_system_platform():
    """ fonction: pour recuperer la platform que xbmc tourne """
    import xbmc
    platform = "unknown"
    if xbmc.getCondVisibility( "system.platform.linux" ):
        platform = "linux"
    elif xbmc.getCondVisibility( "system.platform.xbox" ):
        platform = "xbox"
    elif xbmc.getCondVisibility( "system.platform.windows" ):
        platform = "windows"
    elif xbmc.getCondVisibility( "system.platform.osx" ):
        platform = "osx"
    return platform 
Example #25
Source File: utils.py    From plugin.audio.spotify with GNU General Public License v3.0 5 votes vote down vote up
def test_spotty(self, binary_path):
        '''self-test spotty binary'''
        try:
            st = os.stat(binary_path)
            os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
            args = [
                binary_path,
                "-n", "selftest",
                "-x", "--disable-discovery"
            ]
            startupinfo = None
            if os.name == 'nt':
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
            spotty = subprocess.Popen(
                args,
                startupinfo=startupinfo,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                bufsize=0)
            stdout, stderr = spotty.communicate()
            log_msg(stdout)
            if "ok spotty" in stdout:
                return True
            elif xbmc.getCondVisibility("System.Platform.Windows"):
                log_msg("Unable to initialize spotty binary for playback."
                        "Make sure you have the VC++ 2015 runtime installed.", xbmc.LOGERROR)
        except Exception as exc:
            log_exception(__name__, exc)
        return False 
Example #26
Source File: ga.py    From plugin.video.kmediatorrent with GNU General Public License v3.0 5 votes vote down vote up
def get_platform():
    platforms = {
        "Linux": "X11; Linux",
        "Windows": "Windows NT %d.%d",
        "OSX": "Macintosh; Intel Mac OS X",
        "IOS": "iPad; CPU OS 6_1 like Mac OS X",
    }
    for platform, ua_platform_name in platforms.items():
        if xbmc.getCondVisibility("System.Platform.%s" % platform):
            if platform == "Windows":
                import sys
                version = sys.getwindowsversion()
                ua_platform_name %= (version[0], version[1])
            return ua_platform_name 
Example #27
Source File: googlevideo.py    From script.module.urlresolver with GNU General Public License v2.0 5 votes vote down vote up
def get_media_url(self, host, media_id):
        video = None
        web_url = self.get_url(host, media_id)
        if xbmc.getCondVisibility('System.HasAddon(plugin.video.gdrive)') and self.get_setting('use_gdrive'):
            doc_id = re.search(r'[-\w]{25,}', web_url)
            if doc_id:
                common.kodi.notify(header=None, msg='Resolving with GDRIVE', duration=3000)
                video = 'plugin://plugin.video.gdrive/?mode=video&amp;instance=gdrive1&amp;filename=%s&amp;content_type=video' % doc_id.group(1)

        if not video:
            response, video_urls = self._parse_google(web_url)
            if video_urls:
                video_urls.sort(key=self.__key, reverse=True)
                video = helpers.pick_source(video_urls)

            if response is not None:
                res_headers = response.get_headers(as_dict=True)
                if 'Set-Cookie' in res_headers:
                    self.headers['Cookie'] = res_headers['Set-Cookie']

        if not video:
            if any(url_match in web_url for url_match in self.url_matches):
                video = self._parse_redirect(web_url, hdrs=self.headers)
            elif 'googlevideo.' in web_url:
                video = web_url + helpers.append_headers(self.headers)
        elif 'plugin://' not in video:
            if any(url_match in video for url_match in self.url_matches):
                video = self._parse_redirect(video, hdrs=self.headers)

        if video:
            if 'plugin://' in video:  # google plus embedded videos may result in this
                return video
            else:
                return video + helpers.append_headers(self.headers)

        raise ResolverError('File not found') 
Example #28
Source File: utils.py    From plugin.audio.spotify with GNU General Public License v3.0 5 votes vote down vote up
def kill_spotty():
    '''make sure we don't have any (remaining) spotty processes running before we start one'''
    if xbmc.getCondVisibility("System.Platform.Windows"):
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
        subprocess.Popen(["taskkill", "/IM", "spotty.exe"], startupinfo=startupinfo, shell=True)
    else:
        os.system("killall spotty") 
Example #29
Source File: config.py    From tvalacarta with GNU General Public License v3.0 5 votes vote down vote up
def get_system_platform():
	""" fonction: pour recuperer la platform que xbmc tourne """
	platform = "unknown"
	if xbmc.getCondVisibility( "system.platform.linux" ):
		platform = "linux"
	elif xbmc.getCondVisibility( "system.platform.xbox" ):
		platform = "xbox"
	elif xbmc.getCondVisibility( "system.platform.windows" ):
		platform = "windows"
	elif xbmc.getCondVisibility( "system.platform.osx" ):
		platform = "osx"
	return platform 
Example #30
Source File: utils.py    From plugin.audio.spotify with GNU General Public License v3.0 5 votes vote down vote up
def get_spotty_binary(self):
        '''find the correct spotty binary belonging to the platform'''
        sp_binary = None
        if xbmc.getCondVisibility("System.Platform.Windows"):
            sp_binary = os.path.join(os.path.dirname(__file__), "spotty", "windows", "spotty.exe")
        elif xbmc.getCondVisibility("System.Platform.OSX"):
            # macos binary is x86_64 intel
            sp_binary = os.path.join(os.path.dirname(__file__), "spotty", "darwin", "spotty")
        elif xbmc.getCondVisibility("System.Platform.Linux + !System.Platform.Android"):
            # try to find out the correct architecture by trial and error
            import platform
            architecture = platform.machine()
            log_msg("reported architecture: %s" % architecture)
            if architecture.startswith('AMD64') or architecture.startswith('x86_64'):
                # generic linux x86_64 binary
                sp_binary = os.path.join(os.path.dirname(__file__), "spotty", "x86-linux", "spotty-x86_64")
            else:
                # just try to get the correct binary path if we're unsure about the platform/cpu
                paths = []
##                paths.append(os.path.join(os.path.dirname(__file__), "spotty", "arm-linux", "spotty-muslhf"))
                paths.append(os.path.join(os.path.dirname(__file__), "spotty", "arm-linux", "spotty-hf"))
##                paths.append(os.path.join(os.path.dirname(__file__), "spotty", "arm-linux", "spotty"))
                paths.append(os.path.join(os.path.dirname(__file__), "spotty", "x86-linux", "spotty"))
                for binary_path in paths:
                    if self.test_spotty(binary_path):
                        sp_binary = binary_path
                        break
        if sp_binary:
            st = os.stat(sp_binary)
            os.chmod(sp_binary, st.st_mode | stat.S_IEXEC)
            log_msg("Architecture detected. Using spotty binary %s" % sp_binary)
        else:
            log_msg("Failed to detect architecture or platform not supported ! Local playback will not be available.")
        return sp_binary