Ejemplo n.º 1
0
def new_feed():
	from libs.database import DB
	url = kodi.dialog_input('Feed URL')
	if not url: return
	DB.execute("INSERT INTO feed_subscriptions(url) VALUES(?)", [url])
	DB.commit()
	kodi.refresh()
Ejemplo n.º 2
0
def new_feed():
	from libs.database import DB
	url = kodi.dialog_input('Feed URL')
	if not url: return
	DB.execute("INSERT INTO feed_subscriptions(url) VALUES(?)", [url])
	DB.commit()
	kodi.refresh()
Ejemplo n.º 3
0
def search():
	from commoncore.dispatcher import dispatcher
	from libs.database import DB
	from libs import github
	q = kodi.arg('query') if kodi.arg('query') else kodi.dialog_input('Search GitHub')
	if q in [None, False, '']: return False
Ejemplo n.º 4
0
def search():
    from commoncore.dispatcher import dispatcher
    from libs.database import DB
    from libs import github
    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()

    @dispatcher.register('username')
    def username():
        rtype = 'api'
        response = github.find_zips(q)
        if response is None: return
        for r in github.sort_results(response['items']):
            url = github.content_url % (r['repository']['full_name'],
                                        r['path'])
            menu = kodi.ContextMenu()
            if r['is_repository']:
                menu.add(
                    'Browse Repository Contents', {
                        "mode": "browse_repository",
                        "url": url,
                        "file": r['name'],
                        "full_name": "%s/%s" % (q, r['repository']['name'])
                    })
            if r['is_feed']:
                r['display'] = "[COLOR yellow]%s[/COLOR]" % r['name']
                kodi.add_menu_item({
                    'mode': 'install_feed',
                    "url": url
                }, {
                    'title': r['name'],
                    'display': r['display']
                },
                                   menu=menu,
                                   icon='null')
            else:
                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')

    @dispatcher.register('repository')
    def repository():
        rtype = 'api'
        results = github.search(q, 'title')
        if results is None: return
        for i in results['items']:
            user = i['owner']['login']
            response = github.find_zips(user)
            if response is None: continue
            for r in github.sort_results(response['items']):
                url = github.content_url % (r['repository']['full_name'],
                                            r['path'])
                menu = kodi.ContextMenu()
                if r['is_repository']:
                    menu.add(
                        'Browse Repository Contents', {
                            "mode": "browse_repository",
                            "url": url,
                            "file": r['name'],
                            "full_name": "%s/%s" % (q, r['repository']['name'])
                        })
                if r['is_feed']:
                    kodi.add_menu_item({
                        'mode': 'install_feed',
                        "url": url
                    }, {'title': r['name']},
                                       menu=menu,
                                       icon='null')
                else:
                    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')

    @dispatcher.register('addonid')
    def addonid():
        from commoncore.core import highlight
        from libs.github import re_version, content_url
        from distutils.version import LooseVersion
        rtype = 'api'
        results = github.search(q, 'id')
        if results is None: return

        def version_sort(name):
            v = re_version.search(name)
            if v:
                return LooseVersion(v.group(1))
            else:
                return LooseVersion('0.0.0')

        results.sort(key=lambda x: version_sort(x['name']), reverse=True)

        for i in results:
            menu = kodi.ContextMenu()
            r = i['repository']
            full_name = r['full_name']
            title = highlight("%s/%s" % (full_name, i['name']), q, 'yellow')
            url = content_url % (full_name, i['path'])
            menu.add("Search Username", {
                'mode': 'search',
                'type': 'username',
                'query': r['owner']['login']
            })
            kodi.add_menu_item(
                {
                    'mode': 'github_install',
                    "url": url,
                    "file": i['name'],
                    "full_name": full_name
                }, {'title': title},
                menu=menu,
                icon='null')

    dispatcher.run(kodi.arg('type'))
    kodi.eod()
Ejemplo n.º 5
0
def search():
	from commoncore.dispatcher import dispatcher
	from libs.database import DB
	from libs import github
	from libs.github import get_download_url
	q = kodi.arg('query') if kodi.arg('query') else kodi.dialog_input('Search GitHub')
	if q in [None, False, '']: return False
	DB.execute('REPLACE INTO search_history(search_type, query) VALUES(?,?)', [kodi.arg('type'), q])
	DB.commit()
	
	@dispatcher.register('username')
	def username():
		rtype = 'api'
		response = github.find_zips(q)
		if response is None: return
		for r in github.sort_results(response['items']):
			url = get_download_url(r['repository']['full_name'], r['path'])
			menu = kodi.ContextMenu()
			if r['is_repository']:
				menu.add('Browse Repository Contents', {"mode": "browse_repository", "url": url, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])})
			if r['is_feed']:
				r['display'] = "[COLOR yellow]%s[/COLOR]" % r['name']
				kodi.add_menu_item({'mode': 'install_feed', "url": url}, {'title': r['name'], 'display': r['display']}, menu=menu, icon='null')
			elif r['is_installer']:
				r['display'] = "[COLOR orange]%s[/COLOR]" % r['name']
				kodi.add_menu_item({'mode': 'install_batch', "url": url}, {'title': r['name'], 'display': r['display']}, menu=menu, icon='null')	
			else:
				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')
	
	@dispatcher.register('repository')
	def repository():
		rtype = 'api'
		results = github.search(q, 'title')
		if results is None: return
		for i in results['items']:
			user = i['owner']['login']
			response = github.find_zips(user)
			if response is None: continue
			for r in github.sort_results(response['items']):
				url = get_download_url(r['repository']['full_name'], r['path'])
				menu = kodi.ContextMenu()
				if r['is_repository']:
					menu.add('Browse Repository Contents', {"mode": "browse_repository", "url": url, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])})
				if r['is_feed']:
					r['display'] = "[COLOR yellow]%s[/COLOR]" % r['name']
					kodi.add_menu_item({'mode': 'install_feed', "url": url}, {'title': r['name']}, menu=menu, icon='null')
				elif r['is_installer']:
					r['display'] = "[COLOR orange]%s[/COLOR]" % r['name']
					kodi.add_menu_item({'mode': 'install_batch', "url": url}, {'title': r['name'], 'display': r['display']}, menu=menu, icon='null')	
				else:
					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')
	
	@dispatcher.register('addonid')
	def addonid():
		from commoncore.core import highlight
		from libs.github import version_sort
		rtype = 'api'
		results = github.search(q, 'id')
		if results is None: return
		results.sort(key=lambda x:version_sort(x['name']), reverse=True)
			
		for i in results:
			menu = kodi.ContextMenu()
			r = i['repository']
			full_name = r['full_name']
			title = highlight("%s/%s" % (full_name, i['name']), q, 'yellow')
			url = get_download_url(full_name, i['path'])
			menu.add("Search Username", {'mode': 'search', 'type': 'username', 'query': r['owner']['login']})
			kodi.add_menu_item({'mode': 'github_install', "url": url, "file": i['name'], "full_name": full_name}, {'title': title}, menu=menu, icon='null')
	dispatcher.run(kodi.arg('type'))
	kodi.eod()