Search Results for 'script'
-
Search Results
-
Topic: Shopping List
Someone expressed and interest in this, so I am uploading it. Thanks to Sam for all his help!
This is a simple Shopping List. There are 3 forms. The actual shopping list form, a category form and a products form (which contains the items to populate the shopping list with).
Adding an item to the shopping list is done via a Siri Shortcut (see attached screenshot).
The expected input to the shortcut is <number> item. If a number is not provided, 1 is assumed. For example, you could say ‘3 Peaches’ or ‘Heavy Cream’.
When an item is added to the shopping list, it will see if it exists in the product form. If it does, the item will be also given a category (if it exists). If the item does not exist, it will be added to products, but it will not have a category (this will have to be added manually).
Items are sorted in the Shopping List alphabetically, by category.
There is only 1 script ‘Get Item From Clipboard’ and it does all the work.
Enjoy!
I created a document/form/script. The script worked just fine in Tap Forms. Then I added the script to Siri. I created a Shortcut that used the action to execute the script in the form. However, it did NOT work; I got an error saying that the run was taking too long.
When I switched to using the x-callback (as suggested), everything was happy.
The document in question and a screenshot of the shortcut can be found in this thread
Inspired by this post detailing how to get watched TV shows, I decided to attempt a Movie import script via TheMovieDB’s API. I’m very new to scripting (really only used iOS Shortcuts) and have gotten stuck and could use some direction or assistance.
The big issue I can’t seem to crack is iterating through the JSON for to pull out the cast and add them to the cast table on the form. I’ve looked through the example of the above of pulling the singular episode details, but the JSON for TheMovieDB is more robust than OMDB and I’ve confused myself.
Any Ideas?
var tmdbAPI = 'xxx'; var title_id = 'fld-7f17a3883cf742ca90a732565f687953'; var released_id = 'fld-4f1d3a5878914910954b65c2f782abfd'; var imdbid_id = 'fld-0b8bd8338d8f494aa5b7099c42230e70'; var poster_id = 'fld-bace3b81b9ab4cc9951a9445d12a63b3'; var summary_id = 'fld-d16b4361266b48ee9c3b88afd29fd5ac'; var runtime_id = 'fld-f096b51db4c447e18bf10298135dfaa8'; var tagline_id = 'fld-ac1ad056b5004ed8a19f8d272ae01e2b'; var cast_id = 'fld-0b85d9aef49f4fd58726f6830a03ba11'; var actor_id = 'fld-07249465a7ea45e8830da27e62b3121d'; var role_id = 'fld-bf225b3c443248fd97c5737312acd28b'; var itemID; function fetchDetailsFromURL() { fetchURL = <code>https://api.themoviedb.org/3/movie/${itemID}?api_key=${tmdbAPI}&language=en-US</code>; return Utils.getJsonFromUrl(fetchURL); } function fetchCastFromURL() { fetchURL = <code>https://api.themoviedb.org/3/movie/${itemID}/credits?api_key=${tmdbAPI}&language=en-US</code>; return Utils.getJsonFromUrl(fetchURL); } function getCast() { var cast = fetchCastFromURL() return cast } function getData() { var film = fetchDetailsFromURL(); var imdbID = film.imdb_id; console.log(imdbID) var itemIds = new Set(); var currentItemsByImdbID = {}; var allCurrentItems = form.getRecords(); for (let currentItems of allCurrentItems) { currentItemsByImdbID[currentItems.getFieldValue(imdbid_id)] = currentItems; itemIds.add(currentItems.getFieldValue(imdbid_id)); } let newRecord; if (itemIds.has("http://imdb.com/title/" + imdbID)) { Utils.alertWithMessage(film.title + ' already exists.', 'Sorry.'); } else { newRecord = form.addNewRecord(); newRecord.setFieldValues({ [title_id]: film.title, [released_id]: film.release_date, [imdbid_id]: "http://imdb.com/title/" + film.imdb_id, [summary_id]: film.overview, [runtime_id]: film.runtime, [tagline_id]: film.tagline, }) } var Poster = "https://www.themoviedb.org/t/p/w1280/" + film.poster_path if (Poster != null) { newRecord.addPhotoFromUrlToField(Poster, poster_id); } form.saveAllChanges(); } var prompter = Prompter.new(); prompter.cancelButtonTitle = 'Cancel'; prompter.continueButtonTitle = 'Go'; prompter.addParameter('TMDB Number', 'itemID'); prompter.show('Enter an TMDB code', getData)Here are the TMdb API details: https://developers.themoviedb.org/3/movies/get-movie-credits