Jump to content

Notion.so Instant Search Workflow


Recommended Posts

  • 1 month later...

What am I doing wrong? There seems to be a problem running python on Mac OS 12.3. I've tried everything I could find, but to no avail. 

[08:39:14.372] ERROR: Notion Search[Script Filter] Code 127: /Users/alexufa/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/E3FC2D3E-FD88-41E1-BDB8-E2830D9CDB49:1: command not found: python

 

 

 

╭─alexufa@Alexs-MacBook-Pro ~
╰─$ python --version                                                                                 127 ↵
zsh: command not found: python
╭─alexufa@Alexs-MacBook-Pro ~
╰─$ python3 --version                                                                                127 ↵
Python 3.10.2
╭─alexufa@Alexs-MacBook-Pro ~
╰─$
Link to comment
6 minutes ago, AlexUfa said:

What am I doing wrong? There seems to be a problem running python on Mac OS 12.3. I've tried everything I could find, but to no avail. 

[08:39:14.372] ERROR: Notion Search[Script Filter] Code 127: /Users/alexufa/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/E3FC2D3E-FD88-41E1-BDB8-E2830D9CDB49:1: command not found: python

 

 

 

╭─alexufa@Alexs-MacBook-Pro ~
╰─$ python --version                                                                                 127 ↵
zsh: command not found: python
╭─alexufa@Alexs-MacBook-Pro ~
╰─$ python3 --version                                                                                127 ↵
Python 3.10.2
╭─alexufa@Alexs-MacBook-Pro ~
╰─$


interesting and thanks for raising. Is macOS 12.3 still in beta?

 

I presume this is because python 2 is no longer shipped with Mac OS in this version as its deprecated. 
 

For the long term fix I’ll need to update the workflow to use python 3, but this is not shipped with Mac OS either as far as I’m aware and running python 3 in a terminal would prompt the user to install developer tools (containing python3). I need to investigate if that would mean the workflow wouldn’t work until a user did this, if anyone here knows please share? It would be great to have no additional steps when using this workflow. 
 

For a short term fix, install python 2 if possible. 

Link to comment
1 hour ago, wrjlewis said:


interesting and thanks for raising. Is macOS 12.3 still in beta?

 

I presume this is because python 2 is no longer shipped with Mac OS in this version as its deprecated. 
 

For the long term fix I’ll need to update the workflow to use python 3, but this is not shipped with Mac OS either as far as I’m aware and running python 3 in a terminal would prompt the user to install developer tools (containing python3). I need to investigate if that would mean the workflow wouldn’t work until a user did this, if anyone here knows please share? It would be great to have no additional steps when using this workflow. 
 

For a short term fix, install python 2 if possible. 

Thank you for your answer.

Yes, macOS 12.3 still in beta.

Ok. I'll tryto install python 2. But I'm afraid while I tried to install python 3 and solve this problem I did a lot of wrong settings ))

 

Link to comment
2 hours ago, wrjlewis said:

I presume this is because python 2 is no longer shipped with Mac OS in this version as its deprecated. 

 

That is exactly what’s happening.

 

2 hours ago, wrjlewis said:

I’ll need to update the workflow to use python 3, but this is not shipped with Mac OS either as far as I’m aware and running python 3 in a terminal would prompt the user to install developer tools (containing python3).

 

Again, correct.

 

2 hours ago, wrjlewis said:

I need to investigate if that would mean the workflow wouldn’t work until a user did this, if anyone here knows please share? It would be great to have no additional steps when using this workflow. 

 

Just invoking python3 is enough to trigger the prompt to install the CLI tools, and it will be a GUI prompt. A user with Homebrew installed will already have those installed.

 

Is that an additional step? Kind of, but it’s a one-time thing that is over in two clicks, it’s pretty straightforward, and not everyone will need to do it.

 

For reference, the version will be 3.8.9.

 

3 hours ago, wrjlewis said:

For a short term fix, install python 2 if possible.

 

That won’t work for the current state of the Workflow. I mean, they can install Python 2 but not to the location where it was because that’s protected. You have to at least expand the PATH in the Workflow before calling the script:


export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"

 

To install Python 2, @AlexUfa could install Homebrew, then:

 

export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
eval "$(brew shellenv)"
brew install pyenv
pyenv install 2.7.18
ln -s "${HOME}/.pyenv/versions/2.7.18/bin/python2.7" "${HOMEBREW_PREFIX}/bin/python"


That installs pyenv (a Python version manager), then the latest Python 2, then links it to the Homebrew prefix. They could also try the old Homebrew formula, but that won’t work on Apple Silicon without modification.

 

1 hour ago, AlexUfa said:

Yes, macOS 12.3 still in beta.

 

I highly recommend you avoid installing beta operating systems (especially macOS) if you’re not at ease debugging and fixing these kinds of issues on your own. Beta OSs are unstable and things stop working all the time.

 

