Skip to content

Commit 0a8a55b

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents 9be7695 + 624dddf commit 0a8a55b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: leetcode.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ def camel_to_snake(camel_case_string):
1111
data = json.loads(data)
1212
result = []
1313
for item in data:
14-
# ValidAnagram
1514
if sys.argv[1].isalpha() and camel_to_snake(sys.argv[1]) in item["arg"]:
1615
pass
1716
elif sys.argv[1].lower() not in item["title"].lower():
1817
continue
1918
if os.environ['alfred_workflow_keyword'].lower() == "lc":
2019
item["arg"] = f"https://leetcode.cn/problems/{item['arg']}/description/"
2120
else:
22-
item["arg"] = f"https://www.google.com.hk/search?&q=site:programmercarl.com+{item['title']}"
21+
parts = item['title'].split(' ')
22+
text = ''.join(parts[1:]).replace(' ', '')
23+
formatted_title = '{:0>4}.{}.html'.format(parts[0], text)
24+
item["arg"] = f"https://programmercarl.com/{formatted_title}"
2325
item["icon"] = {}
2426
item["icon"]["path"] = "icon.png"
2527
result.append(item)
2628
alfredJSON = json.dumps({"items": result}, indent=2, ensure_ascii=False)
27-
sys.stdout.write(alfredJSON)
29+
sys.stdout.write(alfredJSON)

0 commit comments

Comments
 (0)