Need help developing a shortcut

StepanDolezal

macrumors newbie
Original poster
Sep 19, 2018
2
0
So, I love the shortcuts app, but all my visions with it seemed to me that they are too complex for the app.

My Shortcuts function is: Ask you for what you want to search an image of, Automatically searches it and downloads the first result in your Photos app. I got to the point of getting to the page with all the images on Google, but i need my shortcut to open the first picture (Which i cant find commands for) and copy the url and download the file from the url.

I've tried the Match Text (Which i still dont understand how it works) Ive tried "Im feeling Lucky" But that doesnt work with the Google images search, Ive tried Counting the number of Items after the URLs from input and then Repeating [If: Containts - png (Copy to clipboard)] But that didnt work for some reason.


Any ideas?
 

Attachments

matttye

macrumors 601
Mar 25, 2009
4,956
30
Lincoln, England
So, I love the shortcuts app, but all my visions with it seemed to me that they are too complex for the app.

My Shortcuts function is: Ask you for what you want to search an image of, Automatically searches it and downloads the first result in your Photos app. I got to the point of getting to the page with all the images on Google, but i need my shortcut to open the first picture (Which i cant find commands for) and copy the url and download the file from the url.

I've tried the Match Text (Which i still dont understand how it works) Ive tried "Im feeling Lucky" But that doesnt work with the Google images search, Ive tried Counting the number of Items after the URLs from input and then Repeating [If: Containts - png (Copy to clipboard)] But that didnt work for some reason.


Any ideas?
Do a ‘repeat with each’ on each URL returned from the get URLs from input.

Inside the repeat with each you need to do an if statement which does a match text using this pattern: “.+?\.png” (without the quotes).

If it does, do a get contents of URL and then pass that onto save to photo album. You then need to add an ‘exit shortcut’ otherwise the shortcut will do the same for every PNG on the page!

Have a go and if you need more help post back here. Pretty sure the above should work.

Edit: added the part about exiting the shortcut after you’ve found the first match.
 

StepanDolezal

macrumors newbie
Original poster
Sep 19, 2018
2
0
Do a ‘repeat with each’ on each URL returned from the get URLs from input.

Inside the repeat with each you need to do an if statement which does a match text using this pattern: “.+?\.png” (without the quotes).

If it does, do a get contents of URL and then pass that onto save to photo album. You then need to add an ‘exit shortcut’ otherwise the shortcut will do the same for every PNG on the page!

Have a go and if you need more help post back here. Pretty sure the above should work.

Edit: added the part about exiting the shortcut after you’ve found the first match.
Okay, tried it but failed. I am confused with how the order you suggest should go. Is it:


Get contents of web page
Get urls
Repeat with each
^Match Text .+?\.png
^if (equals: Text Matches)
^^get contents of url
^^save to photos
^^quit shortcut
^end if
End repeat

I cant get it working
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.