Skip to content

Commit

Permalink
Update Daily Python
Browse files Browse the repository at this point in the history
  • Loading branch information
avs8687 committed Jun 24, 2020
1 parent dfaedcc commit 34f43be
Show file tree
Hide file tree
Showing 205 changed files with 1,256,812 additions and 0 deletions.
Binary file added Daily Python/06_YTDownload/06_YTDownload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions Daily Python/06_YTDownload/06_YTDownload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import win32clipboard
from pytube import YouTube

try:

# get clipboard data
win32clipboard.OpenClipboard()
link = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()

except Exception as ex:
print('Error : ',e)
exit()

try:
#where to save
SAVE_PATH = "F:\\Python Programs\\Daily Python\\06_YTDownload" #to_do
#object creation using YouTube which was imported in the beginning
yt = YouTube(link)

print('Title :',yt.title)
print('Available formats :')
for stream in yt.streams.all():
print(stream)

itag = input('\nEnter the itag number to download video of that format: ')
stream = yt.streams.get_by_itag(itag)
print('\nDownloading--- '+yt.title+' into location : '+SAVE_PATH)
stream.download(SAVE_PATH)
input('Hit Enter to exit')

except Exception as e:
print("Error",e) #to handle exception
input('Hit Enter to exit')

Binary file added Daily Python/06_YTDownload/06_YTDownload_OP.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Daily Python/06_YTDownload/06_YTDownload_YT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Daily Python/06_YTDownload/ytDownloader.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python 06_YTDownload.py
1 change: 1 addition & 0 deletions Daily Python/07_PythonSheets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.json
47 changes: 47 additions & 0 deletions Daily Python/07_PythonSheets/07_PythonSheets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pprint

#Authorize the API
scope = [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.file'
]

file_name = 'client_key.json'
creds = ServiceAccountCredentials.from_json_keyfile_name(file_name,scope)
client = gspread.authorize(creds)


#Fetch the sheet
sheet = client.open('Python Sheet').sheet1
python_sheet = sheet.get_all_records()
pp = pprint.PrettyPrinter()
pp.pprint(python_sheet)

#Fetch row
row = sheet.row_values(5)
print('\nFetched Row')
pp.pprint(row)

#Fetch column
col = sheet.col_values(2)
print('\nFetched Column')
pp.pprint(col)

#Fetch cell
cell = sheet.cell(3,3)
print('\nFetched Cell')
pp.pprint(cell.value)

#Update Cell
cell = sheet.cell(3,3)
print('Cell Before Update: ',cell.value)
sheet.update_cell(3,3,'N')
cell = sheet.cell(3,3)
print('Cell After Update: ',cell.value)

#Insert Row
row = ['7','https://daily-py.blogspot.com','Y']
index = 8
sheet.insert_row(row,index)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions Daily Python/07_PythonSheets/client_key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "YOUR_JSON_CONTENT",
"project_id": "YOUR_JSON_CONTENT",
"private_key_id": "YOUR_JSON_CONTENT",
"private_key": "YOUR_JSON_CONTENT",
"client_email": "YOUR_JSON_CONTENT",
"client_id": "YOUR_JSON_CONTENT",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "YOUR_JSON_CONTENT"
}
39 changes: 39 additions & 0 deletions Daily Python/08_YTDataAPI/08_YTDataAPI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
api_key = "YOUR_API_KEY"

from apiclient.discovery import build

youtube = build('youtube','v3',developerKey = api_key)
print(type(youtube))

request = youtube.search().list(q='Countless Storeys',part='snippet',type='video')
print(type(request))

res = request.execute()
from pprint import PrettyPrinter
pp = PrettyPrinter()
pp.pprint(res)

#Print the total number of results
request = youtube.search().list(q='Countless Storeys',part='snippet',type='video',maxResults=50)
res = request.execute()
print('Total items : ',len(res['items']))

#Print the title
request = youtube.search().list(q='Countless Storeys',part='snippet',type='video')
res = request.execute()
for item in res['items']:
print(item['snippet']['title'])


#Search for channel
request = youtube.search().list(q='Countless Storeys',part='snippet',type='channel')
res = request.execute()
for item in res['items']:
pp.pprint(item['snippet'])

# Search content by channel
channelId = 'UCoEAf0U-QUWl9TeMZSC8D3w'
request = youtube.search().list(q='Countless Storeys',part='snippet',type='video',channelId=channelId)
res = request.execute()
for item in res['items']:
pp.pprint(item['snippet'])
Binary file added Daily Python/08_YTDataAPI/08_YTDataAPI_Code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Daily Python/08_YTDataAPI/08_YTDataAPI_Docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Daily Python/08_YTDataAPI/08_YTDataAPI_Docs_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Daily Python/08_YTDataAPI/08_YTDataAPI_Docs_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Daily Python/08_YTDataAPI/08_YTDataAPI_OP_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Daily Python/08_YTDataAPI/08_YTDataAPI_OP_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Daily Python/08_YTDataAPI/08_YTDataAPI_OP_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Daily Python/08_YTDataAPI/08_YTDataAPI_OP_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
49 changes: 49 additions & 0 deletions Daily Python/09_IFSC/09_IFSC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import requests

class BankDetails:
'''
class to fetch the response of one Bank and
make it accessible through functions
'''
def __init__(self,IFSC_Code):
URL = "https://ifsc.razorpay.com/"
self.result = requests.get(URL+IFSC_Code).json()

