Python xbmc.getInfoLabel() Examples

The following are 30 code examples of xbmc.getInfoLabel(). 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: koditidal2.py    From plugin.audio.tidal2 with GNU General Public License v3.0 6 votes vote down vote up
def add_list_items(self, items, content=None, end=True, withNextPage=False):
        TidalSession.add_list_items(self, items, content=content, end=end, withNextPage=withNextPage)
        if end:
            try:
                self.save_album_cache()
                kodiVersion = xbmc.getInfoLabel('System.BuildVersion').split()[0]
                kodiVersion = kodiVersion.split('.')[0]
                skinTheme = xbmc.getSkinDir().lower()
                if 'onfluence' in skinTheme:
                    if kodiVersion <= '16':
                        xbmc.executebuiltin('Container.SetViewMode(506)')
                    elif content == 'musicvideos':
                        xbmc.executebuiltin('Container.SetViewMode(511)')
                    elif content == 'artists':
                        xbmc.executebuiltin('Container.SetViewMode(512)')
                    else:
                        xbmc.executebuiltin('Container.SetViewMode(506)')
                elif 'estuary' in skinTheme:
                    xbmc.executebuiltin('Container.SetViewMode(55)')
            except:
                pass 
Example #2
Source File: osd.py    From plugin.audio.spotify with GNU General Public License v3.0 6 votes vote down vote up
def get_curplayback(self):
        '''get current playback details - retry on error'''
        count = 5
        while count and self.active:
            try:
                cur_playback = self.dialog.sp.current_playback()
                return cur_playback
            except Exception as exc:
                if "token expired" in str(exc):
                    token = xbmc.getInfoLabel("Window(Home).Property(spotify-token)")
                    self.sp._auth = token
                else:
                    log_exception(__name__, exc)
            count -= 1
            xbmc.sleep(500)
        self.dialog.close_dialog()
        return None 
Example #3
Source File: kodi.py    From script.module.urlresolver with GNU General Public License v2.0 6 votes vote down vote up
def get_current_view():
    skinPath = translate_path('special://skin/')
    xml = os.path.join(skinPath, 'addon.xml')
    f = xbmcvfs.File(xml)
    read = f.read()
    f.close()
    try:
        src = re.search('defaultresolution="([^"]+)', read, re.DOTALL).group(1)
    except:
        src = re.search('<res.+?folder="([^"]+)', read, re.DOTALL).group(1)
    src = os.path.join(skinPath, src, 'MyVideoNav.xml')
    f = xbmcvfs.File(src)
    read = f.read()
    f.close()
    match = re.search('<views>([^<]+)', read, re.DOTALL)
    if match:
        views = match.group(1)
        for view in views.split(','):
            if xbmc.getInfoLabel('Control.GetLabel(%s)' % view):
                return view 
Example #4
Source File: context.py    From script.artwork.beef with MIT License 6 votes vote down vote up
def get_mediatype(listitem):
    try:
        item = listitem.getVideoInfoTag().getMediaType()
        if not item:
            item = listitem.getMusicInfoTag().getMediaType()
        return item
    except AttributeError:
        # DEPRECATED: Before Krypton
        pass
    count = 0
    mediatype = xbmc.getInfoLabel('ListItem.DBTYPE')
    while not mediatype and count < 5:
        count += 1
        xbmc.sleep(200)
        mediatype = xbmc.getInfoLabel('ListItem.DBTYPE')
    if not mediatype:
        xbmc.executebuiltin('Notification(Artwork Beef cannot proceed, "Got an unexpected content type. Try again, it should work.", 6000, DefaultIconWarning.png)')
    return mediatype 
Example #5
Source File: common.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
def getConnectTime(addon):
    # Get the connection time from the settings or use a default
    t = addon.getSetting("last_connect_time")
    if not t.isdigit():
        # Return the Kodi build time or the time I just wrote this in Feb '17, whichever is more recent
        # Expecting a %m %d %Y format date here but will just grab the year and not do time 
        # formatting because I don't know what Kodi will do to the month in different locales
        seconds = 0
        try:
            build_date = xbmc.getInfoLabel("System.BuildDate")
            seconds = (int(build_date[-4:]) - 1970) * 31557600
        except:
            # In case the formatting of the build date changess
            pass
        vpn_mgr_time = 1487116800
        if seconds < vpn_mgr_time:
            seconds = vpn_mgr_time
        return seconds
    else:
        return int(t) 
