def authorize(): CONTROLS = enum(CLOSE=92000, CODE=91050, PROGRESS=91051) class Authorize(BaseWindow): _abort = False return_val = False def onInit(self): response = request_code() self.device_code = response['device_code'] self.user_code = response['user_code'] self.timeout = int(response['expires_in']) self.getControl(CONTROLS.CODE).setLabel(self.user_code) for tick in range(self.timeout, 0, -1): if tick == 0 or self._abort: break width = (float(tick) / self.timeout) * 596 self.getControl(CONTROLS.PROGRESS).setWidth(int(width)) if (tick % 5) == 0: r = poll_credentials(self.device_code) if r: client_id = r['client_id'] client_secret = r['client_secret'] token = request_token(client_id, client_secret, self.device_code) kodi.set_setting('realdebrid_client_id', client_id, addon_id='script.module.scrapecore') kodi.set_setting('realdebrid_client_secret', client_secret, addon_id='script.module.scrapecore') kodi.set_setting('realdebrid_token', token['access_token'], addon_id='script.module.scrapecore') kodi.set_setting('realdebrid_refresh_token', token['refresh_token'], addon_id='script.module.scrapecore') kodi.notify("RealDebrid Authorization", "Success!") self._close() return kodi.sleep(1000) self.close() def onClick(self, controlID): if controlID == CONTROLS.CLOSE: self._close() def _close(self): self._abort = True self.close() A = Authorize( "auth_realdebrid.xml", kodi.get_addon('script.module.scrapecore').getAddonInfo('path').decode( 'utf-8')) A.show()
def multi_select(heading, options, selected=[]): from commoncore.basewindow import BaseWindow from commoncore.enum import enum CONTROLS = enum(CLOSE=82000, LIST=85001, TITLE=85005, CANCEL=85011, OK=85012) skin_path = vfs.join("special://home/addons", "script.module.commoncore/") class MultiSelect(BaseWindow): def __init__(self, *args, **kwargs): BaseWindow.__init__(self) self.return_val = [] def onInit(self): for c in options: if type(c) is tuple: t,v = c liz = xbmcgui.ListItem(t, iconImage='') liz.setProperty("value", v) elif type(c) is list: t = c[0] v = c[1] else: t = c v = options.index(c) liz = xbmcgui.ListItem(t, iconImage='') liz.setProperty("value", str(v)) if options.index(c) in selected: liz.setProperty("selected", "checked.png") self.getControl(CONTROLS.LIST).addItem(liz) self.getControl(CONTROLS.TITLE).setLabel(heading) self.setFocus(self.getControl(CONTROLS.LIST)) def onClick(self, controlID): if controlID==CONTROLS.LIST: index = self.getControl(CONTROLS.LIST).getSelectedPosition() s = self.getControl(CONTROLS.LIST).getListItem(index).getProperty("selected") != "" if s: self.getControl(CONTROLS.LIST). getListItem(index).setProperty("selected", "") else: self.getControl(CONTROLS.LIST). getListItem(index).setProperty("selected", "checked.png") elif controlID in [ CONTROLS.CLOSE, CONTROLS.CANCEL]: self.close() elif controlID == CONTROLS.OK: for index in xrange(self.getControl(CONTROLS.LIST).size()): if self.getControl(CONTROLS.LIST).getListItem(index).getProperty("selected") != "": self.return_val.append(self.getControl(CONTROLS.LIST).getListItem(index).getProperty("value")) self.close() s = MultiSelect("multi_select.xml", skin_path) return s.show()
def authorize(): CONTROLS = enum(CLOSE=92000, CODE=91050, PROGRESS=91051) class Authorize(BaseWindow): _abort = False return_val = False def onInit(self): response = request_code() self.device_code = response['device_code'] self.user_code = response['user_code'] self.timeout = int(response['expires_in']) self.getControl(CONTROLS.CODE).setLabel(self.user_code) for tick in range(self.timeout, 0,-1): if tick == 0 or self._abort: break width = (float(tick) / self.timeout) * 596 self.getControl(CONTROLS.PROGRESS).setWidth(int(width)) if (tick % 5) == 0: r = poll_credentials(self.device_code) if r: client_id = r['client_id'] client_secret = r['client_secret'] token = request_token(client_id, client_secret, self.device_code) kodi.set_setting('realdebrid_client_id', client_id, addon_id='script.module.scrapecore') kodi.set_setting('realdebrid_client_secret', client_secret, addon_id='script.module.scrapecore') kodi.set_setting('realdebrid_token', token['access_token'], addon_id='script.module.scrapecore') kodi.set_setting('realdebrid_refresh_token', token['refresh_token'], addon_id='script.module.scrapecore') kodi.notify("RealDebrid Authorization", "Success!") self._close() return kodi.sleep(1000) self.close() def onClick(self, controlID): if controlID == CONTROLS.CLOSE: self._close() def _close(self): self._abort = True self.close() A = Authorize("auth_realdebrid.xml", kodi.get_addon('script.module.scrapecore').getAddonInfo('path').decode('utf-8')) A.show()
from commoncore import premiumize from commoncore import dom_parser from commoncore.BeautifulSoup import BeautifulSoup from commoncore.threadpool import ThreadPool vfs = kodi.vfs ADDON_ID = 'script.module.scrapecore' CACHE_PATH = vfs.join("special://home", "userdata/addon_data/script.module.scrapecore/cache") if not vfs.exists(CACHE_PATH): vfs.mkdir(CACHE_PATH) VERIFY_POOLS_SIZE = 15 QUALITY = enum(LOCAL=9, HD1080=8, HD720=7, HD=6, HIGH=5, SD480=4, UNKNOWN=3, LOW=2, POOR=1) """ The Base Scraper The essential functions provided to each scraper subtype """ class BaseScraper(): session = requests.Session() abort_event = False accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' timeout = 5
import hashlib import zlib import requests import traceback from sqlite3 import dbapi2 as database from commoncore import kodi from commoncore.enum import enum from commoncore.filelock import FileLock from commoncore.BeautifulSoup import BeautifulSoup vfs = kodi.vfs CACHE = vfs.join(kodi.get_profile(), 'API_CACHE') if not vfs.exists(CACHE): vfs.mkdir(CACHE, True) TYPES = enum(TEXT=unicode, STR=type(''), UTF8=type(u''), DICT=type({}), RESPONSE=requests.models.Response) EXPIRE_TIMES = 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 = ''
import requests from libs.database import DB from libs import github from commoncore import kodi from commoncore.BeautifulSoup import BeautifulSoup from commoncore.enum import enum class installerException(Exception): pass tva_user = '******' # Define source types SOURCES = 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(
"NzA0ZjQwYTMzYzUxODdkNzhiNzkgMDNlMDUwOGQxYzE0YjQwZG" \ "ZmZmIwNDcwM2FlM2I3MzllNDZmMTQxNCAzM2RmZTk1OWRiNTYy" \ "OWIzMTlkY2U3NzhmYjQwNjkwM2FkYTA4ZjMyIDg1ZDBmMDhhND" \ "U5ZGM3YmQyNzg1YWJmMTU4M2NkNGVkYzBhM2YxNjMgM2U0NDY2" \ "ZTkwYTZhM2Y0NmU1OWU5ZjI4ZDAzNjE5ZmNiMWE4YTMyMiA4OT" \ "M4NWYyODg2OTA3NzA1ZWZmZGM4MjY1NmYxNmFhOTI4NDAzNjc1" \ "IDJiMmIzN2VkNmU5YjQ3MGNmMGVlMjljNzI2YzFjZjRhZGFiYT" \ "FlMmM=" return random.choice(base64.b64decode(dts).split()) SORT_ORDER = 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"
along with this program. If not, see <http://www.gnu.org/licenses/>. *''' import xbmcgui from commoncore.enum 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):
def multi_select(heading, options, selected=[]): from commoncore.basewindow import BaseWindow from commoncore.enum import enum CONTROLS = enum(CLOSE=82000, LIST=85001, TITLE=85005, CANCEL=85011, OK=85012) skin_path = vfs.join("special://home/addons", "script.module.commoncore/") class MultiSelect(BaseWindow): def __init__(self, *args, **kwargs): BaseWindow.__init__(self) self.return_val = [] def onInit(self): for c in options: if type(c) is tuple: t, v = c liz = xbmcgui.ListItem(t, iconImage='') liz.setProperty("value", v) elif type(c) is list: t = c[0] v = c[1] else: t = c v = options.index(c) liz = xbmcgui.ListItem(t, iconImage='') liz.setProperty("value", str(v)) if options.index(c) in selected: liz.setProperty("selected", "checked.png") self.getControl(CONTROLS.LIST).addItem(liz) self.getControl(CONTROLS.TITLE).setLabel(heading) self.setFocus(self.getControl(CONTROLS.LIST)) def onClick(self, controlID): if controlID == CONTROLS.LIST: index = self.getControl(CONTROLS.LIST).getSelectedPosition() s = self.getControl(CONTROLS.LIST).getListItem( index).getProperty("selected") != "" if s: self.getControl( CONTROLS.LIST).getListItem(index).setProperty( "selected", "") else: self.getControl( CONTROLS.LIST).getListItem(index).setProperty( "selected", "checked.png") elif controlID in [CONTROLS.CLOSE, CONTROLS.CANCEL]: self.close() elif controlID == CONTROLS.OK: for index in xrange(self.getControl(CONTROLS.LIST).size()): if self.getControl(CONTROLS.LIST).getListItem( index).getProperty("selected") != "": self.return_val.append( self.getControl(CONTROLS.LIST).getListItem( index).getProperty("value")) self.close() s = MultiSelect("multi_select.xml", skin_path) return s.show()
"ExNiBlNDQ5Zjc0MjM4ZTY1Mjc1ODIwYjk0Zjc1ZTAxOTE1Njhh" \ "NDI3M2Q2IDdiMjFkMTJkMzgzOGFiODYzYzlhMzNhNzZkN2MxZj" \ "k0N2M3NDFjMTcgNDhjMjlkN2FjMzUwMWRlM2JhYzU2ODk4NmI2" \ "NjJkZWM1MDYyZDA5YyA0NTY3NWVkMzBhMmNkNmQ5MTM4YzQwOT" \ "g3NGVhNzRlY2RjYWQ5ZDUzIDBmMmE1MzI0NWM5N2VmNjQ0MmFl" \ "NzA0ZjQwYTMzYzUxODdkNzhiNzkgMDNlMDUwOGQxYzE0YjQwZG" \ "ZmZmIwNDcwM2FlM2I3MzllNDZmMTQxNCAzM2RmZTk1OWRiNTYy" \ "OWIzMTlkY2U3NzhmYjQwNjkwM2FkYTA4ZjMyIDg1ZDBmMDhhND" \ "U5ZGM3YmQyNzg1YWJmMTU4M2NkNGVkYzBhM2YxNjMgM2U0NDY2" \ "ZTkwYTZhM2Y0NmU1OWU5ZjI4ZDAzNjE5ZmNiMWE4YTMyMiA4OT" \ "M4NWYyODg2OTA3NzA1ZWZmZGM4MjY1NmYxNmFhOTI4NDAzNjc1" \ "IDJiMmIzN2VkNmU5YjQ3MGNmMGVlMjljNzI2YzFjZjRhZGFiYT" \ "FlMmM=" return random.choice(base64.b64decode(dts).split()) SORT_ORDER = 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): kodi.sleep(random.randint(100, 250)) # random delay 50-250 ms def build_url(self, uri, query, append_base): if append_base: url = self.base_url + uri
import shutil import requests from libs.database import DB from libs import github from commoncore import kodi from commoncore.BeautifulSoup import BeautifulSoup from commoncore.enum import enum class installerException(Exception): pass tva_user = '******' # Define source types SOURCES = 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)
"g3NGVhNzRlY2RjYWQ5ZDUzIDBmMmE1MzI0NWM5N2VmNjQ0MmFl" \ "NzA0ZjQwYTMzYzUxODdkNzhiNzkgMDNlMDUwOGQxYzE0YjQwZG" \ "ZmZmIwNDcwM2FlM2I3MzllNDZmMTQxNCAzM2RmZTk1OWRiNTYy" \ "OWIzMTlkY2U3NzhmYjQwNjkwM2FkYTA4ZjMyIDg1ZDBmMDhhND" \ "U5ZGM3YmQyNzg1YWJmMTU4M2NkNGVkYzBhM2YxNjMgM2U0NDY2" \ "ZTkwYTZhM2Y0NmU1OWU5ZjI4ZDAzNjE5ZmNiMWE4YTMyMiA4OT" \ "M4NWYyODg2OTA3NzA1ZWZmZGM4MjY1NmYxNmFhOTI4NDAzNjc1" \ "IDJiMmIzN2VkNmU5YjQ3MGNmMGVlMjljNzI2YzFjZjRhZGFiYT" \ "FlMmM=" return random.choice(base64.b64decode(dts).split()) SORT_ORDER = enum(REPO=0, FEED=1, PLUGIN=2, PROGRAM=3, SKIN=4, SERVICE=5, SCRIPT=6, 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):
along with this program. If not, see <http://www.gnu.org/licenses/>. *''' import xbmcgui from commoncore.enum 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):