Skip to content

Commit 99e376f

Browse files
committed
First commit
0 parents  commit 99e376f

5 files changed

+156
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#My python Scripts, Here you will find all my significant works in python

bing_photo_of_the_day.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import urllib.request
2+
import requests
3+
from bs4 import BeautifulSoup
4+
5+
# Get BingXML file which contains the URL of the Bing Photo of the day
6+
# idx = Number days previous the present day. 0 means current day, 1 means yesterday, etc
7+
# n = Number of images previous the day given by idx
8+
# mkt denotes your location. e.g. en-US means United States. Put in your country code
9+
10+
BingXML_URL = "http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US"
11+
page = requests.get(BingXML_URL)
12+
BingXML = BeautifulSoup(page.text, "lxml")
13+
Images = BingXML.find_all('image')
14+
for pics in Images:
15+
ImageURL = "https://www.bing.com" + pics.url.text[:-12] + "1920x1080.jpg"
16+
ImageName = "/home/rohan/Downloads/Bing_Photo_Of_the_day/" + pics.startdate.text + ".jpg"
17+
urllib.request.urlretrieve(ImageURL, ImageName)

cleaner.py

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
import os
3+
from pathlib import Path
4+
5+
DIRECTORIES = {
6+
"HTML": [".html5", ".html", ".htm", ".xhtml"],
7+
"IMAGES": [".jpeg", ".jpg", ".tiff", ".gif", ".bmp", ".png", ".bpg", "svg",
8+
".heif", ".psd"],
9+
"VIDEOS": [".avi", ".flv", ".wmv", ".mov", ".mp4", ".webm", ".vob", ".mng",
10+
".qt", ".mpg", ".mpeg", ".3gp", ".mkv"],
11+
"DOCUMENTS": [".oxps", ".epub", ".pages", ".docx", ".doc", ".fdf", ".ods",
12+
".odt", ".pwi", ".xsn", ".xps", ".dotx", ".docm", ".dox",
13+
".rvg", ".rtf", ".rtfd", ".wpd", ".xls", ".xlsx", ".ppt",
14+
".pptx", ".sql"],
15+
"ARCHIVES": [".a", ".ar", ".cpio", ".iso", ".tar", ".gz", ".rz", ".7z",
16+
".dmg", ".rar", ".xar", ".zip"],
17+
"AUDIO": [".aac", ".aa", ".aac", ".dvf", ".m4a", ".m4b", ".m4p", ".mp3",
18+
".msv", "ogg", "oga", ".raw", ".vox", ".wav", ".wma"],
19+
"PLAINTEXT": [".txt", ".in", ".out"],
20+
"PDF": [".pdf"],
21+
"PYTHON": [".py"],
22+
"XML": [".xml"],
23+
"EXE": [".exe"],
24+
"SHELL": [".sh"]
25+
26+
}
27+
28+
29+
FILE_FORMATS = {file_format: directory
30+
for directory, file_formats in DIRECTORIES.items()
31+
for file_format in file_formats}
32+
33+
34+
def organize_junk():
35+
for entry in os.scandir():
36+
if entry.is_dir():
37+
continue
38+
file_path = Path(entry.name)
39+
file_format = file_path.suffix.lower()
40+
if file_format in FILE_FORMATS:
41+
print(entry.name+" ongoing...")
42+
directory_path = Path(FILE_FORMATS[file_format])
43+
if "bill" in str(file_path) or "Bill" in str(file_path):
44+
directory_path = Path("BILLS")
45+
directory_path.mkdir(exist_ok=True)
46+
if os.path.exists(str(directory_path.joinpath(file_path))):
47+
dirs = str(directory_path.joinpath(file_path))
48+
while os.path.exists(dirs):
49+
dirs = dirs + "(copy)"
50+
file_path.rename(dirs)
51+
else:
52+
file_path.rename(directory_path.joinpath(file_path))
53+
54+
try:
55+
os.mkdir("OTHER-FILES")
56+
except:
57+
pass
58+
59+
for dir in os.scandir():
60+
try:
61+
if dir.is_dir():
62+
os.rmdir(dir)
63+
else:
64+
os.rename(os.getcwd() + '/' + str(Path(dir)), os.getcwd() + '/OTHER-FILES/' + str(Path(dir)))
65+
except:
66+
pass
67+
68+
69+
if __name__ == "__main__":
70+
organize_junk()
71+
print("zala copy...")

musical.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
import os
4+
5+
search = input('Enter the name of the song: ')
6+
sc = requests.get('https://www.youtube.com/results?search_query=' + search)
7+
soup = BeautifulSoup(sc.text, 'lxml')
8+
title = soup.findAll('h3', {'class': 'yt-lockup-title '})
9+
link = []
10+
for i in range(min(10, len(title))):
11+
link.append(title[i].find('a')['href'])
12+
for i in range(min(10, len(title))):
13+
print(str(i + 1) + '. ' + title[i].find('a').text)
14+
15+
while True:
16+
try:
17+
user_input = int(input('Enter the song no. to download: '))
18+
if user_input not in range(1, 11):
19+
print('Enter correct input')
20+
continue
21+
break
22+
except NameError:
23+
print('Enter correct input')
24+
continue
25+
26+
print('Download hotay... jara vel thamba....')
27+
os.system("youtube-dl --extract-audio --audio-format mp3 " + 'https://www.youtube.com' + link[user_input - 1])

spot_ur_train.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
chakra = True
5+
trial = 5
6+
7+
# train_no = 22104
8+
train_no = int(input("Enter the train no."))
9+
days = int(
10+
input("enter the starting day number..('0' for today, '1' for yesterday, 2 for day before yesterday and so "
11+
"on...)")) * -1
12+
# days = -1
13+
14+
while chakra and trial >= 0:
15+
try:
16+
sc = requests.get("http://spoturtrain.com/status.php?tno=" + str(train_no) + "&date=+" + str(days))
17+
soup = BeautifulSoup(sc.text, 'lxml')
18+
tr = soup.find_all("tr")
19+
for td in tr[1].find_all("font"):
20+
print(td.getText().strip("\t").strip("\n") + "\n")
21+
print("-----------------------------------------------------------------------------------\n\n")
22+
print("Station -> ETA")
23+
print("--------------")
24+
for i in range(3, len(tr)):
25+
rows = tr[i]
26+
str = ""
27+
flag = True
28+
for td in rows.find_all("td"):
29+
str = str + td.getText().strip('\n') + " "
30+
if flag:
31+
str = str + "-> "
32+
flag = False
33+
print(str)
34+
chakra = False
35+
trial -= 1
36+
except:
37+
trial -= 1
38+
print("Kuch toh locha hai... reattempting")
39+
if chakra:
40+
print("Successfully Failed... Please try again")

0 commit comments

Comments
 (0)