1 hour ago, AlexUfa said:

But I'm afraid while I tried to install python 3 and solve this problem I did a lot of wrong settings

 

Plus, you get into those types of situations. You can’t get out of it by installing Python 3, because it’s incompatible with Python 2 scripts.

 

Naturally, if you want things to break because what you care is the experimentation, more power to you!

Link to comment

@vitor Thank you for your comprehensive answer! Yes, I agree that I have little experience in solving similar problems. But how can I learn something new without experimenting? Regarding this workflow - it looks like I got all exceptions together - macOS 12.3 Beta on the M1 pro.  think the right approach would be to learn the notion api. Thanks again for the reply! 

Link to comment
On 2/1/2022 at 6:16 AM, AlexUfa said:

@vitor Thank you for your comprehensive answer! Yes, I agree that I have little experience in solving similar problems. But how can I learn something new without experimenting? Regarding this workflow - it looks like I got all exceptions together - macOS 12.3 Beta on the M1 pro.  think the right approach would be to learn the notion api. Thanks again for the reply! 

 

New version (including a migration to Python3) available here:

 

https://github.com/wrjlewis/notion-search-alfred-workflow/releases/latest/download/Notion.Search.alfredworkflow
 

** Recently Viewed Pages ** Your most recently viewed notion pages are shown when triggering the workflow. Simply type the 'ns' keyword to start the workflow, as you would before you search, and your most recently viewed notion pages are displayed.
 

The workflow has been migrated to Python3 - ensuring compatibility with future versions of MacOS: "Python 2.7 was removed from macOS [12.3]. Developers should use Python 3 or an alternative language instead. (39795874)"
 

Fixed issue with no results in certain circumstances with collections/dbs

Fixed issue with null highlight on non-page elements - thanks to @ymszzq

Fixed issue retrieving and displaying notion icons in results, due to change in internal notion APIs

Fixed issue where externally hosted icons wouldn't show in results

Slightly better error handling when no results are returned

Link to comment
  • 2 weeks later...

Thank for your super useful workflow, I can't live anymore without it.

It's used to work until a couple of days ago, but now I get this error

  File "notion.py", line 198, in <module>
    for x in searchResults.pages:
AttributeError: 'Payload' object has no attribute 'pages'

what could have happened?

Link to comment
4 minutes ago, Pinuz said:

Thank for your super useful workflow, I can't live anymore without it.

It's used to work until a couple of days ago, but now I get this error

  File "notion.py", line 198, in <module>
    for x in searchResults.pages:
AttributeError: 'Payload' object has no attribute 'pages'

what could have happened?

Hmmm this is interesting because a couple of people have reported this now. 
 

Can I check you have tried refreshing the cookie? 
 

Could you also try setting the env variable showRecentlyViewedPages to False and see if you can search afterwards? 
 

If that doesn’t work I think I’ll need to add some more logging of some kind, because I can’t replicate the error.

Link to comment
On 2/20/2022 at 11:58 PM, wrjlewis said:

Hmmm this is interesting because a couple of people have reported this now. 
 

Can I check you have tried refreshing the cookie? 
 

Could you also try setting the env variable showRecentlyViewedPages to False and see if you can search afterwards? 
 

If that doesn’t work I think I’ll need to add some more logging of some kind, because I can’t replicate the error.

 

Sorry for this late reply but for some reasons I haven't been notified about it.

 

Just refreshing the cookie works, thank you friend! 🙏

Link to comment
  • 1 month later...

Thanks for making this amazing workflow.
There was one thing I was uncomfortable with using this workflow. Works well when looking for notion documents written in English. However, the search for titles written in Korean did not work properly. I'm guessing it's probably an encoding issue.
Can anyone help me improve this workflow to work well for non-English documents?

Link to comment
  • 2 weeks later...

Hello everyone,

 

I managed to set up on my macbook pro the workflow but on my iMac I can't it working.

 

Notiong happens when I do a search with "ns xxxx".

 

Thing is that the cookie doesn't seem right comparing to my macbook pro

"notion_check_cookie_consent=true; notion_experiment_device_id=..."

 

Any idea why ? thanks for help

Link to comment
27 minutes ago, SMN said:

Hello everyone,

 

I managed to set up on my macbook pro the workflow but on my iMac I can't it working.

 

Notiong happens when I do a search with "ns xxxx".

 

Thing is that the cookie doesn't seem right comparing to my macbook pro

"notion_check_cookie_consent=true; notion_experiment_device_id=..."

 

Any idea why ? thanks for help

Hi

 

You’ll need a token_v2 value in the cookie, at the least. Can you try copying the cookie over again, or checking you have this in your cookie? 
 

Thanks

Link to comment

Thanks for the quick reply @wrjlewis, after searching the dev mode it looks like I have V2 token..! sorry for the inconveniance

 

I tried debug mode and this is what is written : ERROR: Notion Search[Script Filter] Code 1: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

 

Does it explains why it will not work ?

 

thanks for taking time ! great workflow

 

after some research I found I was missing some files : 

xcode-select --install
Edited by SMN
Link to comment
8 hours ago, SMN said:

Thanks for the quick reply @wrjlewis, after searching the dev mode it looks like I have V2 token..! sorry for the inconveniance

 

I tried debug mode and this is what is written : ERROR: Notion Search[Script Filter] Code 1: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

 

Does it explains why it will not work ?

 

thanks for taking time ! great workflow

 

after some research I found I was missing some files : 

xcode-select --install

Excellent, is it working now? 

Link to comment
  • 1 month later...

Hi @wrjlewis,

 

I got this error when trying to search:

ERROR: Notion Search[Script Filter] Code 1: Traceback (most recent call last):
  File "notion.py", line 230, in <module>
    searchResults = Payload(data)
  File "/Users/huuho/Library/Mobile Documents/com~apple~CloudDocs/Alfred/Alfred.alfredpreferences/workflows/user.workflow.0A7FEFBF-271A-4240-89BE-62EF80B510B8/payload.py", line 8, in __init__
    self.__dict__ = json.loads(j)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

 

How can I fix this error?

 

Thank you

Best,

Edited by HPH
Link to comment
1 minute ago, HPH said:

Hi @wrjlewis,

 

I got this error when trying to search:

ERROR: Notion Search[Script Filter] Code 1: Traceback (most recent call last):
  File "notion.py", line 230, in <module>
    searchResults = Payload(data)
  File "/Users/huuho/Library/Mobile Documents/com~apple~CloudDocs/Alfred/Alfred.alfredpreferences/workflows/user.workflow.0A7FEFBF-271A-4240-89BE-62EF80B510B8/payload.py", line 8, in __init__
    self.__dict__ = json.loads(j)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

 

How can I fix this error?

 

Thank you

Best,

 

This error indicates that the response from Notion has changed.

 

Indeed, after checking, notion has changed their response to the calls that the workflow makes. They are returning html and I can see "Please stand by, while we are checking your browser...".

It appears Notion is trying to stop automated access to their app, that isn't via their API. This could be a problem for this workflow. 

 

I will need to see if there is anything I can do to get this to work again without going through their public API. Or I will need to implement calls to their API properly, but since this involves oAuth, it's quite complex and difficult to do that, in a workflow that doesn't exist as a traditional webapp. 

 

This is not good news.. 

Link to comment
On 5/26/2022 at 1:16 PM, wrjlewis said:

 

This error indicates that the response from Notion has changed.

 

Indeed, after checking, notion has changed their response to the calls that the workflow makes. They are returning html and I can see "Please stand by, while we are checking your browser...".

It appears Notion is trying to stop automated access to their app, that isn't via their API. This could be a problem for this workflow. 

 

I will need to see if there is anything I can do to get this to work again without going through their public API. Or I will need to implement calls to their API properly, but since this involves oAuth, it's quite complex and difficult to do that, in a workflow that doesn't exist as a traditional webapp. 

 

This is not good news.. 

No wonder the workflow doesn't work recently. thank you for your information!

Link to comment
On 5/26/2022 at 9:04 PM, HPH said:

Hi @wrjlewis,

 

I got this error when trying to search:

ERROR: Notion Search[Script Filter] Code 1: Traceback (most recent call last):
  File "notion.py", line 230, in <module>
    searchResults = Payload(data)
  File "/Users/huuho/Library/Mobile Documents/com~apple~CloudDocs/Alfred/Alfred.alfredpreferences/workflows/user.workflow.0A7FEFBF-271A-4240-89BE-62EF80B510B8/payload.py", line 8, in __init__
    self.__dict__ = json.loads(j)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

 

How can I fix this error?

 

Thank you

Best,

 

On 6/3/2022 at 6:19 AM, ezgnod said:

No wonder the workflow doesn't work recently. thank you for your information!

 

On 6/4/2022 at 7:42 PM, vitor said:

@wrjlewis Consider a library which does the heavy lifting for you. Perhaps notion-py?

 

I can only presume this was a temporary error/change/something on notion's side. 

 

After logging into notion today, re-copying the cookie token, and trying again, its all working. 

Link to comment
  • 1 month later...
On 5/6/2020 at 4:00 AM, johnathanz said:

@wrjlewis Thanks so much for creating this plugin. It's pretty awesome!

@MasterBruce to have the plugin work with desktop version of Notion:

1) you click the Script in Alfred workflow

image.png.bc0cfe4b9ac8013865ead87ea03b414f.png

2) in the Script Field, search for the words (there should be 2 instances)

http://www.notion.so/

3) replace the text with:

notion://www.notion.so/

 

 

Hi,

Someone can help me w/ the editing this script to change to the desktop app. I have no idea how to do it.

 

Thanks.

 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...