Пример #1
0
def github_install():
	if kodi.arg('rtype') == 'web':
		from libs import github_installer
		from libs.github_api import master_url
		full_name = "%s/%s" % (kodi.arg('user'), kodi.arg('repo'))
		c = kodi.dialog_confirm("Confirm Install", full_name, yes="Install", no="Cancel")
		if not c: return
		url = master_url % (kodi.arg('user'), kodi.arg('repo'))
		github_installer.GitHub_Installer(kodi.arg('repo'), url, full_name, kodi.vfs.join("special://home", "addons"), True)
		r = kodi.dialog_confirm(kodi.get_name(), 'Click Continue to install more addons or', 'Restart button to finalize addon installation', yes='Restart', no='Continue')
		if r:
			import sys
			import xbmc
			if sys.platform in ['linux', 'linux2', 'win32']:
				xbmc.executebuiltin('RestartApp')
			else:
				xbmc.executebuiltin('ShutDown')
	else:
		import re
		from libs import github_installer
		from libs import github_api
		c = kodi.dialog_confirm("Confirm Install", kodi.arg('file'), yes="Install", no="Cancel")
		if not c: return
		addon_id = re.sub("-[\d\.]+zip$", "", kodi.arg('file'))
		github_installer.GitHub_Installer(addon_id, kodi.arg('url'), kodi.arg('full_name'), kodi.vfs.join("special://home", "addons"))
		r = kodi.dialog_confirm(kodi.get_name(), 'Click Continue to install more addons or', 'Restart button to finalize addon installation', yes='Restart', no='Continue')
		if r:
			import sys
			import xbmc
			if sys.platform in ['linux', 'linux2', 'win32']:
				xbmc.executebuiltin('RestartApp')
			else:
				xbmc.executebuiltin('ShutDown')
Пример #2
0
def github_install():
	if kodi.arg('rtype') == 'web':
		from libs import github_installer
		from libs.github_api import master_url
		full_name = "%s/%s" % (kodi.arg('user'), kodi.arg('repo'))
		c = kodi.dialog_confirm("Confirm Install", full_name, yes="Install", no="Cancel")
		if not c: return
		url = master_url % (kodi.arg('user'), kodi.arg('repo'))
		github_installer.GitHub_Installer(kodi.arg('repo'), url, full_name, kodi.vfs.join("special://home", "addons"), True)
		r = kodi.dialog_confirm(kodi.get_name(), 'Click Continue to install more addons or', 'Restart button to finalize addon installation', yes='Restart', no='Continue')
		if r:
			import sys
			import xbmc
			if sys.platform in ['linux', 'linux2', 'win32']:
				xbmc.executebuiltin('RestartApp')
			else:
				xbmc.executebuiltin('ShutDown')
	else:
		import re
		from libs import github_installer
		from libs import github_api
		c = kodi.dialog_confirm("Confirm Install", kodi.arg('file'), yes="Install", no="Cancel")
		if not c: return
		addon_id = re.sub("-[\d\.]+zip$", "", kodi.arg('file'))
		github_installer.GitHub_Installer(addon_id, kodi.arg('url'), kodi.arg('full_name'), kodi.vfs.join("special://home", "addons"))
		r = kodi.dialog_confirm(kodi.get_name(), 'Click Continue to install more addons or', 'Restart button to finalize addon installation', yes='Restart', no='Continue')
		if r:
			import sys
			import xbmc
			if sys.platform in ['linux', 'linux2', 'win32']:
				xbmc.executebuiltin('RestartApp')
			else:
				xbmc.executebuiltin('ShutDown')
Пример #3
0
def search_menu():
	from libs.database import DB
	kodi.add_menu_item({'mode': 'void'}, {'title': "[COLOR darkorange]%s[/COLOR]" % kodi.arg('title')}, icon='null')
	kodi.add_menu_item({'mode': 'search', 'type': kodi.arg('type')}, {'title': "*** New Search ***"}, icon='null')
	results = DB.query_assoc("SELECT search_id, query FROM search_history WHERE search_type=? ORDER BY ts DESC LIMIT 10", [kodi.arg('type')], silent=True)
	if results is not None:
		for result in results:
			menu = kodi.ContextMenu()
			menu.add('Delete from search history', {"mode": "history_delete", "id": result['search_id']})
			kodi.add_menu_item({'mode': 'search', 'type': kodi.arg('type'), 'query': result['query']}, {'title': result['query']}, menu=menu, icon='null')
	kodi.eod()
Пример #4
0
def browse_repository():
	from libs import github_api
	xml = github_api.browse_repository(kodi.arg('url'))
	
	heading = "%s/%s" % (kodi.arg('full_name'), kodi.arg('file'))
	options = []
	if xml:
		for addon in xml.findAll('addon'):
			options.append("%s (%s)" % (addon['name'], addon['version']))
			
		kodi.dialog_select(heading, sorted(options))
Пример #5
0
def search_menu():
	from libs.database import DB
	kodi.add_menu_item({'mode': 'void'}, {'title': "[COLOR darkorange]%s[/COLOR]" % kodi.arg('title')}, icon='null')
	kodi.add_menu_item({'mode': 'search', 'type': kodi.arg('type')}, {'title': "*** New Search ***"}, icon='null')
	results = DB.query_assoc("SELECT search_id, query FROM search_history WHERE search_type=? ORDER BY ts DESC LIMIT 10", [kodi.arg('type')], silent=True)
	if results is not None:
		for result in results:
			menu = kodi.ContextMenu()
			menu.add('Delete from search history', {"mode": "history_delete", "id": result['search_id']})
			kodi.add_menu_item({'mode': 'search', 'type': kodi.arg('type'), 'query': result['query']}, {'title': result['query']}, menu=menu, icon='null')
	kodi.eod()