Example #6
Source File: vpnplatform.py    From service.vpn.manager with GNU General Public License v2.0 6 votes vote down vote up
def getPlatform():
    # Work out which platform is being used.
    build = xbmc.getInfoLabel('System.BuildVersion')
    build_number = int(build[0:2])
    if sys.platform == "win32": return platforms.WINDOWS
    if sys.platform == "linux" or sys.platform == "linux2":
        if build_number == 15 and getAddonPath(True, "").startswith("/storage/.kodi/"):
            # For OE 6.0.0 (Kodi 15), openvpn is a separate install             
            return platforms.RPI
        else:
            # Other OE versions and other Linux installs use the openvpn installed in usr/sbin
            return platforms.LINUX
            
    # **** ADD MORE PLATFORMS HERE ****
    
    #if sys.platform == "?": return platforms.ANDROID
    #if sys.platform == "darwin": return platforms.MAC
    return platforms.UNKNOWN 
Example #7
Source File: kodiops.py    From plugin.video.netflix with MIT License 6 votes vote down vote up
def __init__(self):
        import re
        self.build_version = xbmc.getInfoLabel('System.BuildVersion')
        # Parse the version number
        result = re.search(r'\d+\.\d+', self.build_version)
        self.version = result.group(0) if result else ''
        # Parse the major version number
        self.major_version = self.version.split('.')[0] if self.version else ''
        # Parse the date of GIT build
        result = re.search(r'(Git:)(\d+?(?=(-|$)))', self.build_version)
        self.date = int(result.group(2)) if result and len(result.groups()) >= 2 else None
        # Parse the stage name
        result = re.search(r'(\d+\.\d+-)(.+)(?=\s)', self.build_version)
        if not result:
            result = re.search(r'^(.+)(-\d+\.\d+)', self.build_version)
            self.stage = result.group(1) if result else ''
        else:
            self.stage = result.group(2) if result else '' 
Example #8
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 #9
Source File: directory.py    From plugin.video.netflix with MIT License 6 votes vote down vote up
def root(self, pathitems=None):  # pylint: disable=unused-argument
        """Show profiles or home listing when profile auto-selection is enabled"""
        # Get the URL parent path of the navigation: xbmc.getInfoLabel('Container.FolderPath')
        #   it can be found in Kodi log as "ParentPath = [xyz]" but not always return the exact value
        is_parent_root_path = xbmc.getInfoLabel('Container.FolderPath') == g.BASE_URL + '/'
        # Fetch initial page to refresh all session data
        if is_parent_root_path:
            common.make_call('fetch_initial_page')
        # Note when the profiles are updated to the database (by fetch_initial_page call),
        #   the update sanitize also relative settings to profiles (see _delete_non_existing_profiles in website.py)
        autoselect_profile_guid = g.LOCAL_DB.get_value('autoselect_profile_guid', '')
        if autoselect_profile_guid:
            if is_parent_root_path:
                common.info('Performing auto-selection of profile {}', autoselect_profile_guid)
            # Do not perform the profile switch if navigation come from a page that is not the root url,
            # prevents profile switching when returning to the main menu from one of the sub-menus
            if not is_parent_root_path or activate_profile(autoselect_profile_guid):
                self.home(None, False, True)
                return
        list_data, extra_data = common.make_call('get_profiles', {'request_update': False})
        self._profiles(list_data, extra_data) 
Example #10
Source File: log.py    From plugin.video.freplay with GNU General Public License v2.0 6 votes vote down vote up
def logGA(channel, param, programName):
    url = 'http://www.google-analytics.com/collect'
    cid = str(uuid.uuid1())
    cid = cid[cid.rfind('-') + 1:]
    tid = 'UA-62709903-1'
    build = xbmc.getInfoLabel("System.BuildVersion")
    build = 'Kodi ' + build[:build.find(' ')]
    values = {'v': '1',
              'tid': tid,
              'cid': cid,
              't': 'pageview',
              'dl': 'c=%s&p=%s' % (channel, param),
              'dt': programName[:50],
              'ua': build,
              'dr': (globalvar.ADDON.getAddonInfo('name') + '-' + globalvar.ADDON.getAddonInfo('version'))}
    print 'Log', 'c=%s&p=%s' % (channel, param)
    try:
      data = urllib.urlencode(values)
      req = urllib2.Request(url, data)
      response = urllib2.urlopen(req)
    except Exception:
      print 'Error during Google Analytics' 
