Automator: Removing the program icon from the App Store
Makradar Technologies / / December 19, 2019
Instead of artificial examples of the use of automation tools on the Mac, here's a real program Service, which is used by some authors "MakRadara", in particular when preparing images for reviews applications. Through this service, the download icon of any application, available in the App Store and Mac App Store, it becomes easy and fast.
For example, take the iOS-program "Buy a loaf". That before the editors do manually... First, the browser opens the page program in the App Store, and from the address This page was copied 9 tsiferny identifier (each program has his own), which is then substituted into address http://itunes.apple.com/lookup? id =. For example, if the address is "Buy a loaf of" page in App Store - https://itunes.apple.com/ru/app/id725418306 (Program code shown in bold), the editor via "copy-paste" loads the page in the browser window http://itunes.apple.com/lookup? id =725418306.
Content on this page - comprehensive information about the relevant program as a commodity unit in the App Store. All data is presented as a structure, the basis of which - paired values of the form "key value". If the text of the page to find the "key" artworkUrl512Then behind him you will see its value - a long web address to which is the icon of our program in the maximum resolution. It only remains to copy the address and paste it into the address bar - and get the desired picture.
Even if you save the whole procedure - what it be done manually, if you can automate? Will call for help Automator!
First, form the algorithm
The above sequence of steps is very simple, but to "go" I want to add a little more "Shashechek": only for user convenience, we supplement our sequence has a pair steps:
- Of addresses App Store page loaded extract and remember the ID program.
- Run the server-side script in the browser itunes.apple.com/lookupAssigned to it a program code from step 1, and memorize the resulting stream of text data.
- In the obtained in step 2, the data stream by the key trackName We are looking for the name of the program and store it.
- In the obtained in step 2, the data stream by the key artworkUrl512 We are looking for the address of icons and remember it.
- Icons take address obtained in the step 4, and load it on the desktop image.
- The downloaded file picture rename the title of the program obtained in step 3.
- …
- PROFIT.
Now build service
We proceed to the assembly of our algorithm in "Avtomatore". Create a new type of process Service, And in the header field of the program select: in the first drop-down list value
Come clearly in our algorithm.
Step 1. Take the ID of the program and form a treatment address to the script lookup
of section the Internet in the side area "Avtomatora" drag library to the main scope of the program window Get current page from Safari. Configure this action does not need to. The result of this action: web address of the current page in the "Safari" (we assume that this App Store page), which will be handed over to the next step.
of section Utilities add operation Run the shell-script, Be sure to select from the dropdown list Pass input: paragraph as arguments. Because the script, I was in the language of "Python" in the drop-down list Shell I selected the /usr/bin/python. This simple code takes the first action of the web address from which, with the help of mechanism of regular expressions (Fragment search string in a predetermined pattern), retrieves a fragment consisting solely of nine digits. The result of this action: nine-digit identifier of the application that will be passed to the next action.
Step 2. We get Apple's server data about the program
of section the Internet add operation Get text from a web pageBy selecting from the dropdown list Get paragraph plain text. The result of this action: text that will generate Apple server and which we will look for the program name and path to the icon.
The resulting text we still need, and that is not re-apply to the Apple server, this text can be saved in a variable. For this section of the Utilities add operation Set the value of the variable. In the drop-down list Variable select The new variable - in the blue box that appears, enter the variable name lookup and click Done. The result of this action: resulting from previous actions of the text will be stored in the variable lookup.
Of course, the names of the variables you can specify in its sole discretion - even allowed Russian names. It is only necessary to see to it that these variables are correctly placed in the service of the algorithm.
Step 3. We are looking for the name of the program
Previous action sends a text array in the initial state received earlier, so we just can "attach" the next action - Run the shell-script of section Utilities. This action parameters are the same as those of a similar effect, the second from the top: /usr/bin/python in the first drop-down list and as arguments - in the second. The scenario in this action also uses regular expressions, twice: first is the key and value ("TrackName": "Buy Me a Pie! - Grocery Shopping List "), And then from the resulting strings are cut all the extra characters, to keep the name of the program. The result of this action: get the full name of the program, in this example, Buy Me a Pie! - Grocery Shopping List - and it is passed to the next action.
Now is not the name of the program we need to - you will need it later. Therefore, it should be stored in a new variable. of section Utilities add operation Set the value of the variable and repeat the same manipulation as with previous similar action - only this time, create a variable named appName. The result of this action: until the end of the algorithm execution all in a variable appName It will store the name of the program received in the previous step.
Step 4. We are looking for icons web address
"Avtomator" is so constituted that the result of the action predudyschego passed to the next. But we need now is not the name of the program, and the original text information about it, where we will look for the address of the icon. Therefore, in the section Utilities add operation Get the value of a variable - just right-click on the title of this action and the pop-up menu, choose ignore input. Now the action with which you are working now, will never take into account the result of the previous action, that there no matter what happens. In the drop-down list Variable select lookup. The result of this action: the next step will be transferred to the value of lookupIn which we have previously saved the text information about the program.
of section Utilities add operation Run the shell-script with the same parameters as the action of the same name in the second and fifth positions in our algorithm. The scenario in this action is similar to the code that is in the fifth "scripting" action sought the program name: is the key and value pair ("ArtworkUrl512": " http://a1013.phobos.apple.com/us/↵ r30 / Purple6 / v4 / c7 / 9d / 77 / c79d778f-89a1-a925-b424-0e43819dfbba / mzl.xsxlaekt.png "), Which removes all the quotes, the colon and the name of the key. The result of this action: We get the web address of the icon that is passed to the next step.
Step 5. Load icons on the desktop
of section the Internet add operation Download URLAnd in the drop-down list Where enter the desktop folder. The result of this action: upon receipt of a previous action at the desktop icons will be downloaded the file.
Step 6. Ask the downloaded file name of the program
Look again at the web address icon listed two paragraphs above: the file will be loaded with the name mzl.xsxlaekt.png. Of course, you can leave and so, but to be beautiful, this name can be changed to the name of the program that we have already found and stored in the variable appName.
of section Files and folders add operation Rename Finder Items and set it up that way. Basically the drop-down list, select The name of a single objectAnd drop-down list Name select Only the principal name. Now the text field before - drag the variable into it appNameWhich is available in the list of variables in the bottom of the window "Avtomatora". The result of this action: the downloaded file will be renamed with the retaining extension. In our example, we get ready image as a file Buy Me a Pie! - Grocery Shopping List.png.
Step 7. Something else…
Everything to be very nice, you can add a pop-up notification - this feature has appeared in "Avtomatore" with the release of OS X 10.9. of section Utilities add operation Show notification. The first heading, enter the name of the service is almost finished - Download the app iconWhile in the field Message enter a short text like "icon is loaded on your desktop."
Step 8. PROFIT
All our team is ready to work and defense. Save it as Download the app icon and immediately go to the Safari. Opening it any page from the App Store and Mac App Store, search for it in Safari> Service new item Download the app icon - and clicking on it, just run the service saved. After a second or two, depending on the power of your Mac, you will notice - and an icon on the desktop, which can easily be used in further work.
"Yes, it's hard for me!"
In fact, in the process described above is nothing complicated. I myself am not a programmer (although the basics of programming after the Institute still remember), but it was enough to spend three hours at a leisurely search address specific interim targets (for example, I did not know the syntax of regular expressions in the "Python" - had pretty Googling) - and the trick hat. I am pleased that at least some people in our team found a way to produce apps icons easier.
For convenience, you can already download a ready-made service on the button below. Opening the workflow-object "Avtomatore" can carefully examine the contents and settings of each activity to all the foregoing it was understandable.
Download service (ZIP-files, 413 KB)
If someone of you know how to optimize the above algorithm, or can suggest a way simpler - I ask in the comments. :)