Пример #6
0
def browse_repository():
	from libs import github_api
	xml = github_api.browse_repository(kodi.arg('url'))
	
	heading = "%s/%s" % (kodi.arg('full_name'), kodi.arg('file'))
	options = []
	if xml:
		for addon in xml.findAll('addon'):
			options.append("%s (%s)" % (addon['name'], addon['version']))
			
		kodi.dialog_select(heading, sorted(options))
Пример #7
0
def update_addons():
	from libs import github_installer
	quiet = True if kodi.arg('quiet') == 'quiet' else False
	if not quiet:
		c = kodi.dialog_confirm("Confirm Update", "Check for updates", yes="Update", no="Cancel")
		if not c: return
	github_installer.update_addons(quiet)
Пример #8
0
def update_addons():
	from libs import github_installer
	quiet = True if kodi.arg('quiet') == 'quiet' else False
	if not quiet:
		c = kodi.dialog_confirm("Confirm Update", "Check for updates", yes="Update", no="Cancel")
		if not c: return
	github_installer.update_addons(quiet)
Пример #9
0
def search():
	from libs.database import DB
	from libs import github_api
	from libs.github_api import re_repository
	q = kodi.arg('query') if kodi.arg('query') else kodi.dialog_input('Search GitHub')
	if q in [None, False, '']: return False
	DB.execute('INSERT INTO search_history(search_type, query) VALUES(?,?)', [kodi.arg('type'), q])
	DB.commit()
	if kodi.arg('type') == 'username':
		rtype = 'api'
		response = github_api.find_zips(q)
		if response is None: return
		for r in github_api.sort_results(response['items']):
			url = github_api.content_url % (r['repository']['full_name'], r['path'])
			menu = kodi.ContextMenu()
			if re_repository.search(r['name']):
				menu.add('Browse Repository Contents', {"mode": "browse_repository", "url": url, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])})
			kodi.add_menu_item({'mode': 'github_install', "url": url, "user": q, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])}, {'title': r['name']}, menu=menu, icon='null')
		kodi.eod()
	elif  kodi.arg('type') == 'repository':
		rtype = 'api'
		results = github_api.search(q, 'title')
		if results is None: return
		for i in results['items']:
			user = i['owner']['login']
			response = github_api.find_zips(user)
			if response is None: continue
			for r in github_api.sort_results(response['items']):
				url = github_api.content_url % (r['repository']['full_name'], r['path'])
				menu = kodi.ContextMenu()
				if re_repository.search(r['name']):
					menu.add('Browse Repository Contents', {"mode": "browse_repository", "url": url, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])})
				kodi.add_menu_item({'mode': 'github_install', "url": url, "user": q, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])}, {'title': r['name']}, menu=menu, icon='null')
		kodi.eod()
	elif  kodi.arg('type') == 'addonid':
		rtype = 'web'
		results = github_api.web_search(q)
		if results is None: return
		for r in results['items']:
			kodi.add_menu_item({'mode': 'github_install', "user": r['owner']['login'], "repo": r['name'], "rtype": rtype}, {'title': "%s/%s" % (r['owner']['login'], r['name'])}, icon='null')
		kodi.eod()
Пример #10
0
def search():
	from libs.database import DB
	from libs import github_api
	from libs.github_api import re_repository
	q = kodi.arg('query') if kodi.arg('query') else kodi.dialog_input('Search GitHub')
	if q in [None, False, '']: return False
	DB.execute('INSERT INTO search_history(search_type, query) VALUES(?,?)', [kodi.arg('type'), q])
	DB.commit()
	if kodi.arg('type') == 'username':
		rtype = 'api'
		response = github_api.find_zips(q)
		if response is None: return
		for r in github_api.sort_results(response['items']):
			url = github_api.content_url % (r['repository']['full_name'], r['path'])
			menu = kodi.ContextMenu()
			if re_repository.search(r['name']):
				menu.add('Browse Repository Contents', {"mode": "browse_repository", "url": url, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])})
			kodi.add_menu_item({'mode': 'github_install', "url": url, "user": q, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])}, {'title': r['name']}, menu=menu, icon='null')
		kodi.eod()
	elif  kodi.arg('type') == 'repository':
		rtype = 'api'
		results = github_api.search(q, 'title')
		if results is None: return
		for i in results['items']:
			user = i['owner']['login']
			response = github_api.find_zips(user)
			if response is None: continue
			for r in github_api.sort_results(response['items']):
				url = github_api.content_url % (r['repository']['full_name'], r['path'])
				menu = kodi.ContextMenu()
				if re_repository.search(r['name']):
					menu.add('Browse Repository Contents', {"mode": "browse_repository", "url": url, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])})
				kodi.add_menu_item({'mode': 'github_install', "url": url, "user": q, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])}, {'title': r['name']}, menu=menu, icon='null')
		kodi.eod()
	elif  kodi.arg('type') == 'addonid':
		rtype = 'web'
		results = github_api.web_search(q)
		if results is None: return
		for r in results['items']:
			kodi.add_menu_item({'mode': 'github_install', "user": r['owner']['login'], "repo": r['name'], "rtype": rtype}, {'title': "%s/%s" % (r['owner']['login'], r['name'])}, icon='null')
		kodi.eod()
Пример #11
0
def history_delete():
	if not kodi.arg('id'): return
	from libs.database import DB
	DB.execute("DELETE FROM search_history WHERE search_id=?", [kodi.arg('id')])
	DB.commit()	
	kodi.refresh()
Пример #12
0
def history_delete():
	if not kodi.arg('id'): return
	from libs.database import DB
	DB.execute("DELETE FROM search_history WHERE search_id=?", [kodi.arg('id')])
	DB.commit()	
	kodi.refresh()