def resolve_url(self, raw_url): resolved_url = '' host = self.get_domain_from_url(raw_url) if host not in self.get_domains(): return '' from commoncore.dispatcher import WeightedDispatcher dispatcher = WeightedDispatcher() @dispatcher.register(kodi.get_setting('premiumize_priority', ADDON_ID), [raw_url]) def pm_resolver(raw_url): if host not in self.premiumize_hosts: return '' try: response = premiumize.get_download(raw_url) return response['result']['location'] except: return '' @dispatcher.register(kodi.get_setting('realdebrid_priority', ADDON_ID), [raw_url]) def rd_resolver(raw_url): if host not in self.realdebrid_hosts: return '' try: return realdebrid.resolve_url(raw_url) except: return '' kodi.open_busy_dialog() try: resolved_url = dispatcher.run() except: kodi.close_busy_dialog() kodi.close_busy_dialog() return resolved_url
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) update_count += 1 elif source['type'] == SOURCES.REPO: full_name = sources['user'] + '/' + sources['repo'] xml_str = github.find_xml(full_name) xml = BeautifulSoup(xml_str) addon = xml.find('addon') current_version = kodi.get_addon(addon_id).getAddonInfo('version') if LooseVersion(addon['version']) > LooseVersion(current_version): GitHub_Installer(addon_id, source['url'], full_name, kodi.vfs.join("special://home", "addons"), True, quiet) update_count += 1 if not quiet: kodi.close_busy_dialog() if update_count > 0: kodi.notify("Update complete",'Some addons may require restarting kodi.') else: kodi.notify("Update complete",'No updates found.')
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) update_count += 1 elif source['type'] == SOURCES.REPO: full_name = sources['user'] + '/' + sources['repo'] xml_str = github.find_xml(full_name) xml = BeautifulSoup(xml_str) addon = xml.find('addon') current_version = kodi.get_addon(addon_id).getAddonInfo('version') if LooseVersion(addon['version']) > LooseVersion(current_version): GitHub_Installer(addon_id, source['url'], full_name, kodi.vfs.join("special://home", "addons"), True, quiet) update_count += 1 if not quiet: kodi.close_busy_dialog() if update_count > 0: kodi.notify("Update complete",'Some addons may require restarting kodi.') else: kodi.notify("Update complete",'No updates found.')
def resolve_url(self, raw_url): resolved_url = '' kodi.open_busy_dialog() hash = self.get_hash_from_magnet(raw_url) if not hash: hash = self.get_hash_from_url(raw_url) if hash: kodi.set_property('Playback.Hash', hash) else: kodi.clear_property('Playback.Hash') attempt = 0 attempts = 5 try: response = premiumize.create_transfer(raw_url) id = response['id'] except: premiumize.clear_transfers() response = premiumize.create_transfer(raw_url) id = response['id'] try: while attempt < attempts: folder_id = False file_id = False target_folder_id = False kodi.log("Resolve Attempt %s" % attempt) temp = premiumize.list_transfers() for t in temp['transfers']: if t['id'] == id and t['status'] == 'finished': target_folder_id = t['target_folder_id'] folder_id = t['folder_id'] file_id = t['file_id'] break if folder_id: response = premiumize.list_folder(folder_id) resolved_url = premiumize.get_folder_stream(response) break if target_folder_id: response = premiumize.list_folder(target_folder_id) resolved_url = premiumize.get_folder_stream(response) break attempt += 1 kodi.sleep(150) except: kodi.close_busy_dialog() kodi.close_busy_dialog() return resolved_url
def resolve_url(self, raw_url): from commoncore.dispatcher import WeightedDispatcher resolved_url = '' hash = self.get_hash(raw_url) kodi.set_property('Playback.Hash', hash) dispatcher = WeightedDispatcher() @dispatcher.register(kodi.get_setting('premiumize_priority', ADDON_ID), [raw_url]) def premiumize_resolver(raw_url): resolved_url = '' if kodi.get_setting('premiumize_enable', ADDON_ID) != 'true': return resolved_url attempt = 0 attempts = 5 try: response = premiumize.create_transfer(raw_url) id = response['id'] except: premiumize.clear_transfers() response = premiumize.create_transfer(raw_url) id = response['id'] try: while attempt < attempts: folder_id = False file_id = False target_folder_id = False kodi.log("Resolve Attempt %s" % attempt) temp = premiumize.list_transfers() for t in temp['transfers']: if t['id'] == id and t['status'] == 'finished': if 'target_folder_id' in t: target_folder_id = t['target_folder_id'] if 'folder_id' in t: folder_id = t['folder_id'] if 'file_id' in t: file_id = t['file_id'] break if file_id: response = premiumize.item_details(file_id) resolved_url = response['stream_link'] kodi.set_property('Playback.Resolver', 'premiumize') kodi.set_property('Playback.ID', file_id) return resolved_url if folder_id: response = premiumize.list_folder(folder_id) resolved_url = premiumize.get_folder_stream(response) kodi.set_property('Playback.Resolver', 'premiumize') kodi.set_property('Playback.ID', folder_id) return resolved_url if target_folder_id: response = premiumize.list_folder(target_folder_id) resolved_url = premiumize.get_folder_stream(response) kodi.set_property('Playback.Resolver', 'premiumize') kodi.set_property('Playback.ID', target_folder_id) return resolved_url attempt += 1 kodi.sleep(150) except: pass return resolved_url @dispatcher.register(kodi.get_setting('realdebrid_priority', ADDON_ID), [raw_url]) def realdebrid_resolver(raw_url): resolved_url = '' if kodi.get_setting('realdebrid_enable', ADDON_ID) != 'true': return resolved_url response = realdebrid.add_torrent(raw_url) try: torrent_id = response['id'] info = realdebrid.get_torrent_info(torrent_id) file_id = realdebrid.get_stream_file(info['files']) if not file_id: return realdebrid.select_torrent_files(torrent_id, file_id) kodi.sleep(500) info = realdebrid.get_torrent_info(torrent_id) raw_url = info['links'][0] kodi.set_property('Playback.Resolver', 'realdebrid') kodi.set_property('Playback.ID', torrent_id) resolved_url = realdebrid.resolve_url(raw_url) except: pass return resolved_url kodi.open_busy_dialog() try: resolved_url = dispatcher.run() except Exception, e: kodi.log(e) kodi.close_busy_dialog()
def __init__(self, addon_id, url, full_name, destination, master=False, quiet=False, installed_list=[], batch=False): self.installed_list = installed_list self.quiet = quiet self.batch=batch if not self.quiet: 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.install_addon(addon_id, url, full_name, master) completed = list(reversed(self.completed)) if not quiet: pb = kodi.ProgressBar() pb.new('Enabling Addons', len(completed)+1) pb.update_subheading('Building Addon List') kodi.run_command("XBMC.UpdateLocalAddons()") kodi.sleep(500) for addon_id in completed: if not quiet: #percent = 100* (completed.index(addon_id) / len(completed)) #pb.update(percent, "Enabling Addons", addon_id, '') pb.next(addon_id) kodi.sleep(100) self.enable_addon(addon_id) if not quiet: pb.next("Looking for Updates", "") kodi.sleep(500) kodi.run_command('XBMC.UpdateAddonRepos') # Enable installed addons if not self.quiet: pb.close() kodi.close_busy_dialog() if self.install_error: kodi.notify("Install failed", self._addon_id) else: kodi.notify("Install complete", self._addon_id)
def __init__(self, addon_id, url, full_name, destination, master=False, quiet=False, installed_list=[], batch=False): self.installed_list = installed_list self.quiet = quiet self.batch=batch if not self.quiet: 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.install_addon(addon_id, url, full_name, master) completed = list(reversed(self.completed)) if not quiet: pb = kodi.ProgressBar() pb.new('Enabling Addons', len(completed)+1) pb.update_subheading('Building Addon List') kodi.run_command("XBMC.UpdateLocalAddons()") kodi.sleep(500) for addon_id in completed: if not quiet: #percent = 100* (completed.index(addon_id) / len(completed)) #pb.update(percent, "Enabling Addons", addon_id, '') pb.next(addon_id) kodi.sleep(100) self.enable_addon(addon_id) if not quiet: pb.next("Looking for Updates", "") kodi.sleep(500) kodi.run_command('XBMC.UpdateAddonRepos') # Enable installed addons if not self.quiet: pb.close() kodi.close_busy_dialog() if self.install_error: kodi.notify("Install failed", self._addon_id) else: kodi.notify("Install complete", self._addon_id)