示例#1
0
import requests
import github
from . import downloader
from commoncore import kodi
from commoncore import zipfile
from commoncore.beautifulsoup import BeautifulSoup
from database import DB


class installerException(Exception):
	pass

tva_user = '******'

# Define source types
SOURCES = kodi.enum(DEFAULT=0, REPO=1, ZIP=2)

def update_addons(quiet=True):
	from distutils.version import LooseVersion
	if not quiet: kodi.open_busy_dialog()
	sources = DB.query("SELECT addon_id, source FROM install_history")
	update_count = 0
	for source in sources:
		addon_id = source[0]
		source = json.loads(source[1])
		if kodi.get_condition_visiblity("System.HasAddon(%s)" % addon_id):
			if source['type'] == SOURCES.ZIP:
				url, filename, full_name, version = github.find_zip(source['user'], addon_id)
				current_version = kodi.get_addon(addon_id).getAddonInfo('version')
				if LooseVersion(version) > LooseVersion(current_version):
					GitHub_Installer(addon_id, url, full_name, kodi.vfs.join("special://home", "addons"), False, quiet)
示例#2
0
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*'''

import xbmcgui
from commoncore.kodi import enum

WINDOW_ACTIONS = enum(
    ACTION_PREVIOUS_MENU=10,
    ACTION_NAV_BACK=92,
    ACTION_MOVE_LEFT=1,
    ACTION_MOVE_RIGHT=2,
    ACTION_MOVE_UP=3,
    ACTION_MOVE_DOWN=4,
    ACTION_MOUSE_WHEEL_UP=104,
    ACTION_MOUSE_WHEEL_DOWN=105,
    ACTION_MOUSE_DRAG=106,
    ACTION_MOUSE_MOVE=107,
    ACTION_MOUSE_LEFT_CLICK=100,
    ACTION_ENTER=13,
    ACTION_SELECT_ITEM=7,
    ACTION_SPACE=12,
    ACTION_MOUSE_RIGHT_CLICK=101,
    ACTION_SHOW_INFO=11,
    ACTION_CONTEXT_MENU=117,
)


class BaseWindow(xbmcgui.WindowXMLDialog):
    return_val = None

    def __init__(self, *args, **kwargs):
示例#3
0
	
vfs = kodi.vfs
CACHE = vfs.join(kodi.get_profile(), 'API_CACHE')
if not vfs.exists(CACHE): vfs.mkdir(CACHE, True)

try:
	from urllib.parse import urlencode
except ImportError:
	from urllib import urlencode

try:
	str_type = unicode
except:
	str_type = str

TYPES = kodi.enum(TEXT=str_type, STR=type(''), UTF8=type(u''), DICT=type({}), RESPONSE=requests.models.Response)
EXPIRE_TIMES = kodi.enum(FLUSH=-2, NEVER=-1, FIFTEENMIN=.25, THIRTYMIN=.5, HOUR=1, FOURHOURS=4, EIGHTHOURS=8, TWELVEHOURS=12, DAY=24, THREEDAYS=72, WEEK=168)

class baseException(Exception):
	pass

class connectionException(BaseException):
	pass

class responseException(BaseException):
	pass

class BASE_API():
	default_return_type = 'text'
	base_url = ''
	user_agent = ''
示例#4
0
    "NzA0ZjQwYTMzYzUxODdkNzhiNzkgMDNlMDUwOGQxYzE0YjQwZG" \
    "ZmZmIwNDcwM2FlM2I3MzllNDZmMTQxNCAzM2RmZTk1OWRiNTYy" \
    "OWIzMTlkY2U3NzhmYjQwNjkwM2FkYTA4ZjMyIDg1ZDBmMDhhND" \
    "U5ZGM3YmQyNzg1YWJmMTU4M2NkNGVkYzBhM2YxNjMgM2U0NDY2" \
    "ZTkwYTZhM2Y0NmU1OWU5ZjI4ZDAzNjE5ZmNiMWE4YTMyMiA4OT" \
    "M4NWYyODg2OTA3NzA1ZWZmZGM4MjY1NmYxNmFhOTI4NDAzNjc1" \
    "IDJiMmIzN2VkNmU5YjQ3MGNmMGVlMjljNzI2YzFjZjRhZGFiYT" \
    "FlMmM="
    return random.choice(base64.b64decode(dts).split())


SORT_ORDER = kodi.enum(REPO=0,
                       FEED=1,
                       INSTALLER=2,
                       PLUGIN=3,
                       PROGRAM=4,
                       SKIN=5,
                       SERVICE=6,
                       SCRIPT=7,
                       OTHER=100)

#class GitHubWeb(CACHABLE_API):
#	default_return_type = 'text'
#	base_url = "https://github.com/search"


class GitHubAPI(CACHABLE_API):
    default_return_type = 'json'
    base_url = "https://api.github.com"

    def prepair_request(self):