New AutoApps plugin - AutoTools ! Advanced Regex and JSON parser and more!
I am very excited about this new AutoApps plugin named AutoTools. Here is a quick video and details of this new plugin - https://plus.google.com/+Jo%C3%A3oDias/posts/ho992Xp13oK
As it this plugin is currently in Alpha release you'll need to have the main AutoApps suite to get access to it, but for those who are subscribers etc it's the usual process of signing up to be an Alpha tester and then it give you access to it in the PlayStore.
In a nutshell - the two main components are an advanced Regex implementation that goes WELL beyond Tasker's "Search Replace" Action, as well as a convenient user-friendly JSON parser.
For some details on Tasker's built-in shortcomings in regards to Regex reference this thread
What does this mean for the average Tasker user? Well it means quick pulling and parsing of a piece of data from a string of text, most often a large string like a web page's html, or a return of some type from an HTTP Get Action whereby you're just looking for one particular piece of data from a whole long pile of non-sense data. In addition, you can use this plugin to get specific JSON data from anywhere online that supplies such information.
To begin with AutoTools Regex - in the past - using Tasker's built-in Search/Match/Replace Action this would involves first Regex'ing and then another Reg'ex or Split and then another Split to whittle the data down until you get exactly the piece you want, store the Matche(s) in an array in that Action, and finally extract your desired data to a variable. This new AutoApps plugin uses matching as well as non-matching Regex groups to IMMEDIATELY assign variable names to matched pieces of data.
For example take these example strings of text:
"There are many birds in the jungle."
"There are many monkeys in the jungle."
"There are many tigers in the jungle."
etc. etc.
Then using this Regex with the new AutoTools plugin:
(?:There are many )(?<animal>birds|monkeys|tigers)(?: in the jungle.)
You would immediately get the Tasker variable:
%animal=monkeys
...or whatever was in the original string. Whereas before with the default Tasker action you'd have to split it and regex it, and assign matches to an array and use a numbered array element to get the animal, etc.
Or lets say you wanted to leave it open ended:
(?:There are many )(?<animal>[a-zA-Z ]{4,30})(?: in the jungle.)
For any animal name from 4 to 30 characters, including a space perhaps, so:
"There are many orangutans in the jungle."
"There are many tiger cubs in the jungle."
You'd immediately get
%animal=orangutans
<or>
%animal=tiger cubs
AWESOME!
To go even a step further using the above example, this plugin also returns an array named regexgroups() so any capturing group, named or not, will be in this array. So pre-named variables or not in the Regex - you can retrieve all the separated groups immediately without splitting and splitting as before in regular Tasker Action(s).
Update: The AutoTools Regex now supports multiple named groups returned as arrays with as many values as are matched. Details.
On the JSON part, the video shows how this makes parsing and retrieving the variables/data you desire from a web service that returns data in JSON very simple now.
In the video it further enhances it using an AutoVoice request for the data. This is cool stuff for anyone who's been creating their own JSON parsers through Java(script)(let) or anyone who's unfimiliar with JSON but just wants to get the damn data in an easy way lol.
As you'll even see in the comments related to the video link, someone there commented how they just spent a whole long bunch of time building a Tasker JSON solution, only to see this plugin come out this morning that would have saved him a ton of time and frustration.'
Update: On the JSON part the functionality has been enhanced so that in one instance of the plugin running, as many fields can be returned as you'd like, and they can be custom named to whatever array(s) you'd like by comma separating them.
For example if you've got JSON objects:
cars.forsale.type
cars.forsale.year
cars.forsale.color
cars.forsale.price
The plugin will return every instance of each, so if there's 22 cars for sale, you'll get 4 arrays with 22 values in each, named either as the objects with underscores instead of dots as:
%cars_forsale_type()
%cars_forsale_year()
%cars_forsale_color()
%cars_forsale_price()
Or in the plugin you can rename any as you wish so after that Action runs you could get -
%car_type()
%year_made()
%current_color()
%whats_it_cost()
Update: The AutoTools JSON now has an Easy Setup Mode (labelled Simple Mode) where by to get all the results for a deeply nest JSON field, and/or a field you may not have the full path to or trouble finding out, like:
cars.forsale.unitedstates.california.losangeles.model.camaro.images
All you have to is have Simple Mode selected and enter "images" and AutoTools will return all the images without needing to know that big long path beforehand.
Conversely, AutoTools also has a new 'JSON Query' mode where if you want to the find the path to a field you know exists somewhere in a large JSON data page/set, and want to specifically use the exact path for certain reasons, AutoTools JSON Query will return the path. So in looking at http://www.reddit.com/r/aww.json - if you Query for "url" and there are three paths/places in the JSON where "url" if a field, AutoTools will return all the paths for you to reference, which in this case are:
data.children.data.url
data.children.data.preview.images.source.url
data.children.data.preview.images.resolutions.url
UPDATE July 2015: AutoTools has added even more Tools. One being a function to pad text to ensure multiple variables are all the same length, as well as easily turn any numeric variable into currenty (i.e. 3486.5 immediately becomes $3,486.50). Multiple variable can be processed all at once.
Another Tool added is an Easy Vibration Pattern creator, where you can simply tap the vibration pattern on the screen and use it in your current Task or save it to a variable for later use! This is a huge improvement over Tasker's built-in Vibrate Pattern Action where Tasker wants an almost indecipherable string of numbers to create your pattern.
Posted Jun 24, 2015, 4:53 PM UTC · edited