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

unicode encording problem. #19

Closed hansu35 closed 4 years ago

hansu35 commented 4 years ago

hi.

I'm a Koren user. use Korean it dose not working it always returns "no result" (I have checked it works with English)

So I did my homework then I think I found out the problem. here is the key. unicode on Mac use "NFD" So I type on Alfred "한글" but the query string is "ㅎㅏㄴㄱㅡㄹ" I think that makes "no result".

Could you check this?

unicodedata.normalize('NFC',alfredQuery)

I have tried code like this. but this error come out TypeError: normalize() argument 2 must be unicode, not str

wrjlewis commented 4 years ago

Hi @hansu35

Thanks for raising.

Were you using this notion search workflow successfully before the recent changes - or are you new to the workflow?

Thanks

wrjlewis commented 4 years ago

If you update the code you are using to this:

# Get query from Alfred
alfredQuery = unicode(str(sys.argv[1]))
unicodedata.normalize('NFC', alfredQuery)

Does it work? In this code, alfredquery is converted to unicode before being normalised in NFC. You might find you don't need to normalize in NFC at all, so if you find it is working with the above code, can you try again and see if it works without the normalize code line?

Thanks

hansu35 commented 4 years ago

If you update the code you are using to this:

# Get query from Alfred
alfredQuery = unicode(str(sys.argv[1]))
unicodedata.normalize('NFC', alfredQuery)

Does it work? In this code, alfredquery is converted to unicode before being normalised in NFC. You might find you don't need to normalize in NFC at all, so if you find it is working with the above code, can you try again and see if it works without the normalize code line?

Thanks

I have tried your code and faced another error like this

alfredQuery = unicode(str(sys.argv[1]))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 0: ordinal not in range(128)

I am pretty sure that it is about encoding. Here is what I have done.

  1. add some log.

    # add last part of function called "buildnotionsearchquerydata"
    file = open('./log.txt','a')
    file.write(jsonData)
    file.write("\n")
    file.close()

    -> this show me that word has been seperated when it through alfred. ( as I said I type '한글', it printed 'ㅎㅏㄴㄱㅡㄹ') -> as you know English or number are perfect.

  2. add environment variable to code for runing in command line.

    notionSpaceId = "my id"
    cookie = "my cookie"
    useDesktopClient = True
    isNavigableOnly = True
    enableIcons = True

    -> run in terminal like this python notion.py 한글 works great. -> in this time log.txt has appended "한글" correctly

wrjlewis commented 4 years ago

Hmmm I think this is going to need someone who understands about Unicode encoding, I'm going to label this issue appropriately.

cbsjin commented 4 years ago

I have the same problem as a Korean user. Thank you @hansu35 for raising this issue. I want to add my +1.

hansu35 commented 4 years ago

I don't know why.. but I got a solution.

the main idea is using python3 instead of python2.

So I just change code little bit.

replaced all httplib to http.client

add import line import unicodedata

add or change two line in the code.

# Get query from Alfred
alfredQuery = str(sys.argv[1])

# add unicode type to NFC
alfredQuery = unicodedata.normalize('NFC',alfredQuery)

# Call Notion

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

# convert to str
data = str(response.read(),'utf-8')
data = data.replace("<gzkNfoUU>", "")
data = data.replace("</gzkNfoUU>", "")

then as last alfred command replace to python3 notion.py "{query}"

Great..

Now you can get the result!!

cbsjin commented 4 years ago

@hansu35 Could you share the new Workflow File you changed on here? It would be so helpful. Thanks in advance.

hansu35 commented 4 years ago

@hansu35 Could you share the new Workflow File you changed on here? It would be so helpful. Thanks in advance.

first of all, you have python3 on your machine. and you need to change script of this workflow. from python to python3 then copy and past this code to notion.py file.

# coding=utf-8

import http.client
import json
import os
import os.path
import struct
import sys
import urllib
import unicodedata

from payload import Payload
from searchresult import SearchResult

# config
notionSpaceId = os.environ['notionSpaceId']
cookie = os.environ['cookie']

# get useDesktopClient env variable and convert to boolean for use later, default to false
useDesktopClient = os.environ['useDesktopClient']
if (useDesktopClient == 'true') | (useDesktopClient == 'True') | (useDesktopClient == 'TRUE'):
    useDesktopClient = True
else:
    useDesktopClient = False

# get isNavigableOnly env variable and convert to boolean for use later, default to true
isNavigableOnly = os.environ['isNavigableOnly']
if (isNavigableOnly == 'false') | (isNavigableOnly == 'False') | (isNavigableOnly == 'FALSE'):
    isNavigableOnly = False
