I touched Python's Request module for the first time. ** Can I create a query from JSON **? !! It's convenient! Great! → Reproduced with Shortcuts: relaxed:
This time, the URL for extracting the id from the Apple Music URL and requesting it to the iTunes Search API Is generated. 
Specify to get the query with
[Get URL component]
.
ʻI = 40284574` is output.
出力するURLのクエリーを
I want to set
country = jp & lang = ja_jp & id = 40284574
, so enter the value that matches it.
This variable * i * is the magic variable output from the [Get component of URL]
above. Like the GIF below
dictionary
This action allows you to convert ** ʻi = 40284574
to{"i": "40284574"}
and treat it as the value of the key ʻi`. ** (Very convenient)
By the way, if you try to do the same without using this tech, it will increase by 2 actions (see the image below). It is troublesome, so I strongly recommend using the above technique.
Put the
[dictionary]
keys (country
, lang
, ʻid) in
[repeat each item]to pair with the corresponding value. Using the technique above, treat the magic variables in the dictionary as a list (array) of keys.  Output a list by connecting keys and values with'=' in
[Repeat each item]. We've combined this list with
[Merge Text]` using'&' and plunged into the query part of the URL.
Recommended Posts