Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set mJson to do shell script "curl -s 'https://api.coinmarketcap.com/v1/ticker/sentinel-chain/'"
- set AppleScript's text item delimiters to {","}
- set keyValueList to (every text item in mJson) as list
- set AppleScript's text item delimiters to ""
- set theKeyValuePair to item 5 of keyValueList
- set AppleScript's text item delimiters to {": "}
- set theKeyValueBufferList to (every text item in theKeyValuePair) as list
- set AppleScript's text item delimiters to ""
- set usdPrice to item 2 of theKeyValueBufferList
- set theKeyValuePair to item 12 of keyValueList
- set AppleScript's text item delimiters to {": "}
- set theKeyValueBufferList to (every text item in theKeyValuePair) as list
- set AppleScript's text item delimiters to ""
- set change to item 2 of theKeyValueBufferList
- set usdPrice to (RemoveFromString("\"", usdPrice) * 100) / 100
- set change to RemoveFromString("\"", change)
- set arrow to " ▲"
- if change < 0 then
- set arrow to " ▼"
- end if
- set unformatedValue to "$ " & usdPrice & " " & arrow & " " & change & "%"
- return RemoveFromString("\"", unformatedValue)
- -- remove character or string from given string
- on RemoveFromString(CharOrString, txt)
- set AppleScript's text item delimiters to CharOrString
- set temp to txt's text items
- set AppleScript's text item delimiters to ""
- return temp as text
- end RemoveFromString
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement