Jump to content

spongeblink

Member
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

spongeblink's Achievements

Helping Hand

Helping Hand (3/5)

1

Reputation

  1. I tried to use the Script Filter action to find some Japanese novels from the web, I had it list all titles of the novels for me and I will type to search in them, but some of the results were not shown besides me typed the keyword included in the title. I build a test workflow to showcase it: cat << EOB { "items": [ { "title": "ドイツ留学", "subtitle": "ドイツ留学", "arg": "ドイツ留学", "match": "ドイツ留学" }, { "title": "no", "subtitle": "no", "arg": "no", "match": "no" }, { "title": "knkfd", "subtitle": "knkfd", "arg": "knkfd", "match": "knkfd" }, ]} EOB If I type "ドイツ" which is the Japanese word for "Germany", Alfred shows me the result. And if I type "留学" ("study abroad"), he shows me nothing. I'm on Alfred 5.1.2 [2145], macOS 13.5.1. If this is something that Alfred is not currently capable or/and intended to handle, I still don't think this belongs to the feature request category because it is something Alfred says he can do but fails at, since "word" can mean different things in different languages. And I don't think Alfred should work specifically in English.
  2. Thank you so much for modifying my code! 👍👍 Than's exactly how I would like it to work! Looked at my original code and found out that the quick part does not trigger a rerun of itself to let user_prompt and former_user_prompt sync since os.getenv("former_user_prompt") == os.getenv("user_prompt") is no longer true. Your solution is way better! Thanks in advance!
  3. Thanks for the reply! I missed the feature that the variable field that is passed back into a rerun. I made it… kind of work. But I'm confused how to tell between a state that the user just typed (need to run the fast part), and the state the slow part needs to run after the result from the fast part is shown to the user… I tried to keep a record of what the user has typed and based on that, but that didn't work, the script still waits until the slow part is done as the user types. Here's my sample script: import json import os import sys import uuid import time def get_query() -> str: """Join the arguments into a query string.""" return " ".join(sys.argv[1:]) def provide_history(): """Provide the history of the user.""" prompt = get_query() if os.getenv("uuid_") is None or (os.getenv("former_user_prompt") == os.getenv("user_prompt") and os.getenv("user_prompt") != prompt): uuid_ = str(uuid.uuid1()) pre_history_dict = { "variables": { "user_prompt": prompt, }, "rerun": 0.1, "items": [ { "type": "default", "title": prompt, "subtitle": f"Talk to {prompt} 💬".strip(), "arg": [uuid_, prompt], "autocomplete": prompt, } ], } pre_history_dict["variables"]["uuid_"] = uuid_ pre_history_dict["variables"]["former_user_prompt"] = os.getenv("user_prompt") sys.stdout.write(json.dumps(pre_history_dict)) else: #slow part time.sleep(1) response_dict = { "variables": { "user_prompt": prompt, }, "items": [ { "type": "default", "title": "slow part", "subtitle": f"Talk to {prompt} 💬".strip(), "arg": [os.getenv("uuid_"), prompt], "autocomplete": prompt, } ], } response_dict["variables"]["former_user_prompt"] = os.getenv("user_prompt") sys.stdout.write(json.dumps(response_dict)) provide_history() And this is the behavior setting of the script. I'm expecting it to terminate the slow part every time I after started typing. The logic for the tracking user input part seemed to have worked, but Alfred won't terminate the script when a new input has arrived and he's doing the slow part despite this behavior setting.
  4. I have a sadly slow script written in Python. The result from the slow part of it is not always needed so I'm thinking if I can modify the script so that when the user type the argument, the script will return a quick result immediately, and start to do the calculations for the slow part, if it finishes before user starts typing again, the full result is shown; otherwise stop the calculation and show the quick result for the new argument. I have separated the fast and slow part of the script, used two sys.stdout.write() statements, but it seem that Alfred doesn't accept the result from the quick part unless the whole script is finished -- aka when the slow part is done too! Does anyone have the same need or question, is this possible in Script Filter or in other actions? Any help will be appreciated!
  5. The problem seemed to be that the character バ and ド using two different patterns to encode, when the file name server gave me got placed in Alfred, the pattern changes and got passed in the script using another pattern, so when I do a second match, python sees them as they different string. explained here: https://qiita.com/gretchi/items/13c0825282415e2e360d
  6. I have also tried quoting the argument with ' instead of " . Tried taking the input as {query}: but no luck!
  7. I made a workflow that takes an argument, makes a request to the web, navigate through it, get link to some files, and stream them on my Mac. But for some file I'm experiencing trouble that despite the Script Filter and Terminal.app using the exact same Python, to execute the exact same script, with the exact same argument, the result is different, I cannot stream files from that category. I assume that the argument has some special character that Alfred processed differently than it in Terminal.app, but I just can't figure out why and how to fix or avoid this. This is how I ran it in Terminal.app (zsh), python3 /Users/myusernam/Documents/Dropbox\ -\ Maestral/Alfred\ Preferences/Alfred.alfredpreferences/workflows/user.workflow.B8A4F870-10C1-4428-8F3E-235D38E1CEE9/src_py/req_json.py "RJ01036180&&新感覚バイノーラル『 テレバーチャルヘッド』を体感しよう!" This is how I invoked it in Alfred: asmr RJ01036180&&新感覚バイノーラル『 テレバーチャルヘッド』を体感しよう! How I set the Script Filter in Alfred: Any help will be appreciated!
×
×
  • Create New...