Jump to content

Show icon from url in script results


Recommended Posts

Hi guys,

 

I've just set up my first python workflow using the alfred-workflow lib and its superb tutorial.

I am fetching results from an api and showing them using wf.add_item, but for each api result I get a link to an image, and I would like to use this as the result icon.

 

From what I understand from the lib documentation it is not directly possible using the icon parameter.

 

Do you know if there is some way to do that ?

 

I guess I could try to download the file from python and referencing it locally ? But I haven't really thought about it yet and this already raises some concerns to me haha, seems hacky

 

Thanks for your help !

Edited by uncalin
Link to comment
17 minutes ago, uncalin said:

From what I understand from the lib documentation it is not directly possible using the icon parameter.

 

That is correct. Passing Alfred a URL for an icon doesn't work. You have to cache the icons locally and pass Alfred the filepath.

 

26 minutes ago, uncalin said:

I guess I could try to download the file from python and referencing it locally ?

 

That's exactly how you have to do it.

 

I wrote a module that might help. It generates thumbnail images, but it could easily be repurposed to download images instead. The general idea is that if an image isn't already cached, it queues it up to be downloaded in the background, so your workflow isn't slowed down by waiting for images.

Link to comment

Sorry for the late reply, busy week.

 

Thanks man, I'll check this out.

Any technical reason why this is not included in the alfred-workflow library ? I mean other than lack of time, or lack of requests to integrate it

(I might consider contributing, so this could be start if I get something nice to work for my personnal workflow)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...