diff --git a/plugin/__init__.py b/plugin/__init__.py index 8f0141f..8f95923 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -1111,6 +1111,28 @@ class AnkiConnect: return models + @util.api() + def findModelsById(self, modelIds): + models = [] + for id in modelIds: + model = self.collection().models.get(id) + if model is None: + raise Exception("model was not found: {}".format(id)) + else: + models.append(model) + return models + + @util.api() + def findModelsByName(self, modelNames): + models = [] + for name in modelNames: + model = self.collection().models.byName(name) + if model is None: + raise Exception("model was not found: {}".format(name)) + else: + models.append(model) + return models + @util.api() def modelNameFromId(self, modelId): model = self.collection().models.get(modelId)