def __init__(self): # Initialize this type super(MovieBase, self).__init__() self.initType() addApiView('movie.add', self.addView, docs = { 'desc': 'Add new movie to the wanted list', 'return': {'type': 'object', 'example': """{ 'success': True, 'movie': object }"""}, 'params': { 'identifier': {'desc': 'IMDB id of the movie your want to add.'}, 'profile_id': {'desc': 'ID of quality profile you want the add the movie in. If empty will use the default profile.'}, 'force_readd': {'desc': 'Force re-add even if movie already in wanted or manage. Default: True'}, 'category_id': {'desc': 'ID of category you want the add the movie in. If empty will use no category.'}, 'title': {'desc': 'Movie title to use for searches. Has to be one of the titles returned by movie.search.'}, } }) addApiView('movie.edit', self.edit, docs = { 'desc': 'Add new movie to the wanted list', 'params': { 'id': {'desc': 'Movie ID(s) you want to edit.', 'type': 'int (comma separated)'}, 'profile_id': {'desc': 'ID of quality profile you want the edit the movie to.'}, 'category_id': {'desc': 'ID of category you want the add the movie in. If empty will use no category.'}, 'default_title': {'desc': 'Movie title to use for searches. Has to be one of the titles returned by movie.search.'}, } }) addEvent('movie.add', self.add) addEvent('movie.update', self.update) addEvent('movie.update_release_dates', self.updateReleaseDate)
def __init__(self): fireEvent('scheduler.interval', identifier = 'manage.update_library', handle = self.updateLibrary, hours = 2) addEvent('manage.update', self.updateLibrary) addEvent('manage.diskspace', self.getDiskSpace) # Add files after renaming def after_rename(message = None, group = None): if not group: group = {} return self.scanFilesToLibrary(folder = group['destination_dir'], files = group['renamed_files'], release_download = group['release_download']) addEvent('renamer.after', after_rename, priority = 110) addApiView('manage.update', self.updateLibraryView, docs = { 'desc': 'Update the library by scanning for new movies', 'params': { 'full': {'desc': 'Do a full update or just recently changed/added movies.'}, } }) addApiView('manage.progress', self.getProgress, docs = { 'desc': 'Get the progress of current manage update', 'return': {'type': 'object', 'example': """{ 'progress': False || object, total & to_go, }"""}, }) if not Env.get('dev') and self.conf('startup_scan'): addEvent('app.load', self.updateLibraryQuick) addEvent('app.load', self.setCrons) # Enable / disable interval addEvent('setting.save.manage.library_refresh_interval.after', self.setCrons)
def __init__(self): addEvent('quality.all', self.all) addEvent('quality.single', self.single) addEvent('quality.guess', self.guess) addEvent('quality.pre_releases', self.preReleases) addEvent('quality.order', self.getOrder) addEvent('quality.ishigher', self.isHigher) addEvent('quality.isfinish', self.isFinish) addEvent('quality.fill', self.fill) addApiView('quality.size.save', self.saveSize) addApiView('quality.list', self.allView, docs = { 'desc': 'List all available qualities', 'return': {'type': 'object', 'example': """{ 'success': True, 'list': array, qualities }"""} }) addEvent('app.initialize', self.fill, priority = 10) addEvent('app.test', self.doTest) self.order = [] self.addOrder()
def __init__(self): super(Trakt, self).__init__() addApiView('automation.trakt.auth_url', self.getAuthorizationUrl) addApiView('automation.trakt.credentials', self.getCredentials) fireEvent('schedule.interval', 'updater.check', self.refreshToken, hours = 24) addEvent('app.load', self.refreshToken)
def __init__(self): addApiView('media.refresh', self.refresh, docs = { 'desc': 'Refresh a any media type by ID', 'params': { 'id': {'desc': 'Movie, Show, Season or Episode ID(s) you want to refresh.', 'type': 'int (comma separated)'}, } }) addApiView('media.list', self.listView, docs = { 'desc': 'List media', 'params': { 'type': {'type': 'string', 'desc': 'Media type to filter on.'}, 'status': {'type': 'array or csv', 'desc': 'Filter media by status. Example:"active,done"'}, 'release_status': {'type': 'array or csv', 'desc': 'Filter media by status of its releases. Example:"snatched,available"'}, 'limit_offset': {'desc': 'Limit and offset the media list. Examples: "50" or "50,30"'}, 'starts_with': {'desc': 'Starts with these characters. Example: "a" returns all media starting with the letter "a"'}, 'search': {'desc': 'Search media title'}, }, 'return': {'type': 'object', 'example': """{ 'success': True, 'empty': bool, any media returned or not, 'media': array, media found, }"""} }) addApiView('media.get', self.getView, docs = { 'desc': 'Get media by id', 'params': { 'id': {'desc': 'The id of the media'}, } }) addApiView('media.delete', self.deleteView, docs = { 'desc': 'Delete a media from the wanted list', 'params': { 'id': {'desc': 'Media ID(s) you want to delete.', 'type': 'int (comma separated)'}, 'delete_from': {'desc': 'Delete media from this page', 'type': 'string: all (default), wanted, manage'}, } }) addApiView('media.available_chars', self.charView) addEvent('app.load', self.addSingleRefreshView, priority = 100) addEvent('app.load', self.addSingleListView, priority = 100) addEvent('app.load', self.addSingleCharView, priority = 100) addEvent('app.load', self.addSingleDeleteView, priority = 100) addEvent('app.load', self.cleanupFaults) addEvent('media.get', self.get) addEvent('media.with_status', self.withStatus) addEvent('media.with_identifiers', self.withIdentifiers) addEvent('media.list', self.list) addEvent('media.delete', self.delete) addEvent('media.restatus', self.restatus) addEvent('media.tag', self.tag) addEvent('media.untag', self.unTag)
def __init__(self): addEvent('download', self._download) addEvent('download.enabled', self._isEnabled) addEvent('download.enabled_protocols', self.getEnabledProtocol) addEvent('download.status', self._getAllDownloadStatus) addEvent('download.remove_failed', self._removeFailed) addEvent('download.pause', self._pause) addEvent('download.process_complete', self._processComplete) addApiView('download.%s.test' % self.getName().lower(), self._test)
def __init__(self): addEvent('notify.%s' % self.getName().lower(), self._notify) addApiView(self.testNotifyName(), self.test) # Attach listeners for listener in self.listen_to: if not listener in self.dont_listen_to: addEvent(listener, self.createNotifyHandler(listener))
def __init__(self): addApiView('suggestion.view', self.suggestView) addApiView('suggestion.ignore', self.ignoreView) def test(): time.sleep(1) self.suggestView() addEvent('app.load', test)
def __init__(self): addApiView('userscript.get/(.*)/(.*)', self.getUserScript, static = True) addApiView('userscript', self.iFrame) addApiView('userscript.add_via_url', self.getViaUrl) addApiView('userscript.includes', self.getIncludes) addApiView('userscript.bookmark', self.bookmark) addEvent('userscript.get_version', self.getVersion) addEvent('app.test', self.doTest)
def addSingleDeleteView(self): for media_type in fireEvent('media.types', merge = True): tempDelete = lambda *args, **kwargs : self.deleteView(type = media_type, **kwargs) addApiView('%s.delete' % media_type, tempDelete, docs = { 'desc': 'Delete a ' + media_type + ' from the wanted list', 'params': { 'id': {'desc': 'Media ID(s) you want to delete.', 'type': 'int (comma separated)'}, 'delete_from': {'desc': 'Delete ' + media_type + ' from this page', 'type': 'string: all (default), wanted, manage'}, } })
def __init__(self): addEvent('file.download', self.download) addApiView('file.cache/(.*)', self.showCacheFile, static = True, docs = { 'desc': 'Return a file from the cp_data/cache directory', 'params': { 'filename': {'desc': 'path/filename of the wanted file'} }, 'return': {'type': 'file'} }) fireEvent('schedule.interval', 'file.cleanup', self.cleanup, hours = 24) addEvent('app.test', self.doSubfolderTest)
def __init__(self): addApiView('directory.list', self.view, docs = { 'desc': 'Return the directory list of a given directory', 'params': { 'path': {'desc': 'The directory to scan'}, 'show_hidden': {'desc': 'Also show hidden files'} }, 'return': {'type': 'object', 'example': """{ 'is_root': bool, //is top most folder 'parent': string, //parent folder of requested path 'home': string, //user home folder 'empty': bool, //directory is empty 'dirs': array, //directory names }"""} })
def __init__(self): addApiView('search', self.search, docs = { 'desc': 'Search the info in providers for a movie', 'params': { 'q': {'desc': 'The (partial) movie name you want to search for'}, 'type': {'desc': 'Search for a specific media type. Leave empty to search all.'}, }, 'return': {'type': 'object', 'example': """{ 'success': True, 'movies': array, 'show': array, etc }"""} }) addEvent('app.load', self.addSingleSearches)
def __init__(self): addApiView('settings', self.view, docs = { 'desc': 'Return the options and its values of settings.conf. Including the default values and group ordering used on the settings page.', 'return': {'type': 'object', 'example': """{ // objects like in __init__.py of plugin "options": { "moovee" : { "groups" : [{ "description" : "SD movies only", "name" : "#alt.binaries.moovee", "options" : [{ "default" : false, "name" : "enabled", "type" : "enabler" }], "tab" : "providers" }], "name" : "moovee" } }, // object structured like settings.conf "values": { "moovee": { "enabled": false } } }"""} }) addApiView('settings.save', self.saveView, docs = { 'desc': 'Save setting to config file (settings.conf)', 'params': { 'section': {'desc': 'The section name in settings.conf'}, 'name': {'desc': 'The option name'}, 'value': {'desc': 'The value you want to save'}, } }) addEvent('database.setup', self.databaseSetup) self.file = None self.p = None self.log = None
def addSingleListView(self): for media_type in fireEvent('media.types', merge = True): tempList = lambda *args, **kwargs : self.listView(type = media_type, **kwargs) addApiView('%s.list' % media_type, tempList, docs = { 'desc': 'List media', 'params': { 'status': {'type': 'array or csv', 'desc': 'Filter ' + media_type + ' by status. Example:"active,done"'}, 'release_status': {'type': 'array or csv', 'desc': 'Filter ' + media_type + ' by status of its releases. Example:"snatched,available"'}, 'limit_offset': {'desc': 'Limit and offset the ' + media_type + ' list. Examples: "50" or "50,30"'}, 'starts_with': {'desc': 'Starts with these characters. Example: "a" returns all ' + media_type + 's starting with the letter "a"'}, 'search': {'desc': 'Search ' + media_type + ' title'}, }, 'return': {'type': 'object', 'example': """{ 'success': True, 'empty': bool, any """ + media_type + """s returned or not, 'media': array, media found, }"""} })
def __init__(self): addEvent('searcher.protocols', self.getSearchProtocols) addEvent('searcher.contains_other_quality', self.containsOtherQuality) addEvent('searcher.correct_3d', self.correct3D) addEvent('searcher.correct_year', self.correctYear) addEvent('searcher.correct_name', self.correctName) addEvent('searcher.correct_words', self.correctWords) addEvent('searcher.search', self.search) addApiView('searcher.full_search', self.searchAllView, docs = { 'desc': 'Starts a full search for all media', }) addApiView('searcher.progress', self.getProgressForAll, docs = { 'desc': 'Get the progress of all media searches', 'return': {'type': 'object', 'example': """{ 'movie': False || object, total & to_go, 'show': False || object, total & to_go, }"""}, })
def __init__(self): addApiView('category.save', self.save) addApiView('category.save_order', self.saveOrder) addApiView('category.delete', self.delete) addApiView('category.list', self.allView, docs = { 'desc': 'List all available categories', 'return': {'type': 'object', 'example': """{ 'success': True, 'categories': array, categories }"""} }) addEvent('category.all', self.all)
def __init__(self): addApiView('release.manual_download', self.manualDownload, docs = { 'desc': 'Send a release manually to the downloaders', 'params': { 'id': {'type': 'id', 'desc': 'ID of the release object in release-table'} } }) addApiView('release.delete', self.deleteView, docs = { 'desc': 'Delete releases', 'params': { 'id': {'type': 'id', 'desc': 'ID of the release object in release-table'} } }) addApiView('release.ignore', self.ignore, docs = { 'desc': 'Toggle ignore, for bad or wrong releases', 'params': { 'id': {'type': 'id', 'desc': 'ID of the release object in release-table'} } }) addEvent('release.add', self.add) addEvent('release.download', self.download) addEvent('release.try_download_result', self.tryDownloadResult) addEvent('release.create_from_search', self.createFromSearch) addEvent('release.delete', self.delete) addEvent('release.clean', self.clean) addEvent('release.update_status', self.updateStatus) addEvent('release.with_status', self.withStatus) addEvent('release.for_media', self.forMedia) # Clean releases that didn't have activity in the last week addEvent('app.load', self.cleanDone, priority = 1000) fireEvent('schedule.interval', 'movie.clean_releases', self.cleanDone, hours = 12)
def __init__(self): if Env.get('desktop'): self.updater = DesktopUpdater() elif os.path.isdir(os.path.join(Env.get('app_dir'), '.git')): git_default = 'git' git_command = self.conf('git_command', default = git_default) git_command = git_command if git_command != git_default and (os.path.isfile(git_command) or re.match('^[a-zA-Z0-9_/\.\-]+$', git_command)) else git_default self.updater = GitUpdater(git_command) else: self.updater = SourceUpdater() addEvent('app.load', self.logVersion, priority = 10000) addEvent('app.load', self.setCrons) addEvent('updater.info', self.info) addApiView('updater.info', self.info, docs = { 'desc': 'Get updater information', 'return': { 'type': 'object', 'example': """{ 'last_check': "last checked for update", 'update_version': "available update version or empty", 'version': current_cp_version }"""} }) addApiView('updater.update', self.doUpdateView) addApiView('updater.check', self.checkView, docs = { 'desc': 'Check for available update', 'return': {'type': 'see updater.info'} }) addEvent('setting.save.updater.enabled.after', self.setCrons)
def __init__(self): super(MovieSearcher, self).__init__() addEvent('movie.searcher.all', self.searchAll) addEvent('movie.searcher.all_view', self.searchAllView) addEvent('movie.searcher.single', self.single) addEvent('movie.searcher.try_next_release', self.tryNextRelease) addEvent('movie.searcher.could_be_released', self.couldBeReleased) addEvent('searcher.correct_release', self.correctRelease) addEvent('searcher.get_search_title', self.getSearchTitle) addApiView('movie.searcher.try_next', self.tryNextReleaseView, docs = { 'desc': 'Marks the snatched results as ignored and try the next best release', 'params': { 'media_id': {'desc': 'The id of the media'}, }, }) addApiView('movie.searcher.full_search', self.searchAllView, docs = { 'desc': 'Starts a full search for all wanted movies', }) addApiView('movie.searcher.progress', self.getProgress, docs = { 'desc': 'Get the progress of current full search', 'return': {'type': 'object', 'example': """{ 'progress': False || object, total & to_go, }"""}, }) if self.conf('run_on_launch'): addEvent('app.load', self.searchAll)
def __init__(self): addApiView('downloader.putio.getfrom', self.getFromPutio, docs = { 'desc': 'Allows you to download file from prom Put.io', }) addApiView('downloader.putio.auth_url', self.getAuthorizationUrl) addApiView('downloader.putio.credentials', self.getCredentials) addEvent('putio.download', self.putioDownloader) return super(PutIO, self).__init__()
def __init__(self): addEvent('profile.all', self.all) addEvent('profile.default', self.default) addApiView('profile.save', self.save) addApiView('profile.save_order', self.saveOrder) addApiView('profile.delete', self.delete) addApiView('profile.list', self.allView, docs = { 'desc': 'List all available profiles', 'return': {'type': 'object', 'example': """{ 'success': True, 'list': array, profiles }"""} }) addEvent('app.initialize', self.fill, priority = 90) addEvent('app.load', self.forceDefaults, priority = 110)
def __init__(self): addEvent('library.title', self.title) addEvent('library.related', self.related) addEvent('library.tree', self.tree) addEvent('library.root', self.root) addApiView('library.query', self.queryView) addApiView('library.related', self.relatedView) addApiView('library.tree', self.treeView)
def __init__(self): addApiView('app.shutdown', self.shutdown, docs = { 'desc': 'Shutdown the app.', 'return': {'type': 'string: shutdown'} }) addApiView('app.restart', self.restart, docs = { 'desc': 'Restart the app.', 'return': {'type': 'string: restart'} }) addApiView('app.available', self.available, docs = { 'desc': 'Check if app available.' }) addApiView('app.version', self.versionView, docs = { 'desc': 'Get version.' }) addEvent('app.shutdown', self.shutdown) addEvent('app.restart', self.restart) addEvent('app.load', self.launchBrowser, priority = 1) addEvent('app.base_url', self.createBaseUrl) addEvent('app.api_url', self.createApiUrl) addEvent('app.version', self.version) addEvent('app.load', self.checkDataDir) addEvent('app.load', self.cleanUpFolders) addEvent('app.load.after', self.dependencies) addEvent('setting.save.core.password', self.md5Password) addEvent('setting.save.core.api_key', self.checkApikey) # Make sure we can close-down with ctrl+c properly if not Env.get('desktop'): self.signalHandler() # Set default urlopen timeout import socket socket.setdefaulttimeout(30) # Don't check ssl by default try: if sys.version_info >= (2, 7, 9): import ssl ssl._create_default_https_context = ssl._create_unverified_context except: log.debug('Failed setting default ssl context: %s', traceback.format_exc())
def __init__(self): addApiView('logging.get', self.get, docs = { 'desc': 'Get the full log file by number', 'params': { 'nr': {'desc': 'Number of the log to get.'} }, 'return': {'type': 'object', 'example': """{ 'success': True, 'log': [{ 'time': '03-12 09:12:59', 'type': 'INFO', 'message': 'Log message' }, ..], //Log file 'total': int, //Total log files available }"""} }) addApiView('logging.partial', self.partial, docs = { 'desc': 'Get a partial log', 'params': { 'type': {'desc': 'Type of log', 'type': 'string: all(default), error, info, debug'}, 'lines': {'desc': 'Number of lines. Last to first. Default 30'}, }, 'return': {'type': 'object', 'example': """{ 'success': True, 'log': [{ 'time': '03-12 09:12:59', 'type': 'INFO', 'message': 'Log message' }, ..] }"""} }) addApiView('logging.clear', self.clear, docs = { 'desc': 'Remove all the log files' }) addApiView('logging.log', self.log, docs = { 'desc': 'Log errors', 'params': { 'type': {'desc': 'Type of logging, default "error"'}, '**kwargs': {'type': 'object', 'desc': 'All other params will be printed in the log string.'}, } })
def __init__(self): super(CoreNotifier, self).__init__() addEvent('notify', self.notify) addEvent('notify.frontend', self.frontend) addApiView('notification.markread', self.markAsRead, docs = { 'desc': 'Mark notifications as read', 'params': { 'ids': {'desc': 'Notification id you want to mark as read. All if ids is empty.', 'type': 'int (comma separated)'}, }, }) addApiView('notification.list', self.listView, docs = { 'desc': 'Get list of notifications', 'params': { 'limit_offset': {'desc': 'Limit and offset the notification list. Examples: "50" or "50,30"'}, }, 'return': {'type': 'object', 'example': """{ 'success': True, 'empty': bool, any notification returned or not, 'notifications': array, notifications found, }"""} }) addNonBlockApiView('notification.listener', (self.addListener, self.removeListener)) addApiView('notification.listener', self.listener) fireEvent('schedule.interval', 'core.check_messages', self.checkMessages, hours = 12, single = True) fireEvent('schedule.interval', 'core.clean_messages', self.cleanMessages, seconds = 15, single = True) addEvent('app.load', self.clean) if not Env.get('dev'): addEvent('app.load', self.checkMessages) self.messages = [] self.listeners = [] self.m_lock = threading.Lock()
def addSingleSearches(self): for media_type in fireEvent('media.types', merge = True): addApiView('%s.search' % media_type, self.createSingleSearch(media_type))
def __init__(self): addApiView('charts.view', self.automationView) addApiView('charts.ignore', self.ignoreView)
def addSingleCharView(self): for media_type in fireEvent('media.types', merge = True): tempChar = lambda *args, **kwargs : self.charView(type = media_type, **kwargs) addApiView('%s.available_chars' % media_type, tempChar)
def addSingleRefreshView(self): for media_type in fireEvent('media.types', merge = True): addApiView('%s.refresh' % media_type, self.refresh)