else:
    isNavigableOnly = True

# get enableIcons env variable and convert to boolean for use later, default to true
enableIcons = os.environ['enableIcons']
if (enableIcons == 'false') | (enableIcons == 'False') | (enableIcons == 'FALSE'):
    enableIcons = False
else:
    enableIcons = True

def buildnotionsearchquerydata():
    query = {}

    query["type"] = "BlocksInSpace"
    query["query"] = alfredQuery
    query["spaceId"] = notionSpaceId
    query["limit"] = 9
    filters = {}
    filters["isDeletedOnly"] = False
    filters["excludeTemplates"] = False
    filters["isNavigableOnly"] = isNavigableOnly
    filters["requireEditPermissions"] = False
    ancestors = []
    filters["ancestors"] = ancestors
    createdby = []
    filters["createdBy"] = createdby
    editedby = []
    filters["editedBy"] = editedby
    lasteditedtime = []
    filters["lastEditedTime"] = lasteditedtime
    createdtime = []
    filters["createdTime"] = createdtime
    query["filters"] = filters
    query["sort"] = "Relevance"
    query["source"] = "quick_find"

    jsonData = json.dumps(query)
    return jsonData

def getnotionurl():
    if useDesktopClient:
        return "notion://www.notion.so/"
    else:
        return "https://www.notion.so/"

def decodeemoji(emoji):
    if emoji:
        b = emoji.encode('utf_32_le')
        count = len(b) // 4
        # If count is over 10, we don't have an emoji
        if count > 10:
            return None
        cp = struct.unpack('<%dI' % count, b)
        hexlist = []
        for x in cp:
            hexlist.append(hex(x)[2:])
        return hexlist
    return None

def downloadandgetfilepath(searchresultobjectid, imageurl):
    # create icons dir if it doesn't already exist
    if not os.path.isdir('./icons'):
        path = "./icons"
        access_rights = 0o755
        os.mkdir(path, access_rights)

    downloadurl = "/image/" \
                  + urllib.quote(imageurl.encode('utf8'), safe='') \
                  + "?width=120&cache=v2"
    filetype = downloadurl[downloadurl.rfind('.'):]
    filetype = filetype[:filetype.rfind('?')]
    if '%3F' in filetype:
        filetype = filetype[:filetype.rfind('%3F')]
    filepath = "icons/" + searchresultobjectid + filetype

    headers = {"Cookie": cookie}
    conn = http.client.HTTPSConnection("www.notion.so")
    conn.request("GET", downloadurl, "", headers)
    response = conn.getresponse()
    data = response.read()

    with open(filepath, 'wb') as f:
        f.write(data)
    return filepath

def geticonpath(searchresultobjectid, notionicon):
    iconpath = None

    # is icon an emoji? If so, get hex values and construct the matching image file path in emojiicons/
    hexlist = decodeemoji(notionicon)
    if hexlist:
        emojicodepoints = ""
        count = 0
        for x in hexlist:
            count += 1
            if count > 1:
                emojicodepoints += "_"
            emojicodepoints += x
        iconpath = "emojiicons/" + emojicodepoints + ".png"
        # check if emoji image exists - if not, remove last unicode codepoint and try again
        if not os.path.isfile(iconpath):
            while emojicodepoints.count("_") > 0:
                emojicodepoints = emojicodepoints.rsplit('_', 1)[0]
                iconpath = "emojiicons/" + emojicodepoints + ".png"
                if os.path.isfile(iconpath):
                    break

    else:
        # is icon a web url? If so, download it to icons/
        if "http" in notionicon:
            iconpath = downloadandgetfilepath(searchresultobjectid, notionicon)

    return iconpath

# Get query from Alfred
alfredQuery = str(sys.argv[1])

alfredQuery = unicodedata.normalize('NFC',alfredQuery)

# Call Notion

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

data = str(response.read(),'utf-8')
data = data.replace("<gzkNfoUU>", "")
data = data.replace("</gzkNfoUU>", "")

conn.close()