def getBankName(self):
bankName = self.result['BANK']
print('Bank Name : ',bankName)
return bankName

def getBankContact(self):
bankContact = self.result['CONTACT']
print('Bank Contact : ',bankContact)
return bankContact

def getBankAddress(self):
bankAddr = self.result['ADDRESS']
print('Bank Address : ',bankAddr)
return bankAddr

def getBankBranch(self):
bankBranch = self.result['BRANCH']
print('Bank Branch : ',bankBranch)
return bankBranch

def getBankState(self):
bankState = self.result['STATE']
print('Bank State : ',bankState)
return bankState

def getBankCity(self):
bankCity = self.result['CITY']
print('Bank City : ',bankCity)
return bankCity

IFSC_Code = 'MAHB0001716'
bank = BankDetails(IFSC_Code)
bank.getBankName()
bank.getBankContact()
bank.getBankBranch()
bank.getBankAddress()
bank.getBankCity()
bank.getBankState()
Binary file added Daily Python/09_IFSC/09_IFSC_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Daily Python/09_IFSC/09_IFSC_2.png
Binary file added Daily Python/09_IFSC/09_IFSC_OP.png
Binary file added Daily Python/09_IFSC/09_IFSC_Razor.png
58 changes: 58 additions & 0 deletions Daily Python/10_TradeData/10_TradeData.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#Import requests module
import requests

#Import Pretty Printer module
from pprint import PrettyPrinter
pp = PrettyPrinter()

#Store the API Token
api_token = 'zlI4jkX6AA2REJ6HcgI6V58UIioxDwahyUKokvqtB9xDhJoyBtd9V06QhLNf'

#Fetch Stock Data
url = 'https://api.worldtradingdata.com/api/v1/stock'
params = {
'symbol':'GOOGL',
'api_token':api_token,
}
response = requests.request('GET',url,params=params)
pp.pprint(response.json())

#Fetch Mutual Fund Data
url = 'https://api.worldtradingdata.com/api/v1/mutualfund'
params = {
'symbol': 'AAAAX,AAAGX',
'api_token': api_token
}
response = requests.request('GET', url, params=params)
pp.pprint(response.json())

#Fetch Intraday Stock Data
url = 'https://intraday.worldtradingdata.com/api/v1/intraday'
params = {
'symbol': 'GOOGL',
'api_token': api_token,
'interval': '1',
'range': '1'
}
response = requests.request('GET', url, params=params)
pp.pprint(response.json())

#Fetch Real-Time Forex Data
url = 'https://api.worldtradingdata.com/api/v1/forex'
params = {
'base': 'INR',
'api_token': api_token
}
response = requests.request('GET', url, params=params)
print(response.json())

#Fetch Historical Market Data
url = 'https://api.worldtradingdata.com/api/v1/history'
params = {
'symbol': 'GOOGL',
'api_token': api_token,
'date_from':'2020-01-08',
'date_to':'2020-01-14'
}
response = requests.request('GET', url, params=params)
pp.pprint(response.json())
Binary file added Daily Python/10_TradeData/10_TradeData_1.png
Binary file added Daily Python/10_TradeData/10_TradeData_2.png
Binary file added Daily Python/10_TradeData/10_TradeData_OP_1.png
Binary file added Daily Python/10_TradeData/10_TradeData_OP_2.png
Binary file added Daily Python/10_TradeData/10_TradeData_OP_3.png
Binary file added Daily Python/10_TradeData/10_TradeData_OP_4.png
Binary file added Daily Python/10_TradeData/10_TradeData_OP_5.png
Binary file added Daily Python/10_TradeData/10_TradeData_WTD.png
43 changes: 43 additions & 0 deletions Daily Python/11_Meme/11_Meme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#Meme Generator webapp using Flask in Python | Daily Python #11
import requests
import urllib

#Store the required keys, passwords and user agent
username = 'AjinkyaSonawane'
password = 'dailypy1'
userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) \
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 \
Safari/537.36'

#Fetch the available memes
data = requests.get('https://api.imgflip.com/get_memes').json()['data']['memes']
images = [{'name':image['name'],'url':image['url'],'id':image['id']} for image in data]

#List all the memes
print('Here is the list of available memes : \n')
ctr = 1
for img in images:
print(ctr,img['name'])
ctr = ctr+1

#Take input from user -- Meme, Text0 and Text1
id = int(input('Enter the serial number of the meme : '))
text0 = input('Enter first text : ')
text1 = input('Enter second text : ')

#Fetch the generated meme
URL = 'https://api.imgflip.com/caption_image'
params = {
'username':username,
'password':password,
'template_id':images[id-1]['id'],
'text0':text0,
'text1':text1
}
response = requests.request('POST',URL,params=params).json()
print(response)

#Save the meme
opener = urllib.request.URLopener()
opener.addheader('User-Agent', userAgent)
filename, headers = opener.retrieve(response['data']['url'], images[id-1]['name']+'.jpg')
Binary file added Daily Python/11_Meme/11_Meme_1.png
Binary file added Daily Python/11_Meme/11_Meme_2.png
Binary file added Daily Python/11_Meme/11_Meme_OP_1.png
Binary file added Daily Python/11_Meme/11_Meme_UA.png
Binary file added Daily Python/11_Meme/11_Meme_Web.png
Binary file added Daily Python/11_Meme/Drake Hotline Bling.jpg
Loading

0 comments on commit 34f43be

Please sign in to comment.