wrjlewis / notion-search-alfred-workflow

An Alfred workflow to search Notion with instant results
GNU General Public License v3.0
825 stars 41 forks source link

Opening in Notion app #7

Closed bradydjohnson closed 4 years ago

bradydjohnson commented 4 years ago

Re: this tip:

If you prefer using the Mac app of Notion, just replace https://www.notion.so with notion://www.notion.so/ in the workflow script.

Where exactly in the script? In every instance of "https://www.notion.so"? Just the line beginning with "searchResultObject.link"?

#Call Notion

headers = {"Content-type": "application/json",
           "Cookie": cookie}
conn = httplib.HTTPSConnection("www.notion.so")
conn.request("POST", "/api/v3/search",
             buildNotionSearchQueryData(alfredQuery), headers)
response = conn.getresponse()
...

#Extract search results from notion response
searchResultList = []
searchResults = Payload(data)
...
    searchResultObject.link = "https://www.notion.so/" + searchResultObject.id.replace("-", "")
    searchResultList.append(searchResultObject)

...

items = {}
if not itemList:
    item = {}
    item["uid"] = 1
    item["type"] = "default"
    item["title"] = "No results - go to Notion homepage"
    item["arg"] = "https://www.notion.so/"
    itemList.append(item)
items["items"] = itemList
items_json = json.dumps(items)

sys.stdout.write(items_json)
wrjlewis commented 4 years ago

(Thanks to an answer from the Alfred forum):

Search for the words (there should be 2 instances)

https://www.notion.so/

Replace the text with:

notion://www.notion.so/

johnathanz commented 4 years ago

Added a pull request to do this + do Notion "Search in Title" only (invoke by "nt") https://github.com/wrjlewis/notion-search-alfred-workflow/pull/8

Suggest close this issue on PR approval

wrjlewis commented 4 years ago

I had to refactor the way the script works pretty heavily, to allow for easier debugging, version control, and diffs. The code now lives in a python script separately and I'm using the releases feature on Github. For this particular issue above, you'll find a new env variable that controls whether the workflow uses the notion desktop client or the web version.