# Extract search results from notion response
searchResultList = []
searchResults = Payload(data)
for x in searchResults.results:
    searchResultObject = SearchResult(x.get('id'))
    if "properties" in searchResults.recordMap.get('block').get(searchResultObject.id).get('value'):
        searchResultObject.title = \
            searchResults.recordMap.get('block').get(searchResultObject.id).get('value').get('properties').get('title')[
                0][0]
    else:
        searchResultObject.title = x.get('highlight').get('text')
    if "pathText" in x.get('highlight'):
        searchResultObject.subtitle = x.get('highlight').get('pathText')
    else:
        searchResultObject.subtitle = " "
    if "format" in searchResults.recordMap.get('block').get(searchResultObject.id).get('value'):
        if "page_icon" in searchResults.recordMap.get('block').get(searchResultObject.id).get('value').get('format'):
            if enableIcons:
                searchResultObject.icon = geticonpath(searchResultObject.id,
                                                      searchResults.recordMap.get('block').get(searchResultObject.id)
                                                      .get('value').get('format').get('page_icon'))
            else:
                searchResultObject.icon = None
                searchResultObject.title = searchResults.recordMap.get('block').get(searchResultObject.id).get(
                    'value').get('format').get('page_icon') + " " + searchResultObject.title
    searchResultObject.link = getnotionurl() + searchResultObject.id.replace("-", "")
    searchResultList.append(searchResultObject)

itemList = []
for searchResultObject in searchResultList:
    item = {}
    item["uid"] = searchResultObject.id
    item["type"] = "default"
    item["title"] = searchResultObject.title
    item["arg"] = searchResultObject.link
    item["subtitle"] = searchResultObject.subtitle
    if searchResultObject.icon:
        icon = {}
        icon["path"] = searchResultObject.icon
        item["icon"] = icon
    item["autocomplete"] = searchResultObject.title
    itemList.append(item)

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

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

@hansu35 Kor) 안녕하세요. 알프레드 - 노션 한국 검색 구현에 도움 주셔서 감사합니다. wrjlewis 이분이 만드신 alfred workflow를 하루 전에 알게 되어 잘 쓰고 있었는데 페이스북에서 한국 검색 구현이 되는 걸 발견하고 워크플로우를 새로 바꿨는데요

ns 검색어 를 평소처럼 해봤는데 검색이 되진 않고 다음과 같은 알프레드 상의 에러가 뜹니다

[23:57:22.555] Notion Search[Script Filter] Script with argv '(null)' finished [23:57:22.564] ERROR: Notion Search[Script Filter] Code 1: Traceback (most recent call last): File "notion.py", line 162, in <module> buildnotionsearchquerydata(), headers) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output self.send(msg) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send self.connect() File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect server_hostname=server_hostname) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket session=session File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create self.do_handshake() File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

맨 마지막의 ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: 에러가 핵심인 거 같은데 제 파이썬 환경에 문제가 있는 걸까요?? 제가 전문 개발자는 아니라서 해결방법에 대한 갈피를 잡지 못하고 있습니다. 문제 해결에 대한 도움을 조금이나마 요청드려도 될까요?

Eng) to hansu35 Hi I'm Korean who recently found alfred-workflow-notion seach from wrjlewis I have used workflow from wrjlewis without any problems (notion searching only English) But after changing new workflow which hansu35 edited, the Error below happens.

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

May I ask a little tips to solve my problems?

full error messages : [23:57:22.555] Notion Search[Script Filter] Script with argv '(null)' finished [23:57:22.564] ERROR: Notion Search[Script Filter] Code 1: Traceback (most recent call last): File "notion.py", line 162, in <module> buildnotionsearchquerydata(), headers) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output self.send(msg) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send self.connect() File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect server_hostname=server_hostname) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket session=session File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create self.do_handshake() File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

romantech commented 4 years ago

@hansu35 Thank you for good information. How do I change the script from python to python3?

@hansu35 Could you share the new Workflow File you changed on here? It would be so helpful. Thanks in advance.

first of all, you have python3 on your machine. and you need to change script of this workflow. from python to python3 then copy and past this code to notion.py file.

# coding=utf-8

import http.client
import json
import os
import os.path
import struct
import sys
import urllib
import unicodedata

from payload import Payload
from searchresult import SearchResult

# config
notionSpaceId = os.environ['notionSpaceId']
cookie = os.environ['cookie']

# get useDesktopClient env variable and convert to boolean for use later, default to false
useDesktopClient = os.environ['useDesktopClient']
if (useDesktopClient == 'true') | (useDesktopClient == 'True') | (useDesktopClient == 'TRUE'):
    useDesktopClient = True
else:
    useDesktopClient = False

# get isNavigableOnly env variable and convert to boolean for use later, default to true
isNavigableOnly = os.environ['isNavigableOnly']
if (isNavigableOnly == 'false') | (isNavigableOnly == 'False') | (isNavigableOnly == 'FALSE'):
    isNavigableOnly = False
else:
    isNavigableOnly = True

# get enableIcons env variable and convert to boolean for use later, default to true
enableIcons = os.environ['enableIcons']
if (enableIcons == 'false') | (enableIcons == 'False') | (enableIcons == 'FALSE'):
    enableIcons = False
