-
Notifications
You must be signed in to change notification settings - Fork 0
/
cov19ind.py
72 lines (59 loc) · 2.69 KB
/
cov19ind.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'''
Create on Sun Apr 31 19:00 2020
@author : Rivas Frits Sasia
'''
#Import Module
from colorama import Fore, Back, Style
from datetime import datetime
from os import system, name
import urllib
import json
#Color
RED = Fore.RED
WHITE = Fore.WHITE
YELLOW = Fore.YELLOW
GREEN = Fore.GREEN
CYAN = Fore.CYAN
BLUE = Fore.BLUE
#Detect OS and Clear Terminal
if name == 'posix':
_ = system('clear')
elif name == 'nt':
_ = system('cls')
#Header
print " " + RED + " ______ ______ ____ ____ __ ___ __ .__ __. _______ "
print " " + RED + " / | / __ \ \ \ / / /_ | / _ \ | | | \ | | | \ "
print " " + RED + " | ,----'| | | | \ \/ / ______| | | (_) | | | | \| | | .--. | "
print " " + WHITE + " | | | | | | \ / |______| | \__, | | | | . ` | | | | | "
print " " + WHITE + " | `----.| `--' | \ / | | / / | | | |\ | | '--' | "
print " " + WHITE + " \______| \______/ \__/ |_| /_/ |__| |__| \__| |_______/ "
print " " + GREEN + " TRACKING COVID-19 "
print " " + RED + " Country : "+ WHITE +" Indonesia "
print " " + GREEN + " Author : Frits Sasia "
api = "https://coronavirus-19-api.herokuapp.com/countries/Indonesia" # API public
link_json = urllib.urlopen(api) # Mengakses API
status_code = link_json.getcode() # Mendapatkan response/status code
if status_code == 200: # if else
data = json.loads(link_json.read()) # Membaca data berformat JSON, dari API
else:
print RED+"ERROR"
now = datetime.now() # Waktu Sekarang
day = now.day #Tanggal
mounth = now.month # Bulan
year = now.year # Tahun
hour = now.hour # Jam
minute = now.minute # Menit
second = now.second # Detik
print ""
print GREEN+"Berikut Data Terbaru Tentang Perkembangan"+RED+" COVID-19"+WHITE+" Di Indonesia : "
print GREEN+"Tanggal & Waktu {}-{}-{} {}:{}:{}".format(day, mounth, year, hour, minute, second) # Informasi Tanggal dan Waktu
print ""
# Fetching dan menampilkan data dari JSON
print GREEN+"Negara\t\t\t\t: %s" % data['country']
print YELLOW+"Kasus Hari Ini\t\t\t: %s" % data['todayCases'] + str(' Orang')
print RED+"Kematian Hari Ini\t\t: %s" % data['todayDeaths'] + str(' Orang')
print GREEN+"Sembuh\t\t\t\t: %s" % data['recovered'] + str(' Orang')
print YELLOW+"Total Kasus\t\t\t: %s" % data['cases'] + str(' Orang')
print RED+"Total Kematian\t\t\t: %s" % data['deaths'] + str(' Orang')
print ""
print GREEN+"Jangan panik, stay safe"+RED+" #TetapDi"+WHITE+"rumahAja "+GREEN+"dan jaga kesehatan kamu yaa :)"