Example #11
Source File: actions.py    From plugin.video.netflix with MIT License 6 votes vote down vote up
def remove_watched_status(self, videoid):
        """Remove the watched status from the Netflix service"""
        if not ui.ask_for_confirmation(common.get_local_string(30168),
                                       common.get_local_string(30300).format(xbmc.getInfoLabel('ListItem.Label'))):
            return
        if not api.remove_watched_status(videoid):
            ui.show_notification('The operation was cancelled due to an unexpected error')
            return
        # Check if item is in the cache
        videoid_exists, list_id = common.make_http_call('get_continuewatching_videoid_exists',
                                                        {'video_id': str(videoid.value)})
        if videoid_exists:
            # Try to remove the videoid from the list in the cache
            try:
                video_list_sorted_data = g.CACHE.get(cache_utils.CACHE_COMMON, list_id)
                del video_list_sorted_data.videos[videoid.value]
                g.CACHE.add(cache_utils.CACHE_COMMON, list_id, video_list_sorted_data)
                common.json_rpc('Input.Down')  # Avoids selection back to the top
            except CacheMiss:
                pass
        common.container_refresh() 
Example #12
Source File: rpc.py    From addon with GNU General Public License v3.0 6 votes vote down vote up
def GetCurrentView(self):
        skinPath = xbmc.translatePath('special://skin/')
        xml = os.path.join(skinPath, 'addon.xml')
        f = xbmcvfs.File(xml)
        read = f.read()
        f.close()
        try:
            src = re.search('defaultresolution="([^"]+)', read, re.DOTALL).group(1)
        except:
            src = re.search('<res.+?folder="([^"]+)', read, re.DOTALL).group(1)
        src = os.path.join(skinPath, src, 'MyVideoNav.xml')
        f = xbmcvfs.File(src)
        read = f.read()
        f.close()
        match = re.search('<views>([^<]+)', read, re.DOTALL)
        if match:
            views = match.group(1)
            log.info("Skin's ViewModes: %s" % views)
            for view in views.split(','):
                if xbmc.getInfoLabel('Control.GetLabel(%s)' % view):
                    return view 
Example #13
Source File: ivi2xbmc.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def track_page_view2(path,nevent='', tevent='',UATRACK='UA-30985824-7'):
	domain = DOMAIN
	document_path = unquote(path)
	utm_gif_location = "http://www.google-analytics.com/__utm.gif"
	extra = {}
	extra['screen'] = xbmc.getInfoLabel('System.ScreenMode')

	md5String = md5(str(uniq_id)).hexdigest()
	gvid="0x" + md5String[:16]
	utm_url = utm_gif_location + "?" + \
		"utmwv=" + VERSION + \
		"&utmn=" + get_random_number() + \
		"&utmsr=" + quote(extra.get("screen", "")) + \
		"&utmt=" + nevent + \
		"&utme=" + tevent +\
		"&utmhn=localhost" + \
		"&utmr=" + quote('-') + \
		"&utmp=" + quote(document_path) + \
		"&utmac=" + UATRACK + \
		"&utmvid=" + gvid + \
		"&utmcc="+ GAcookie
	return send_request_to_google_analytics(utm_url, UA) 
Example #14
Source File: DialogDownloadProgress.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent_win=None, **kwargs):
        if xbmc.getInfoLabel("Window.Property(DialogDownloadProgress.IsAlive)") == "true":
            raise xbmcguiWindowError("DialogDownloadProgress IsAlive: Not possible to overscan!")

        self.SKINS_PATH = os.path.join(addonDir, "resources", "skins")
        self.ADDON_SKIN = ("default", XBMC_SKIN)[os.path.exists(os.path.join(self.SKINS_PATH, XBMC_SKIN))]
        windowXml = DialogDownloadProgressXML("DialogDownloadProgress.xml", addonDir, self.ADDON_SKIN)
        #windowXml = DialogDownloadProgressXML("DialogProgress.xml", addonDir, self.ADDON_SKIN) # Aeon nox
        self.controls = windowXml.controls
        del windowXml

        self.window   = parent_win
        self.windowId = parent_win

        self.background = None
        self.heading	= None
        self.label	  = None
        self.progress   = None 
Example #15
Source File: kodi.py    From script.module.resolveurl with GNU General Public License v2.0 6 votes vote down vote up
def get_current_view():
    skinPath = translate_path('special://skin/')
    xml = os.path.join(skinPath, 'addon.xml')
    f = xbmcvfs.File(xml)
    read = f.read()
    f.close()
    try:
        src = re.search('defaultresolution="([^"]+)', read, re.DOTALL).group(1)
    except:
        src = re.search('<res.+?folder="([^"]+)', read, re.DOTALL).group(1)
    src = os.path.join(skinPath, src, 'MyVideoNav.xml')
    f = xbmcvfs.File(src)
    read = f.read()
    f.close()
    match = re.search('<views>([^<]+)', read, re.DOTALL)
    if match:
        views = match.group(1)
        for view in views.split(','):
            if xbmc.getInfoLabel('Control.GetLabel(%s)' % view):
                return view 
Example #16
Source File: DialogDownloadProgress.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def getControls(self):
        coordinates = self.getControl(2000).getPosition()

        c_anim = []
        try:
            for anim in re.findall("(\[.*?\])", xbmc.getInfoLabel("Control.GetLabel(1999)"), re.S):
                try: c_anim.append(tuple(eval(anim)))
                except: pass
        except:
            print_exc()

        self.controls["background"] = Control(self.getControl(2001), 0, coordinates, c_anim)

        self.controls["heading"] = Control(self.getControl(2002), 1, coordinates, c_anim)

        self.controls["label"] = Control(self.getControl(2003), 1, coordinates, c_anim)

        try:
            v = xbmc.getInfoLabel("Control.GetLabel(2045)").replace(", ", ",")
            progressTextures = dict([k.split("=") for k in v.split(",")])
        except:
            progressTextures = {}


        self.controls["progress"] = Control(self.getControl(2004), 2, coordinates, c_anim, **progressTextures) 
Example #17
Source File: client.py    From plugin.video.emby with GNU General Public License v3.0 6 votes vote down vote up
def get_device_name():

    ''' Detect the device name. If deviceNameOpt, then
        use the device name in the add-on settings.
        Otherwise fallback to the Kodi device name.
    '''
    if not settings('deviceNameOpt.bool'):
        device_name = xbmc.getInfoLabel('System.FriendlyName').decode('utf-8')
    else:
        device_name = settings('deviceName')
        device_name = device_name.replace("\"", "_")
        device_name = device_name.replace("/", "_")

    if not device_name:
        device_name = "Kodi"

    return device_name 
Example #18
Source File: service.py    From xbmc-addons-chinese with GNU General Public License v2.0 6 votes vote down vote up
def Search(item):
    try:
        rmtree(__temp__)
    except:
        pass
    try:
        os.makedirs(__temp__)
    except:
        pass

    if item['mansearch']:
        title = item['mansearchstr']
        getSubByTitle(title, item['3let_language'])
    else:
        title = '%s %s' % (item['title'], item['year'])
        # pass original filename, api.assrt.net will handle it more properly
        getSubByTitle(xbmc.getInfoLabel("VideoPlayer.Title"),
                      item['3let_language'])  # use assrt.net
        if __addon__.getSetting("subSourceAPI") == 'true':  # use splayer api
            if 'chi' in item['3let_language']:
                getSubByHash(item['file_original_path'],
                             "chn", "zh", "Chinese")
            if 'eng' in item['3let_language']:
                getSubByHash(item['file_original_path'],
                             "eng", "en", "English") 