else:
    enableIcons = True

def buildnotionsearchquerydata():
    query = {}

    query["type"] = "BlocksInSpace"
    query["query"] = alfredQuery
    query["spaceId"] = notionSpaceId
    query["limit"] = 9
    filters = {}
    filters["isDeletedOnly"] = False
    filters["excludeTemplates"] = False
    filters["isNavigableOnly"] = isNavigableOnly
    filters["requireEditPermissions"] = False
    ancestors = []
    filters["ancestors"] = ancestors
    createdby = []
    filters["createdBy"] = createdby
    editedby = []
    filters["editedBy"] = editedby
    lasteditedtime = []
    filters["lastEditedTime"] = lasteditedtime
    createdtime = []
    filters["createdTime"] = createdtime
    query["filters"] = filters
    query["sort"] = "Relevance"
    query["source"] = "quick_find"

    jsonData = json.dumps(query)
    return jsonData

def getnotionurl():
    if useDesktopClient:
        return "notion://www.notion.so/"
    else:
        return "https://www.notion.so/"

def decodeemoji(emoji):
    if emoji:
        b = emoji.encode('utf_32_le')
        count = len(b) // 4
        # If count is over 10, we don't have an emoji
        if count > 10:
            return None
        cp = struct.unpack('<%dI' % count, b)
        hexlist = []
        for x in cp:
            hexlist.append(hex(x)[2:])
        return hexlist
    return None

def downloadandgetfilepath(searchresultobjectid, imageurl):
    # create icons dir if it doesn't already exist
    if not os.path.isdir('./icons'):
        path = "./icons"
        access_rights = 0o755
        os.mkdir(path, access_rights)

    downloadurl = "/image/" \
                  + urllib.quote(imageurl.encode('utf8'), safe='') \
                  + "?width=120&cache=v2"
    filetype = downloadurl[downloadurl.rfind('.'):]
    filetype = filetype[:filetype.rfind('?')]
    if '%3F' in filetype:
        filetype = filetype[:filetype.rfind('%3F')]
    filepath = "icons/" + searchresultobjectid + filetype

    headers = {"Cookie": cookie}
    conn = http.client.HTTPSConnection("www.notion.so")
    conn.request("GET", downloadurl, "", headers)
    response = conn.getresponse()
    data = response.read()

    with open(filepath, 'wb') as f:
        f.write(data)
    return filepath

def geticonpath(searchresultobjectid, notionicon):
    iconpath = None

    # is icon an emoji? If so, get hex values and construct the matching image file path in emojiicons/
    hexlist = decodeemoji(notionicon)
    if hexlist:
        emojicodepoints = ""
        count = 0
        for x in hexlist:
            count += 1
            if count > 1:
                emojicodepoints += "_"
            emojicodepoints += x
        iconpath = "emojiicons/" + emojicodepoints + ".png"
        # check if emoji image exists - if not, remove last unicode codepoint and try again
        if not os.path.isfile(iconpath):
            while emojicodepoints.count("_") > 0:
                emojicodepoints = emojicodepoints.rsplit('_', 1)[0]
                iconpath = "emojiicons/" + emojicodepoints + ".png"
                if os.path.isfile(iconpath):
                    break

    else:
        # is icon a web url? If so, download it to icons/
        if "http" in notionicon:
            iconpath = downloadandgetfilepath(searchresultobjectid, notionicon)

    return iconpath

# Get query from Alfred
alfredQuery = str(sys.argv[1])

alfredQuery = unicodedata.normalize('NFC',alfredQuery)

# Call Notion

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

data = str(response.read(),'utf-8')
data = data.replace("<gzkNfoUU>", "")
data = data.replace("</gzkNfoUU>", "")

conn.close()

# Extract search results from notion response
searchResultList = []
searchResults = Payload(data)
for x in searchResults.results:
    searchResultObject = SearchResult(x.get('id'))
    if "properties" in searchResults.recordMap.get('block').get(searchResultObject.id).get('value'):
        searchResultObject.title = \
            searchResults.recordMap.get('block').get(searchResultObject.id).get('value').get('properties').get('title')[
                0][0]
    else:
        searchResultObject.title = x.get('highlight').get('text')
    if "pathText" in x.get('highlight'):
        searchResultObject.subtitle = x.get('highlight').get('pathText')
    else:
        searchResultObject.subtitle = " "
    if "format" in searchResults.recordMap.get('block').get(searchResultObject.id).get('value'):
        if "page_icon" in searchResults.recordMap.get('block').get(searchResultObject.id).get('value').get('format'):
            if enableIcons:
                searchResultObject.icon = geticonpath(searchResultObject.id,
                                                      searchResults.recordMap.get('block').get(searchResultObject.id)
                                                      .get('value').get('format').get('page_icon'))
            else:
                searchResultObject.icon = None
                searchResultObject.title = searchResults.recordMap.get('block').get(searchResultObject.id).get(
                    'value').get('format').get('page_icon') + " " + searchResultObject.title
    searchResultObject.link = getnotionurl() + searchResultObject.id.replace("-", "")
    searchResultList.append(searchResultObject)

