Last active
November 27, 2019 12:21
-
-
Save faressoft/ca87c8b92e88dba6cac77870b4f08bf9 to your computer and use it in GitHub Desktop.
IZDB Azhan Script
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
#!/usr/bin/env node | |
/** | |
* Azhan | |
* Display prayer times for today from IZDB | |
* | |
* Installation | |
* - Install Node.js | |
* - Create a directory and execute `npm init --yes` | |
* - CD to the directory and execute `npm install --save table chalk` | |
* - Save this script as a file named `azhan` | |
* - Give it execution permissions `chmod +x azhan` | |
* - Execute `ln -s /Path/To/The/Script/Here/azhan /usr/local/bin/azhan` | |
* - Now you can show azhan times using `azhan` in your terminal | |
* | |
* PreRequirements: | |
* - Download a prayer times photo from https://fb.com/pg/izdb.berlin/photos/?ref=page_internal | |
* - Scan it using https://www.onlineocr.net and copy the text | |
* - Remove new lines and replace the value of the `text` variable | |
* | |
* Usage: azhan | |
* | |
* @author Mohammad Fares <[email protected]> | |
*/ | |
const table = require('table'), | |
chalk = require('chalk'); | |
let matches = []; | |
const now = new Date(); | |
const day = now.getDate(); // 1 - 31 | |
const pattern = /(\d+:\d+) (\d+:\d+) (\d+:\d+) (\d+:\d+) (\d+:\d+) (\d+:\d+)/gm; | |
const prayersNames = ['Fajr', 'Sunrise', 'Duhr', 'Aser', 'Maghrib', 'Ishaa']; | |
const text = `Einheitliche Gebetszeiten fOr Berlin and ihre Umgebung 1 I , November 146 Likul Datum FrUhlicht S'Aufgang Mittag Nachmittag Abend Nacht 1 5:26 7:01 11:55 14:14 16:42 18:12 2 5:28 7:03 11:55 14:14 16:40 18:10 3 5:30 7:05 11:55 14:13 16:38 18:08 4 5:31 7:07 11:55 14:11 16:37 18:07 5 5:33 7:08 11:55 14:10 16:35 18:05 6 5:34 7:07 11:55 14:07 16:33 18:03 7 5:36 7:10 11:56 14:07 16:31 18:01 8 5:38 7:14 11:56 14:06 16:29 18:00 9 5:39 7:16 11:56 14:05 16:28 17:58 10 5:41 7:18 11:56 14:03 16:26 17:56 1 1 5:42 7:19 11:56 14:02 16:24 17:55 12 5:44 7:21 11:56 14:01 16:23 17:53 13 5:45 7:23 11:56 14:00 16:22 17:52 14 5:47 7:25 11:56 13:59 16:20 17:50 15 5:48 7:27 11:56 13:58 16:19 17:49 16 5:50 7:28 11:57 13:57 16:17 17:47 17 5:51 7:30 11:57 13:56 16:16 17:46 18 5:53 7:32 11:57 13:54 16:14 17:45 19 5:54 7:34 11:57 13:54 16:13 17:43 20 5:56 7:35 11:58 13:53 16:12 17:42 21 5:57 7:37 11:58 13:52 16:11 17:41 22 5:58 7:39 11:58 13:51 16:10 17:40 23 6:00 7:40 11:58 13:50 16:09 17:39 24 6:01 7:42 11:59 13:49 16:07 17:38 25 6:03 7:44 11:59 13:49 16:07 17:37 26 6:04 7:45 11:59 13:48 16:05 17:36 27 6:05 7:47 12:00 13:47 16:05 17:35 28 6:06 7:48 12:00 13:47 16:04 17:34 29 6:08 7:50 12:00 13:46 16:03 17:33 30 6:09 7:51 12:01 13:45 16:02 17:32 13 IZDB e.V. re: 030/49500803 [email protected] IZDB e.V. Q Drontheimer Str. 32a www.izdb-berlin.de`; | |
// Extract data | |
while (match = pattern.exec(text)) matches.push(match.slice(1, 7)); | |
console.log(table.table([prayersNames.map((item) => chalk.green(item)), matches[day - 1]], { | |
border: table.getBorderCharacters('ramac') | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment