Jump to content

Cheng

Member
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Cheng

  1. 5 hours ago, deanishe said:

    FWIW, simply replacing https with http is not super robust, as it's possible that https appears more than once in the URL, e.g.:

     

    https://web.archive.org/web/*/https://www.alfredapp.com/

     

    Arguably better to use a Run Script with a slightly-modified version of your original code that only replaces https:// at the start of the URL:

    
    if query.startswith('https://'):
        query = 'http://' + query[8:]
    
    sys.stdout.write(query)

    Cool, How can I hook up a script with a open url action? As I tried to use a script filter but being told that it is not what script filter is for.

     

  2. 23 minutes ago, vitor said:

    A Script Filter is the wrong solution. You should have a Keyword connected to a Run Script connected to Open URL. Yes, that is more nodes, but will actually be simpler code and will be more efficient since it won’t run with every character press.


    When asking for help with your workflow please also post a link a to it. We’re not seeing the whole picture and the problem may be somewhere you’re not thinking of. Also give us your Alfred version.

    Thanks Vitor!

  3. 22 minutes ago, Andrew said:

    You'd be better off just using a keyword input to capture the query, then run it through a Run Script which does your processing. This simplifies things as you just output the URL from the script which will be used as the input of the Open URL.

     

    You could even do this without scripting using:

    Keyword input -> Replace util (replace http) -> Process util (lower case) -> Open URL.

     

    Cheers,

    Andrew

     

    Really appreciate your help  "Keyword input -> Replace util (replace http) -> Process util (lower case) -> Open URL" => this one is much easier. The "Process util" is called "Transform" in my alfred.

  4. Newbie question here: I have created a script filter to convert a {query} to lower case and replace https with http:

     

    import sys
    
    query = "{query}"
    
    query = query.lower()
    
    if query.startswith('https://'):
        query = query.replace('https://', 'http://')
    
    sys.stdout.write('{"items":[{"title": "test", "args":"'+query+'"}]}')

     

    Then, I'd like to pass the processed {query} to an open url action. (See the attached image below)

     

    After I enter the keyword: ala a_url, and press enter, nothing happens. I can see the debug console printing out the correct JSON, but I am not sure how to pass the processed {query} to the "open url action", please help

    截图 2016-10-30 23时25分17秒.jpg

×
×
  • Create New...