Advertisement
mobbyg

CC Dashboard

Nov 26th, 2022
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.38 KB | Source Code | 0 0
  1. Error:
  2. 2022.11.26 13:08:38 An error has occured: EAccessViolation Access violation
  3. 2022.11.26 13:08:38 Shutting down
  4.  
  5. Python Code:
  6.  
  7. #######################################################################
  8. # Crypto Currency Dashboard v0.1a                                     #
  9. # (C) 2021 Richard L. Gattie II                                       #
  10. # Written for the Radio Freqs & Geeks BBS                             #
  11. # Release under Creative Commons License Attribution-ShareAlike 4.0   #
  12. # https://creativecommons.org/licenses/by-sa/4.0/legalcode            #
  13. #                                                                     #
  14. # This code is free to use and redistibute as well as modify, adapt,  #
  15. # and build upon your work even for commercial purposes, as long as   #
  16. # they credit you and license their new creations under the identical #
  17. # terms. This license is often compared to "copyleft" free and open   #
  18. # source software licenses. All new works based on                    #
  19. # yours will carry the same license, so any derivatives will also     #
  20. # allow commercial use.                                               #
  21. #                                                                     #
  22. # Please see the README file for install instructions.                #
  23. #                                                                     #
  24. #######################################################################
  25.  
  26. #Import da' stuff!
  27. from mystic_bbs import *
  28. from requests import Request, Session
  29. from requests.exceptions import ConnectionError, Timeout, TooManyRedirects
  30. import mystic_bbs as bbs
  31. import json
  32. import sys
  33.  
  34. # Where to get the info from
  35. url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest'
  36. cc_id = bbs.param_str(1)
  37.  
  38. # Grabs data for the Crypto using your API Key
  39. parameters = {
  40.   'id':cc_id
  41. }
  42. headers = {
  43.   'Accepts': 'application/json',
  44.   'X-CMC_PRO_API_KEY': 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
  45. }
  46.  
  47. session = Session()
  48. session.headers.update(headers)
  49.  
  50. # Try, Try Again.. or ERROR!!!
  51. try:
  52.   response = session.get(url, params=parameters)
  53.   data = json.loads(response.text)
  54.  
  55. # Assign them
  56.   for cc_coin in data['data']:
  57.     cc_coin = str(cc_coin)
  58.  
  59.     cc_symbol = data['data'][cc_coin]['symbol']
  60.     cc_cost = data['data'][cc_coin]['quote']['USD']['price']
  61.     cc_24vol = data['data'][cc_coin]['quote']['USD']['volume_24h']
  62.     cc_percent1 = data['data'][cc_coin]['quote']['USD']['percent_change_1h']
  63.     cc_percent24 = data['data'][cc_coin]['quote']['USD']['percent_change_24h']
  64.     cc_percent7d = data['data'][cc_coin]['quote']['USD']['percent_change_7d']
  65.     cc_percent30d = data['data'][cc_coin]['quote']['USD']['percent_change_30d']
  66.     cc_lastupdate = data['data'][cc_coin]['quote']['USD']['last_updated']
  67.  
  68. # Make Them Strings
  69.     cc_cost = str(cc_cost)
  70.     cc_24vol = str(cc_24vol)
  71.     cc_percent1 = str(cc_percent1)
  72.     cc_percent24 = str(cc_percent24)
  73.     cc_percent7d = str(cc_percent7d)
  74.     cc_percent30d = str(cc_percent30d)
  75.  
  76. # Show the goods...
  77.     showfile(cc_symbol+".ANS",0,0,1,0)
  78.     write("|[X51|[Y04|16|09$"+cc_cost)
  79.     write("|[X55|[Y06"+cc_24vol)
  80.     write("|[X55|[Y08"+cc_percent1)
  81.     write("|[X60|[Y10"+cc_percent24)
  82.     write("|[X59|[Y12"+cc_percent7d)
  83.     write("|[X60|[Y14"+cc_percent30d)
  84.     write("|[X00|[Y23|00|PN")
  85. except (ConnectionError, Timeout, TooManyRedirects) as e:
  86.   print(e)
  87. else:
  88.   pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement