示例#1
0
def __pick_source(sources):
    log_utils.log('Sources found: {0}'.format(sources))
    if len(sources) == 1:
        return sources[0]
    elif len(sources) > 1:
        if kodi.get_kodi_version().major > 16:
            listitem_sources = []
            for source in sources:
                title = source['label'] if source['label'] else kodi.i18n('unknown')
                label2 = '%s [[COLOR=lightgray]%s[/COLOR]]' % (source['content_type'].capitalize(), source['resolver'] if source['resolver'] else 'Kodi')
                icon = ''
                if source['content_type'] == 'image':
                    icon = source['url']
                elif not source['resolver']:
                    icon = ICONS.KODI
                elif source['resolver'] == 'youtube-dl':
                    icon = ICONS.YOUTUBEDL
                elif source['resolver'] == 'URLResolver':
                    icon = ICONS.URLRESOLVER
                l_item = kodi.ListItem(label=title, label2=label2)
                l_item.setArt({'icon': icon, 'thumb': icon})
                listitem_sources.append(l_item)
            result = kodi.Dialog().select(kodi.i18n('choose_source'), list=listitem_sources, useDetails=True)
        else:
            result = kodi.Dialog().select(kodi.i18n('choose_source'),
                                          ['[%s] %s' % (source['content_type'].capitalize(), source['label'])
                                           if source['label']
                                           else '[%s] %s' % (source['content_type'].capitalize(), kodi.i18n('unknown'))
                                           for source in sources])
        if result == -1:
            return None
        else:
            return sources[result]
    else:
        return None
示例#2
0
def update_addons():
	return
	save_file = kodi.vfs.join(kodi.get_profile(), "install.log")
	if vfs.exists(save_file):
		temp = kodi.load_data(save_file, format='json', compress=True)
	else:
		temp = {}
	kodi.open_busy_dialog()
	v = kodi.get_kodi_version()
	from sqlite3 import dbapi2
	dbf = kodi.vfs.join("special://profile/Database", "Addons20.db")
	if v >= 17:
		dbf = kodi.vfs.join("special://profile/Database", "Addons27.db")
		SQL = """SELECT installed.addonID, addons.version from installed 
				 JOIN addons on installed.addonID=addons.addonID
				 WHERE origin = '' and enabled=1"""
		with dbapi2.connect(dbf) as dbh:
			dbc = dbh.cursor()
			dbc.execute(SQL)
			for a in dbc.fetchall():
				if a[0] in temp:
					kodi.log(temp[a[0]])
	else:
		dbf = kodi.vfs.join("special://profile/Database", "Addons20.db")

	kodi.close_busy_dialog()
	
	kodi.notify("Update complete", 'Update complete')
示例#3
0
	def __init__(self, addon_id, url, full_name, destination, master=False):
		kodi.open_busy_dialog()
		v = kodi.get_kodi_version()
		
		# Grab a list of KNOWN addons from the database. Unfortunately Jarvis requires direct database access for the installed flag
		if v >= 17:
			response = kodi.kodi_json_request("Addons.GetAddons", { "installed": False, "properties": ["path", "dependencies"]})
			for a in response['result']['addons']:
				self.available_addons += [a['addonid']]
				self.source_table[a['addonid']] = a['path']
		else:
			from sqlite3 import dbapi2
			dbf = kodi.vfs.join("special://profile/Database", "Addons20.db")
			with dbapi2.connect(dbf) as dbh:
				dbc = dbh.cursor()
				dbc.execute("SELECT addon.addonID, broken.addonID is Null AS enabled, addon.path FROM addon LEFT JOIN broken on addon.addonID=broken.addonID WHERE enabled=1")
				for a in dbc.fetchall():
					self.available_addons += [a[0]]
					self.source_table[a[0]] = a[2]
			dbh.close()
		self._addon_id = addon_id
		self._url = url
		self._full_name = full_name
		self._user, self.repo = full_name.split("/")
		self._master = master
		self._destination = destination
		
		# Add the final addon target to the sources list with type of zip
		# Initiate install routine
		self.sources[addon_id] = {"type": SOURCES.ZIP, "url": url}
		self.install_addon(addon_id, url, full_name, master)
		
		# Enable installed addons
		for addon_id in self.completed:
			self.enable_addon(addon_id)
		kodi.close_busy_dialog()
		if self.install_error:
			kodi.notify("Install failed", self._addon_id)
		else:		
			kodi.notify("Install complete", self._addon_id)