Advertisement
Guest User

Untitled

a guest
Nov 9th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set mJson to do shell script "curl -s 'https://api.coinmarketcap.com/v1/ticker/sentinel-chain/'"
  2. set AppleScript's text item delimiters to {","}
  3. set keyValueList to (every text item in mJson) as list
  4. set AppleScript's text item delimiters to ""
  5.  
  6. set theKeyValuePair to item 5 of keyValueList
  7. set AppleScript's text item delimiters to {": "}
  8. set theKeyValueBufferList to (every text item in theKeyValuePair) as list
  9. set AppleScript's text item delimiters to ""
  10. set usdPrice to item 2 of theKeyValueBufferList
  11.  
  12.  
  13. set theKeyValuePair to item 12 of keyValueList
  14. set AppleScript's text item delimiters to {": "}
  15. set theKeyValueBufferList to (every text item in theKeyValuePair) as list
  16. set AppleScript's text item delimiters to ""
  17. set change to item 2 of theKeyValueBufferList
  18.  
  19. set usdPrice to (RemoveFromString("\"", usdPrice) * 100) / 100
  20. set change to RemoveFromString("\"", change)
  21.  
  22. set arrow to " ▲"
  23.  
  24. if change < 0 then
  25.     set arrow to " ▼"
  26. end if
  27.  
  28. set unformatedValue to "$ " & usdPrice & " " & arrow & " " & change & "%"
  29.  
  30. return RemoveFromString("\"", unformatedValue)
  31.  
  32.  
  33. -- remove character or string from given string
  34. on RemoveFromString(CharOrString, txt)
  35.     set AppleScript's text item delimiters to CharOrString
  36.     set temp to txt's text items
  37.     set AppleScript's text item delimiters to ""
  38.     return temp as text
  39. end RemoveFromString
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement