-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccffb19
commit 55661f8
Showing
11 changed files
with
167 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Import the required module for text | ||
# to speech conversion | ||
from gtts import gTTS | ||
from playsound import playsound | ||
|
||
# This module is imported so that we can | ||
# play the converted audio | ||
import os | ||
|
||
# The text that you want to convert to audio | ||
mytext = 'Welcome to binarynote.com and this is really amazing my dear!' | ||
|
||
# Language in which you want to convert | ||
language = 'en' | ||
|
||
# Passing the text and language to the engine, | ||
# here we have marked slow=False. Which tells | ||
# the module that the converted audio should | ||
# have a high speed | ||
myobj = gTTS(text=mytext, lang=language, slow=False) | ||
|
||
# Saving the converted audio in a mp3 file named | ||
# welcome | ||
myobj.save("welcome.mp3") | ||
|
||
# Playing the converted file | ||
#os.system("mpg321 welcome.mp3") | ||
playsound("welcome.mp3") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
x = [10,20,30,40,50] | ||
y = [14,20,25,30] | ||
z = [] | ||
i=j=k=0 | ||
while(i<5 and j<4): | ||
if(x[i]<y[j]): | ||
z.append(x[i]) | ||
i = i+1 | ||
else: | ||
z.append(y[j]) | ||
j = j+1 | ||
while(i<4): | ||
z.append(x[i]) | ||
i = i+1 | ||
while(j<5): | ||
z.append(y[j]) | ||
j = j+1 | ||
print(z) | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import time | ||
import notify2 | ||
from topNews import topStories | ||
|
||
# path to notification window icon | ||
ICON_PATH = "put full path to icon image here" | ||
|
||
# fetch news items | ||
newsitems = topStories() | ||
|
||
# initialise the d-bus connection | ||
notify2.init("News Notifier") | ||
|
||
# create Notification object | ||
n = notify2.Notification(None, icon = ICON_PATH) | ||
|
||
# set urgency level | ||
n.set_urgency(notify2.URGENCY_NORMAL) | ||
|
||
# set timeout for a notification | ||
n.set_timeout(10000) | ||
|
||
for newsitem in newsitems: | ||
|
||
# update notification data for Notification object | ||
n.update(newsitem['title'], newsitem['description']) | ||
|
||
# show notification on screen | ||
n.show() | ||
|
||
# short delay between notifications | ||
time.sleep(15) |
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rakesh ="This is my first attempt my in python" | ||
new1 = rakesh.split('my') | ||
print(new1) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from subprocess import call | ||
call(["notify-send", "This is title!", "This is message body!"]) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import requests | ||
import xml.etree.ElementTree as ET | ||
|
||
# url of news rss feed | ||
RSS_FEED_URL = "http://www.hindustantimes.com/rss/topnews/rssfeed.xml" | ||
|
||
def loadRSS(): | ||
''' | ||
utility function to load RSS feed | ||
''' | ||
# create HTTP request response object | ||
resp = requests.get(RSS_FEED_URL) | ||
|
||
# return response content | ||
return resp.content | ||
|
||
def parseXML(rss): | ||
''' | ||
utility function to parse XML format rss feed | ||
''' | ||
# create element tree root object | ||
root = ET.fromstring(rss) | ||
|
||
# create empty list for news items | ||
newsitems = [] | ||
|
||
# iterate news items | ||
for item in root.findall('./channel/item'): | ||
news = {} | ||
|
||
# iterate child elements of item | ||
for child in item: | ||
|
||
# special checking for namespace object content:media | ||
if child.tag == '{http://search.yahoo.com/mrss/}content': | ||
news['media'] = child.attrib['url'] | ||
else: | ||
news[child.tag] = child.text.encode('utf8') | ||
newsitems.append(news) | ||
|
||
# return news items list | ||
return newsitems | ||
|
||
def topStories(): | ||
''' | ||
main function to generate and return news items | ||
''' | ||
# load rss feed | ||
rss = loadRSS() | ||
|
||
# parse XML | ||
newsitems = parseXML(rss) | ||
return newsitems |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
import requests | ||
import time | ||
from win10toast import ToastNotifier | ||
import webbrowser | ||
from bs4 import BeautifulSoup | ||
|
||
url ="http://www.moneycontrol.com/india/stockpricequote/banks-private-sector/idfcbank/IDF01" | ||
site = requests.get(url) | ||
#print(site.text) | ||
soup = BeautifulSoup(site.text,"html.parser") | ||
for link in soup.select('#Nsc_Prc_tick_div'): | ||
print(link) | ||
name = link.get('strong') | ||
print(name) | ||
def current_price(url): | ||
site = requests.get(url) | ||
# toaster = ToastNotifier() | ||
# toaster.show_toast("Hello World!!!", "Python is awesome and I am learning a lot!",icon_path=None, duration=160) | ||
#print(site.text) | ||
# while toaster.notification_active(): time.sleep(0.1) | ||
soup = BeautifulSoup(site.text,"html.parser") | ||
for link in soup.find_all("span", id ="Nse_Prc_tick"): | ||
# #print(link) | ||
name = link.getText() | ||
#print('current Price :',name) | ||
#toaster.show_toast("IDFC Bank!!!", "Current Price :"+str(name),icon_path=None, duration=30) | ||
return name | ||
|
||
while True: | ||
toaster = ToastNotifier() | ||
idfc = current_price("http://www.moneycontrol.com/india/stockpricequote/banks-private-sector/idfcbank/IDF01") | ||
hind = current_price("http://www.moneycontrol.com/india/stockpricequote/metals-non-ferrous/hindustancopper/HC07") | ||
ab = current_price("http://www.moneycontrol.com/india/stockpricequote/finance-investments/adityabirlacapital/ABC9") | ||
cadila = current_price("http://www.moneycontrol.com/india/stockpricequote/pharmaceuticals/cadilahealthcare/CHC") | ||
mep = current_price("http://www.moneycontrol.com/india/stockpricequote/infrastructure-general/mepinfrastructuredevelopers/MID") | ||
|
||
rates ="IDFC Bank : " + str(idfc) + "\tHind Copper : " +str(hind) +"\nAB Capital : "+str(ab) | ||
rates = rates +"\nCadila Heathcare : "+str(cadila) +"\nMEP infra :"+ str(mep) | ||
toaster.show_toast("Price Alert!!!", rates,icon_path=None, duration=30) | ||
time.sleep(60) |
Binary file not shown.