Example #19
Source File: service.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def run(self):
        self.kodimonitor.waitForAbort(450)  # Delay start-up to give time for datetime python module
        self.nexttime = datetime.datetime.combine(datetime.datetime.today(), datetime.time(utils.try_parse_int(self.update_hour)))  # Get today at hour
        self.lasttime = xbmc.getInfoLabel('Skin.String(TMDbHelper.AutoUpdate.LastTime)')  # Get last update
        self.lasttime = utils.convert_timestamp(self.lasttime) if self.lasttime else None
        if self.lasttime and self.lasttime > self.nexttime:
            self.nexttime += datetime.timedelta(hours=24)  # Already updated today so set for tomorrow

        while not self.kodimonitor.abortRequested() and not self.exit and self.poll_time:
            if self.addon.getSettingBool('library_autoupdate'):
                if datetime.datetime.now() > self.nexttime:  # Scheduled time has past so lets update
                    xbmc.executebuiltin('RunScript(plugin.video.themoviedb.helper,library_autoupdate)')
                    xbmc.executebuiltin('Skin.SetString(TMDbHelper.AutoUpdate.LastTime,{})'.format(datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")))
                    self.nexttime += datetime.timedelta(hours=24)  # Set next update for tomorrow
            self.kodimonitor.waitForAbort(self.poll_time) 
Example #20
Source File: main.py    From plugin.video.iptv.recorder with GNU General Public License v3.0 5 votes vote down vote up
def refresh():
    containerAddonName = xbmc.getInfoLabel('Container.PluginName')
    AddonName = xbmcaddon.Addon().getAddonInfo('id')
    if (containerAddonName == AddonName) and (plugin.get_setting('refresh') == 'true') :
        xbmc.executebuiltin('Container.Refresh') 
Example #21
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def get_addon_id():
    return xbmc.getInfoLabel('Container.PluginName') 
Example #22
Source File: service.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def get_dbtype(self):
        dbtype = xbmc.getInfoLabel('{0}DBTYPE'.format(self.containeritem))
        dbtype = 'actor' if dbtype == 'video' and xbmc.getInfoLabel('{0}Property(Container.Type)'.format(self.containeritem)) == 'person' else dbtype
        if xbmc.getCondVisibility("Window.IsVisible(DialogPVRInfo.xml) | Window.IsVisible(MyPVRChannels.xml) | Window.IsVisible(MyPVRGuide.xml)"):
            dbtype = 'tvshow'
        return '{0}s'.format(dbtype) if dbtype else xbmc.getInfoLabel('Container.Content()') or '' 
Example #23
Source File: service.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def get_color_lumsat(self, r, g, b):
        hls_tuple = colorsys.rgb_to_hls(r / 255.0, g / 255.0, b / 255.0)
        hue = hls_tuple[0]
        lum = utils.try_parse_float(xbmc.getInfoLabel('Skin.String(TMDbHelper.Colors.Luminance)')) or hls_tuple[1]
        sat = utils.try_parse_float(xbmc.getInfoLabel('Skin.String(TMDbHelper.Colors.Saturation)')) or hls_tuple[2]
        return self.rgb_to_int(*colorsys.hls_to_rgb(hue, lum, sat)) 
Example #24
Source File: ga.py    From plugin.video.kmediatorrent with GNU General Public License v3.0 5 votes vote down vote up
def get_user_agent():
    return "XBMC/%s (%s)" % (
        xbmc.getInfoLabel("System.BuildVersion").split(" ")[0],
        get_platform()
    ) 
Example #25
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def get_title():
    title = xbmc.getInfoLabel("ListItem.Title") if xbmc.getInfoLabel("ListItem.Title") else xbmc.getInfoLabel("ListItem.Label")
    return decode_(title) 
Example #26
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def get_media_year(title):
    year = xbmc.getInfoLabel('ListItem.Year')
    if year:
        return year
    else:    
        pattern = r"[([]([12][90]\d\d)[]), ]"
        match = re.compile(decode_(pattern)).search(title)
        return match.group(1) if match else None 
Example #27
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def main():
    uricmd = "plugin://plugin.video.united.search/?action=search&keyword=%s" % xbmc.getInfoLabel("ListItem.Title").split('[')[0].split('(')[0].split('/')[0].strip()
    xbmc.executebuiltin("Container.Update(%s)" % uricmd) 
Example #28
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def get_image():
    image = xbmc.getInfoLabel("ListItem.Icon") if xbmc.getInfoLabel("ListItem.Icon") else xbmc.getInfoLabel("ListItem.Thumb")
    return decode_(image) 
Example #29
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def get_params():
    params = "info=%s" % (TYPE_MEDIA_INFO[_media_type_])
    if _title_ != "":
        params = params + ",name=%s" % _title_
    if _year_ != "":
        params = params + ",year=%s" % _year_
    if _iddb_  != "":
        params = params + ",dbid=%s" % _iddb_
    if xbmc.getInfoLabel("ListItem.Property(id)") and (_iddb_  == ""):
        params = params + ",id=%s" % xbmc.getInfoLabel("ListItem.Property(id)")
    elif _movie_id_ != "":
        params = params + ",id=%s" % _movie_id_
    return params 
Example #30
Source File: default.py    From kodi with GNU General Public License v3.0 5 votes vote down vote up
def get_iddb():
    return xbmc.getInfoLabel("ListItem.DBID") if xbmc.getInfoLabel("ListItem.DBID") and (xbmc.getInfoLabel("ListItem.DBID") != "-1") else ""