EdwinW Posted June 22, 2023 Share Posted June 22, 2023 This is the address of the project : https://github.com/huamang/SiYuan-Search-workflow This is the specific log of debug [16:04:23.260] SiYuan[Script Filter] Queuing argument 's' [16:04:23.384] SiYuan[Script Filter] Script with argv '(null)' finished [16:04:23.389] ERROR: SiYuan[Script Filter] Code 1: Traceback (most recent call last): File "/Users/edwinwang/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A73C9D10-C775-4B59-9699-E72DE2DBFE81/search.py", line 57, in <module> main() File "/Users/edwinwang/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A73C9D10-C775-4B59-9699-E72DE2DBFE81/search.py", line 53, in main parseRes(resJson) File "/Users/edwinwang/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A73C9D10-C775-4B59-9699-E72DE2DBFE81/search.py", line 37, in parseRes for block in resJson["data"]["blocks"]: KeyError: 'data' This is the specific content of the script import json import sys import requests def fullTextSearchBlock(q): searchJson = {} searchJson["query"] = q searchJson["method"] = 0 type = {} type["blockquote"] = True type["codeBlock"] = True type["document"] = True type["embedBlock"] = True type["heading"] = True type["htmlBlock"] = True type["list"] = True type["listItem"] = True type["mathBlock"] = True type["paragraph"] = True type["superBlock"] = True type["table"] = True searchJson["type"] = type searchJson["path"] = [] searchJson["groupBy"] = 0 searchJson["orderBy"] = 0 data = json.dumps(searchJson) url = "http://127.0.0.1:6806/api/search/fullTextSearchBlock" res = requests.post(url, data) resJson = json.loads(res.text) return resJson def parseRes(resJson): itemList = [] uid = 1 for block in resJson["data"]["blocks"]: item = {} item["uid"] = uid item["title"] = block["content"].replace("<mark>", "").replace("</mark>", "")[:50] item["subtitle"] = block["hPath"] item["arg"] = "siyuan://blocks/" + block["id"] itemList.append(item) uid += 1 items = {} items["items"] = itemList items_json = json.dumps(items) sys.stdout.write(items_json) def main(): alfredQuery = str(sys.argv[1]) resJson = fullTextSearchBlock(alfredQuery) parseRes(resJson) if __name__ == '__main__': main() Link to comment
vitor Posted June 22, 2023 Share Posted June 22, 2023 (edited) This is already being answered in the official repository. That’s the correct place to post, the author is the one who can best help you. Edited June 22, 2023 by vitor Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now