-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (26 loc) · 858 Bytes
/
main.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
import json
import os
import random
from datetime import date
CURRDIR = os.path.dirname(os.path.realpath(__file__))
YELLOW = (194,217,76)
PINKISH = (248,131,121)
def loadQuotes():
with open (f'{CURRDIR}/quotes.json') as f:
# Reading from file
data = json.load(f)
return data
def to_coloured(col):
return f"\x1b[38;2;{col[0]};{col[1]};{col[2]}m"
quotes = loadQuotes().get("quotes")
curr_date = date.today()
# always the same seed
random.seed(1)
# position in shuffled array
position = curr_date.day + curr_date.month * 31 + curr_date.year * 365
# shuffle the quotes
random.shuffle(quotes)
randomQuote = quotes[position % len(quotes)]
bold = "\033[1m"
print(bold + to_coloured(YELLOW) + randomQuote.get("text") + \
to_coloured(PINKISH) + "\n- " + randomQuote.get("author"))