From 76f05250e926358832b8c3a59b80bbb2a9731125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E9=87=91=E6=A0=8B?= Date: Thu, 23 Nov 2023 15:23:05 +0800 Subject: [PATCH] Alfred 5.1 multiple keywords feature support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 胡金栋 --- info.plist | 79 ++++------------------------------------------------- leetcode.py | 5 ++-- 2 files changed, 9 insertions(+), 75 deletions(-) diff --git a/info.plist b/info.plist index 45be397..02fdb70 100644 --- a/info.plist +++ b/info.plist @@ -4,21 +4,10 @@ bundleid com.hopbourn.leetcode-search + category + Productivity connections - 150D093F-8D15-4EDB-A55E-B4862A5D7E40 - - - destinationuid - 89066D90-11BF-40C9-BD1C-A7585FAAA4C2 - modifiers - 0 - modifiersubtext - - vitoclose - - - 3B4CA1A5-E71B-4073-9282-BFA5E25D49D6 @@ -59,7 +48,7 @@ escaping 102 keyword - lc + lc||sxl queuedelaycustom 3 queuedelayimmediatelyinitially @@ -71,7 +60,7 @@ runningsubtext 查询中,请等待...... script - python3 leetcode.py "$1" "" + python3 leetcode.py "$1" scriptargtype 1 scriptfile @@ -113,73 +102,17 @@ version 1 - - config - - alfredfiltersresults - - alfredfiltersresultsmatchmode - 0 - argumenttreatemptyqueryasnil - - argumenttrimmode - 0 - argumenttype - 1 - escaping - 102 - keyword - sxl - queuedelaycustom - 3 - queuedelayimmediatelyinitially - - queuedelaymode - 0 - queuemode - 1 - runningsubtext - 查询中,请等待...... - script - python3 leetcode.py "$1" "sxl" - scriptargtype - 1 - scriptfile - - subtext - - title - 搜索 Leetcode 题目 - type - 11 - withspace - - - type - alfred.workflow.input.scriptfilter - uid - 150D093F-8D15-4EDB-A55E-B4862A5D7E40 - version - 3 - readme uidata - 150D093F-8D15-4EDB-A55E-B4862A5D7E40 - - xpos - 275 - ypos - 260 - 3B4CA1A5-E71B-4073-9282-BFA5E25D49D6 xpos - 275 + 280 ypos - 135 + 200 89066D90-11BF-40C9-BD1C-A7585FAAA4C2 diff --git a/leetcode.py b/leetcode.py index 319f86b..07a626a 100644 --- a/leetcode.py +++ b/leetcode.py @@ -1,3 +1,4 @@ +import os import re import sys import json @@ -11,11 +12,11 @@ def camel_to_snake(camel_case_string): result = [] for item in data: # ValidAnagram - if sys.argv[1].isalpha() and camel_to_snake(sys.argv[1]) == item["arg"]: + if sys.argv[1].isalpha() and camel_to_snake(sys.argv[1]) in item["arg"]: pass elif sys.argv[1].lower() not in item["title"].lower(): continue - if sys.argv[2].lower() == "": + if os.environ['alfred_workflow_keyword'].lower() == "lc": item["arg"] = f"https://leetcode.cn/problems/{item['arg']}/description/" else: item["arg"] = f"https://www.google.com.hk/search?&q=site:programmercarl.com+{item['title']}"