Generate web thumbnail

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Generate web thumbnail Sun Jan 17, 2010 9:09 pm • by eN0ch
Hi,

I'm a non-geek, so be kind ;)

Long story short .... I want to use Hazel to move newly-created webloc files to a certain folder, and in the process generate a thumbnail of the webpage. I had it working pre-Snow Leopard with an Applescript and app called Webseecon generating the thumbnails. But that setup no longer works. (Something to do with the way SL treats some newly generated files??)

I've found a freeware python script here that looks like it might do the job. But I can't figure out how to add that script to a Hazel rule.

Can someone help me in plain English? (Or is there a better / simpler way to do what I want?)

Thanks.
Lance <º))><

iMac 24" 2021 M1 | macOS 14.4.1 | Hazel 5.2.1
eN0ch
 
Posts: 63
Joined: Tue Jul 01, 2008 7:41 pm
Location: Crookwell, NSW, Australia

Re: Generate web thumbnail Tue Jan 19, 2010 1:31 pm • by Mr_Noodle
The "Run shell script" action can run most any script. In the "Shell:" field, just enter the path to wherever python is stored. On my machine here (10.6), it's at /usr/bin/python.

The script itself would then be a python script. Just paste in the script. The instructions in the script editor should tell you what variable represents the file argument Hazel will pass in.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Generate web thumbnail Tue Jan 19, 2010 7:46 pm • by eN0ch
Hi Paul,

Thanks for the tip. Sounds good - but we've already passed the stage where my geekery runs out ;) .. So a bit more help please:

The path to python is the same on my machine as yours, and pasting that into the shell field was fine, and I then pasted the entire text of the python document in the script box. That was fine too. But confusion after that.
• if I tab from the shell field the instruction changes from "Use $1 to refer to the file .. " to "Use sys.argv[1] to refer .."
• if I then click 'OK' to save the rule, and then re-open the rule edit panel, I find that it's changed back to "Use $1 ... "
• there's no occurrence of "$1" anywhere in the script
• there's no occurrence of "sys.argv[1]" either
• but there is something almost the same as the latter:
Code: Select all
# commandline arguments
   optlist, args = getopt.gnu_getopt(sys.argv[1:], 'o:w:h:')
   opts = dict(optlist)

• thus far the script isn't working

So as I said - my geekery doesn't extend to some of this stuff. Please elaborate. Thanks :)
Lance <º))><

iMac 24" 2021 M1 | macOS 14.4.1 | Hazel 5.2.1
eN0ch
 
Posts: 63
Joined: Tue Jul 01, 2008 7:41 pm
Location: Crookwell, NSW, Australia

Re: Generate web thumbnail Thu Jan 21, 2010 2:52 pm • by Mr_Noodle
The instructions are just a guideline for those writing a script. Different languages refer to their arguments differently. $1 doesn't make sense for Python in this case. I'll file a bug about that instructional text reverting back after a save.

Unfortunately, my Python knowledge is limited. You may be better off finding a Python forum and asking someone there to help you customize the script. Also, it's unclear to me why you abandoned the AppleScript version. You can try posting that script here but again, you may be better off finding an AppleScript specific forum to help you on that.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Generate web thumbnail Thu Jan 21, 2010 6:15 pm • by eN0ch
Thanks, Paul.

The Applescript solution depended on calling the app Webseecon to generate the thumbnails. It worked brilliantly with rarely a hitch pre-Snow Leopard. But when I upgraded to SL everything changed. I haven't seen anything that documents this, but from observation SL appears to treat newly-created files (or possibly it's files that suddenly appear in a new location??) differently, such that as soon as the file is created / appears, it's opened with the default app for that filetype. So in the case of the webloc files that my script created on the desktop, Safari would immediately open the web location, and that would somehow 'hijack' the operation. Similarly, even manually dragging the webloc file to the Webseecon dock icon produces the same result - i.e. Safari (again) opens the URL and nothing happens in Webseecon. Webseecon now only works by manually dragging a webloc over the Webseecon interface.

I'll track down a python forum as you suggest. But I ned you to tell me what exactly I'm asking them. Sorry to be such a scripting noob ;)
Lance <º))><

iMac 24" 2021 M1 | macOS 14.4.1 | Hazel 5.2.1
eN0ch
 
Posts: 63
Joined: Tue Jul 01, 2008 7:41 pm
Location: Crookwell, NSW, Australia

Re: Generate web thumbnail Fri Jan 22, 2010 3:36 pm • by Mr_Noodle
Maybe the file association between .webloc files and Webseecon was lost? Why is anything automatically opening the file? Is that a part of the AppleScript or do you have some other program opening the files? If that solution was working before, maybe it might be better to fix that.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Generate web thumbnail Fri Jan 22, 2010 7:58 pm • by eN0ch
OK, thanks for that. Guess I might try posting to an AS forum on that point. We'll see ...

If I remember I'll post back here with what I eventually find.
Lance <º))><

iMac 24" 2021 M1 | macOS 14.4.1 | Hazel 5.2.1
eN0ch
 
Posts: 63
Joined: Tue Jul 01, 2008 7:41 pm
Location: Crookwell, NSW, Australia


Return to Support