def __init__(self): profile_path = Utils.unicode( KodiUtils.translate_path(KodiUtils.get_addon_info('profile'))) ini_path = os.path.join(profile_path, 'onedrive.ini') if os.path.exists(ini_path): config = ConfigParser() account_manager = AccountManager(profile_path) config.read(ini_path) for driveid in config.sections(): Logger.notice('Migrating drive %s...' % driveid) account = {'id': driveid, 'name': config.get(driveid, 'name')} account['drives'] = [{ 'id': driveid, 'name': '', 'type': 'migrated' }] account['access_tokens'] = { 'access_token': config.get(driveid, 'access_token'), 'refresh_token': config.get(driveid, 'refresh_token'), 'expires_in': 0, 'date': 0 } try: account_manager.add_account(account) except Exception as e: raise UIException(32021, e) os.remove(ini_path) KodiUtils.set_addon_setting('migrated', 'true')
def do_GET(self): Logger.debug(self.path) data = self.path.split('/') code = 307 headers = {} content = Utils.get_file_buffer() if len(data) > 4 and data[1] == self.server.service.name: try: driveid = data[2] provider = self.server.data() account_manager = AccountManager( self.server.service.profile_path) provider.configure(account_manager, driveid) item = provider.get_item(item_driveid=data[3], item_id=data[4], include_download_info=True) headers['location'] = item['download_info']['url'] except Exception as e: httpex = ExceptionUtils.extract_exception(e, HTTPError) if httpex: code = httpex.code else: code = 500 ErrorReport.handle_exception(e) content.write(ExceptionUtils.full_stacktrace(e)) else: code = 404 self.write_response(code, content=content, headers=headers)
def __init__(self, request, client_address, server): self._system_monitor = KodiUtils.get_system_monitor() self._account_manager = AccountManager(server.service.profile_path) self._addonid = KodiUtils.get_addon_info('id') expiration = datetime.timedelta(minutes=KodiUtils.get_cache_expiration_time()) self._page_cache = Cache(self._addonid, 'page', expiration) self._children_cache = Cache(self._addonid, 'children', expiration) self._items_cache = Cache(self._addonid, 'items', expiration) BaseHandler.__init__(self, request, client_address, server)
def __init__(self, provider_class): self.abort = False self._system_monitor = KodiUtils.get_system_monitor() self.provider = provider_class() self.addonid = KodiUtils.get_addon_info('id') self._profile_path = Utils.unicode(KodiUtils.translate_path(KodiUtils.get_addon_info('profile'))) self._startup_type = Utils.str(ExportScheduleDialog._startup_type) self.export_manager = ExportManager(self._profile_path) self._account_manager = AccountManager(self._profile_path) self._video_file_extensions = KodiUtils.get_supported_media("video") self._audio_file_extensions = KodiUtils.get_supported_media("music")
def __init__(self): self._addon = xbmcaddon.Addon() self._addonid = self._addon.getAddonInfo('id') self._addon_name = self._addon.getAddonInfo('name') self._addon_url = sys.argv[0] self._addon_version = self._addon.getAddonInfo('version') self._common_addon_id = 'script.module.clouddrive.common' self._common_addon = xbmcaddon.Addon(self._common_addon_id) self._common_addon_version = self._common_addon.getAddonInfo('version') self._dialog = xbmcgui.Dialog() self._profile_path = Utils.unicode( xbmc.translatePath(self._addon.getAddonInfo('profile'))) self._progress_dialog = DialogProgress(self._addon_name) self._progress_dialog_bg = DialogProgressBG(self._addon_name) self._export_progress_dialog_bg = DialogProgressBG(self._addon_name) self._system_monitor = xbmc.Monitor() self._account_manager = AccountManager(self._profile_path) self._home_window = xbmcgui.Window(10000) if len(sys.argv) > 1: self._addon_handle = int(sys.argv[1]) self._addon_params = urlparse.parse_qs(sys.argv[2][1:]) for param in self._addon_params: self._addon_params[param] = self._addon_params.get(param)[0] self._content_type = Utils.get_safe_value(self._addon_params, 'content_type') if not self._content_type: wid = xbmcgui.getCurrentWindowId() if wid == 10005 or wid == 10500 or wid == 10501 or wid == 10502: self._content_type = 'audio' elif wid == 10002: self._content_type = 'image' else: self._content_type = 'video' xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_FILE) xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_SIZE) xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DATE) xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DURATION)
def __init__(self): self._addon = KodiUtils.get_addon() self._addonid = self._addon.getAddonInfo('id') self._addon_name = self._addon.getAddonInfo('name') self._addon_url = sys.argv[0] self._addon_version = self._addon.getAddonInfo('version') self._common_addon_id = 'script.module.clouddrive.common' self._common_addon = KodiUtils.get_addon(self._common_addon_id) self._common_addon_version = self._common_addon.getAddonInfo('version') self._dialog = xbmcgui.Dialog() self._profile_path = Utils.unicode(KodiUtils.translate_path(self._addon.getAddonInfo('profile'))) self._progress_dialog = DialogProgress(self._addon_name) self._progress_dialog_bg = DialogProgressBG(self._addon_name) self._system_monitor = KodiUtils.get_system_monitor() self._account_manager = AccountManager(self._profile_path) self._pin_dialog = None self.provider = GoogleDrive()
def __init__(self, provider_class): self.abort = False self._system_monitor = KodiUtils.get_system_monitor() self.provider = provider_class() self.addonid = KodiUtils.get_addon_info('id') self._addon_name = KodiUtils.get_addon_info('name') self._common_addon_id = 'script.module.clouddrive.common' self._common_addon = KodiUtils.get_addon(self._common_addon_id) self._profile_path = Utils.unicode( KodiUtils.translate_path(KodiUtils.get_addon_info('profile'))) self._startup_type = Utils.str(ExportScheduleDialog._startup_type) self.export_manager = ExportManager(self._profile_path) self._account_manager = AccountManager(self._profile_path) self._video_file_extensions = [ x for x in KodiUtils.get_supported_media("video") if x not in ('', 'zip') ] self._audio_file_extensions = KodiUtils.get_supported_media("music") self._artwork_file_extensions = [ 'back', 'banner', 'characterart', 'clearart', 'clearlogo', 'discart', 'fanart', 'keyart', 'landscape', 'poster', 'spine', 'thumb', 'folder', 'cover', 'animatedposter', 'animatedfanart' ] self._export_progress_dialog_bg = DialogProgressBG(self._addon_name)