Jump to content

deanishe

Member
  • Posts

    8,759
  • Joined

  • Last visited

  • Days Won

    522

Everything posted by deanishe

  1. Add a Keyword input with "Argument optional" then connect it to a Run Script action with Language set to "/usr/bin/python". Paste this script in the Script box: # encoding: utf-8 import csv import os import subprocess import sys csvfile = os.path.expanduser('~/Desktop/links.csv') count = 0 if len(sys.argv) > 1: count = int(sys.argv[1]) urls = [] with open(csvfile) as fp: reader = csv.reader(fp, delimiter=',') for i, row in enumerate(reader): if count and i == count: break urls.append(row[1]) for url in urls: subprocess.call(['/usr/bin/open', url]) If you enter a number after your keyword, it will open that many URLs. If you don't enter a number it will open them all.
  2. I'm not sure I'd eat a burger called "McFrozen". Sounds like "McUncooked". I bet you'd eat a "McMett", wouldn't you? Igittigitt
  3. Not really, no. Alfred can't possibly guess which URLs you want to open, so you have to write them down somewhere. A better solution than snippets would probably be a List Filter.
  4. All at the same time? Always the first 5? Or sometimes the first 4? With a text editor.
  5. Just the ones you use and know aren't working. Like @vitor said, if you want the author(s) of the workflow(s) to see your post, you should post in the appropriate thread. As you can see, nobody who can help you has seen this thread.
  6. Yeah, that's bitten me before, too. In any case, exporting it via Alfred saves us the bother of having to change the extension so we can actually install the workflow. Here's an edited version of the workflow. I've implemented the first two levels (top-level and second-level) to show you how to connect them. I've connected them via External Triggers instead of just wiring them together, as it makes the layout more pleasant, albeit a bit more complicated. It works just the same as if they were connected via normal connections. I'll leave the further levels up to you, as the Classes pages are harder to parse, and I don't like parsing HTML (very error prone). The two main "features" I've added are filtering of the result by Alfred (by ticking the "Alfred filters results" box), so you can filter the results using a query, and very importantly, caching of the results. The way Alfred works, your workflow was downloading the webpage(s), more or less, on every single keypress. With caching, the workflow no longer hammers the server, and is much more responsive. Personally, I'd implement the workflow using a single script that understands different URL types, but that's somewhat more complicated. Also, I'd use Alfred-Workflow's filtering rather than Alfred's, as it's better-suited to things like class names. I'll also leave that as an exercise for you.
  7. What you've uploaded is broken. The workflow and bs4 directories are empty. Please export the workflow from Alfred (right-click on the workflow in Alfred Preferences and choose Export…) and upload the resulting .alfredworkflow file.
  8. I think reading the stickied threads is fairly universally considered good Which reminds, me. I'm moving this thread to the Workflow Help & Questions one, where it belongs.
  9. Please, upload the entire workflow somewhere and post a link to that. It's unreasonable to expect us to try to recreate your workflow in order to help you. I'm afraid I don't understand. You want to read a list of links from the page that showing in your browser? As regards the code: def dbg(msg): log.debug(msg) Don't do this. Just use log.debug(). The proper way to use logging is like this, which you've broken: url = 'http://www.example.com' r = web.get(url) log.debug('[%d] %s', r.status_code, url) Also, don't stream the response. It's a web page, not a multi-megabyte zip file: response = web.get(url, stream=True) # should be response = web.get(url) This is unnecessary: laz_icon = os.path.join(sys.path[0], 'icon.png') Just use: laz_icon = 'icon.png' It would only make a difference if you were running the script from a different directory, which is not a good idea (for a workflow). If you must do that, the correct way is: laz_icon = os.path.join(os.path.dirname(__file__), 'icon.png') The reason is that sys.path is not guaranteed to have your script's directory at the front. If you've used Workflow(libraries=[...]), for example, your code won't work as expected.
  10. Re-installed this workflow today, as it handles a few things better than my Pandoc-based one. Couple of bugs/feature requests: Could you add support for level 4+ headers? The workflow also processes the contents of code blocks. Newlines get doubled and comments starting with # get turned into level-1 headers, both of which are undesirable.
  11. I've edited the script a wee bit. You were using workflow.web and httplib2 to fetch the URL twice. import sys from bs4 import BeautifulSoup, SoupStrainer from workflow import Workflow3, ICON_WEB, web def main(wf): url = 'http://lazarus-ccr.sourceforge.net/docs/' response = web.get(url) # throw an error if request failed # Workflow will catch this and show it to the user response.raise_for_status() # Parse the response for link in BeautifulSoup(response.text, parseOnlyThese=SoupStrainer('a')): if link.has_attr('href'): wf.add_item(title=link['href'], arg=link['href'], valid=True, icon=ICON_WEB) # Send the results to Alfred as XML wf.send_feedback() if __name__ == "__main__": wf = Workflow3() sys.exit(wf.run(main))
  12. Don't use print. That invalidates the JSON output. That's why logging is built into the library. Alfred shows its "web search" fallback results when your script doesn't output any valid results. Don't use libraries installed globally. Include them in the workflow itself. Otherwise it won't work for other people, and we can't help you with it because we don't have the same workflow.
  13. It works for me, although I think it crashed Safari the first time I ran it…
  14. No biggie. You're just more likely to get an answer posting in the right place. Glad it's working.
  15. That's why I use File Filters or workflows for all file searches.
  16. It sounds like there's a problem with the link you're trying to add. What's the URL?
  17. Heh. Good thinking. I always forget about that feature, as I never use it.
  18. I'm going to move this to the Workflow Help & Questions forum, as that's where it belongs. I'd also like to refer you to the thread on asking for help with your workflow. The TL;DR is: if you want help with a workflow, it's usually best to post the actual workflow so we can see what you're talking about. Here's a guess at one way you might do that (no idea if it's appropriate without knowing your workflow): If all your websites are using the same software (i.e. the CMS login page is always at the same relative URL), just add a second Open URL action after your List Filter and add the appropriate relative URL to {query}. Then double-click the connection between the action and your List Filter, and set it to run when CMD is pressed. That way, ↩ opens the website and ⌘↩ opens the CMS login page. If that's no good, please post a copy of the workflow, so we can actually see what we're talking about. Make a copy and fill it with dummy URLs if need be.
  19. I don't think so, no. Alfred will offer to open as a URL anything that's a valid domain name, which these days is almost anything with a dot in it.
  20. Of course it has. I can see from the screenshot that you've ticked the "Alfred filters results" box, which was one of the issues with the workflow you posted. Also, the workflow you posted did not have this particular issue. The cat works fine. Images are fine, but post the workflow, too. It's not your fault I keep reading your posts, is it? I mean, here I am again… Don't leave the forums or quit making workflows on my account. It seems I'm the only person who gets annoyed by having to remind you to post your workflow, not a picture of it, every single time. I'll stick you on my ignore list, and then everyone's happy.
  21. Why are you posting a screenshot? Seriously, why? You've been told literally over 20 times by now to post the workflow that isn't working, not a bloody picture of it. I'm sticking you on ignore, tbh. I'm not going to waste any more of my time answering your questions because you immediately forget everything.
  22. It sounds like option (a): macOS being weird. Alfred doesn't mess about with your volume settings, and you'd have to authorise (as an admin) changing a volume to read-only in any case.
  23. Yeah, you made 2 silly mistakes. You haven't checked "Alfred filters results" in your Script Filter, which is why search isn't working. I'm surprised it even works at all, as your JSON isn't even valid: Trailing commas aren't allowed in JSON, but every object within items has a trailing comma after the autocomplete item. I can only assume that you still aren't using a real JSON library, or at least not using it properly.
×
×
  • Create New...