Advertisement
joric

resistance.py

May 5th, 2018
5,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import json
  3. import requests
  4.  
  5. morse = {
  6.     '..-.': 'F', '-..-': 'X', '.--.': 'P', '-': 'T', '..---': '2',
  7.     '....-': '4', '-----': '0', '--...': '7', '...-': 'V', '-.-.': 'C',
  8.     '.': 'E', '.---': 'J', '---': 'O', '-.-': 'K', '----.': '9', '..': 'I',
  9.     '.-..': 'L', '.....': '5', '...--': '3', '-.--': 'Y', '-....': '6',
  10.     '.--': 'W', '....': 'H', '-.': 'N', '.-.': 'R', '-...': 'B', '---..': '8',
  11.     '--..': 'Z', '-..': 'D', '--.-': 'Q', '--.': 'G', '--': 'M', '..-': 'U',
  12.     '.-': 'A', '...': 'S', '.----': '1'
  13. }
  14.  
  15. fname = 'd1_uniq_ip4.json'
  16.  
  17. try:
  18.     j = json.loads(open(fname).read())
  19. except:
  20.     j = requests.get('https://usher2.club/'+fname).json()
  21.     json.dump(j, open(fname, 'w'))
  22.  
  23. s, b, t0 = '', False, 0
  24. for pt in j:
  25.     t, h = pt['x'], pt['y']
  26.     a = h > 50000
  27.     if b != a:
  28.         dt = t - t0
  29.         t0 = t
  30.         if not b and dt > 1300 and s:
  31.             s += ' '
  32.         elif b and dt > 1300:
  33.             s += '-'
  34.         elif b and dt > 300:
  35.             s += '.'
  36.     b = a
  37.  
  38. print(s)
  39. print(''.join([morse.get(str(x), ' ') for x in s.split(' ')]))
  40.  
  41. # -.. .. --. .. - .- .-.. .-. . ... .. ... - .- -. -.-. .
  42. # DIGITALRESISTANCE
  43. # d1_uniq_ip4.json: https://pastebin.com/3MBSRsxq
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement