Last active
October 25, 2023 21:16
-
-
Save arfan/b5f092f1d72a937bae18cc801dca59be to your computer and use it in GitHub Desktop.
jadwal sholat command line using python and curl with api from myquran, hard coded jakarta city
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python | |
import json | |
import subprocess | |
from datetime import datetime | |
now = datetime.now() | |
current_date = now.strftime("%Y/%m/%d") | |
jakarta_city_code = "1301" | |
result = subprocess.run(["curl", f"https://api.myquran.com/v1/sholat/jadwal/{jakarta_city_code}/{current_date}"], | |
stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
result_json = json.loads(result.stdout) | |
print(result_json["data"]["lokasi"]) | |
print(result_json["data"]["daerah"]) | |
print(f'Hari/Tanggal: {result_json["data"]["jadwal"]["tanggal"]}') | |
print(f'- imsak {result_json["data"]["jadwal"]["imsak"]}') | |
print(f'- subuh {result_json["data"]["jadwal"]["subuh"]}') | |
print(f'- terbit {result_json["data"]["jadwal"]["terbit"]}') | |
print(f'- dhuha {result_json["data"]["jadwal"]["dhuha"]}') | |
print(f'- dzuhur {result_json["data"]["jadwal"]["dzuhur"]}') | |
print(f'- ashar {result_json["data"]["jadwal"]["ashar"]}') | |
print(f'- maghrib {result_json["data"]["jadwal"]["maghrib"]}') | |
print(f'- isya {result_json["data"]["jadwal"]["isya"]}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment