Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History Of Present Day #138

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions windows/activities.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ NOTE: All the recorded files will be saved on the desktop. Make sure that the fi
_draw graph for x**2+4*x+6 from -100 to 100_.
* "*_city_name_* ***boxoffice***" to get list of Movies from the Cinemas of Town within `Indian Region`.
* "***add event in google calendar*** to add event on your google calendar, type(or say) in the following format: "add event <event_name> <start date in format yyyy-mm-dd> to <end date in format yyyy-mm-dd>" and it will save the event on your google calendar.
* "***history of today***" to get details of `Historical Events` occured in the past on the `same Date`.
* "***play/stream/queue*** _Song/VideoName_" to play any song or video on Youtube.
* "***download video*** _SongName_" to download video.
* "***download music*** _SongName_" to download a song.
Expand Down
42 changes: 41 additions & 1 deletion windows/benji.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def events(frame,put):
download_music=("download ","download music ")
search_pc= ("find ","lookfor ")
graph_generation = ("draw graph for ")
close_keywords=("close ","over ","stop ","exit ")
history_today = ("history of today")
close_keywords = ("close ","over ","stop ","exit ")
pc_locations = ("desktop", "documents", "downloads")

put = put.lower()
Expand Down Expand Up @@ -418,6 +419,45 @@ def main():
speak.say("Sorry Graph can not be Plotted")
speak.runAndWait()

#On this Day
elif put.startswith(history_today):
try:
time = datetime.datetime.now()
url = "https://en.wikipedia.org/wiki/" + time.strftime("%B") + "_" + time.strftime("%d")

r = requests.get(url)
soup = BeautifulSoup(r.content, 'html.parser')
raw = soup.find_all('div', attrs={'class': 'mw-parser-output'})[0].find_all('ul')[1].find_all('li')
desc_raw = soup.find_all('div', attrs={'class': 'mw-parser-output'})[0].find_all('p')

hist = []
def cleaning(string):
cnt = string.find(">")
if cnt != -1:
cnt_2 = string.find("<")
string = string.replace(string[cnt_2 : cnt+1], "")
cleaning(string)
else:
string = string.replace(u'\xa0', u' ')
hist.append(string)

cleaning(str(desc_raw[1]))
for i in raw:
timeline_data = str(i)
cleaning(timeline_data)

for i in hist:
print("")
print("--------------------")
print(i)
print("--------------------")
print("")
print("--------------- END ---------------")

except:
print("ER")


#Box Office Status
elif link[-1] == "boxoffice":
try:
Expand Down