itemList = []
for searchResultObject in searchResultList:
    item = {}
    item["uid"] = searchResultObject.id
    item["type"] = "default"
    item["title"] = searchResultObject.title
    item["arg"] = searchResultObject.link
    item["subtitle"] = searchResultObject.subtitle
    if searchResultObject.icon:
        icon = {}
        icon["path"] = searchResultObject.icon
        item["icon"] = icon
    item["autocomplete"] = searchResultObject.title
    itemList.append(item)

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

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

안녕하세요. 아마 인증서 관련 문제 인것으로 보이는데 아래와 같은 링크를 찾았습니다. 인증서를 새롭게 설치해 보시는걸 추천드려요. 혹 영어로만 잘 쓰고 계신다면 그냥 원본으로 쓰시면서 영어로 쓰시는게 더 좋을꺼에요 :)

it looks like problem about certification. I just found link below, you could try it.

https://stackoverflow.com/questions/42098126/mac-osx-python-ssl-sslerror-ssl-certificate-verify-failed-certificate-verify

@hansu35 Kor) 안녕하세요. 알프레드 - 노션 한국 검색 구현에 도움 주셔서 감사합니다. wrjlewis 이분이 만드신 alfred workflow를 하루 전에 알게 되어 잘 쓰고 있었는데 페이스북에서 한국 검색 구현이 되는 걸 발견하고 워크플로우를 새로 바꿨는데요

ns 검색어 를 평소처럼 해봤는데 검색이 되진 않고 다음과 같은 알프레드 상의 에러가 뜹니다

맨 마지막의 ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: 에러가 핵심인 거 같은데 제 파이썬 환경에 문제가 있는 걸까요?? 제가 전문 개발자는 아니라서 해결방법에 대한 갈피를 잡지 못하고 있습니다. 문제 해결에 대한 도움을 조금이나마 요청드려도 될까요?

Eng) to hansu35 Hi I'm Korean who recently found alfred-workflow-notion seach from wrjlewis I have used workflow from wrjlewis without any problems (notion searching only English) But after changing new workflow which hansu35 edited, the Error below happens.

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

May I ask a little tips to solve my problems?

full error messages : [23:57:22.555] Notion Search[Script Filter] Script with argv '(null)' finished [23:57:22.564] ERROR: Notion Search[Script Filter] Code 1: Traceback (most recent call last): File "notion.py", line 162, in <module> buildnotionsearchquerydata(), headers) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output self.send(msg) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send self.connect() File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect server_hostname=server_hostname) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket session=session File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create self.do_handshake() File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

hansu35 commented 4 years ago

Hi. Instruction.

  1. open alred prefereces.
  2. open notion search workflow.
  3. right click on a box with notion icon.
  4. select "Configure Object..."
  5. you can see the phrase python notion.py "{query}" in the Script window.
  6. type 3 end of python
  7. click save button.

@hansu35 Thank you for good information. How do I change the script from python to python3?

romantech commented 4 years ago

@hansu35 It works normally. Thank you! It's so useful.

Hi. Instruction.

  1. open alred prefereces.
  2. open notion search workflow.
  3. right click on a box with notion icon.
  4. select "Configure Object..."
  5. you can see the phrase python notion.py "{query}" in the Script window.
  6. type 3 end of python
  7. click save button.

@hansu35 Thank you for good information. How do I change the script from python to python3?

wrjlewis commented 4 years ago

Please check out this new version (https://github.com/wrjlewis/notion-search-alfred-workflow/releases/tag/0.3.3).

I believe this is now fixed and handling Unicode characters properly, so you don't need to install python 3 or make any changes yourself.

Can you let me know if it is working?

wonjoonSeol commented 4 years ago

Seems like the issue is solved. Thank you 👍

wrjlewis commented 4 years ago

Awesome

hansu35 commented 4 years ago

Please check out this new version (https://github.com/wrjlewis/notion-search-alfred-workflow/releases/tag/0.3.3).

I believe this is now fixed and handling Unicode characters properly, so you don't need to install python 3 or make any changes yourself.

Can you let me know if it is working?

works great.. :) Thank you~~