Skip to content

Commit 5a2b516

Browse files
authored
Merge branch 'master' into master
2 parents 158a6ee + bbb70ed commit 5a2b516

File tree

9 files changed

+202
-1
lines changed

9 files changed

+202
-1
lines changed

Music Downloader/MusicDownloader.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from pytube import YouTube
2+
import os
3+
4+
def get_song_list():
5+
music_data = []
6+
with open('./music-list.txt', 'r') as sl:
7+
music_list = sl.readlines()
8+
for _, music in enumerate(music_list):
9+
music = music.replace('\n', '')
10+
music = music.split(' https:')
11+
music[1] = f'https:{music[1]}'
12+
music_data.append(music)
13+
return music_data
14+
15+
16+
def run():
17+
music_data = get_song_list()
18+
19+
for _, (title, url) in enumerate(music_data):
20+
# url input from user
21+
yt = YouTube(url)
22+
23+
# extract only audio
24+
print(f"Extracting audio of: {title}")
25+
video = yt.streams.filter(only_audio=True).first()
26+
27+
# check for destination to save file
28+
destination = "./music"
29+
30+
# download the file
31+
print(f"Downloading: {title}")
32+
out_file = video.download(output_path=destination)
33+
34+
# save the file
35+
new_filename = title + ".mp3"
36+
new_file = os.path.join(destination, new_filename)
37+
os.rename(out_file, new_file)
38+
39+
# result of success
40+
print(yt.title + " has been successfully downloaded.")
41+
print('-' * 20)
42+
43+
print("### All music files have been successfully downloaded! ###")
44+
45+
if __name__ == '__main__':
46+
run()

Music Downloader/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This repository consists of a list of python scripts to automate few tasks.
2+
3+
You can contribute by adding more python scripts which can be used to automate things. Some of already done are listed below.
4+
Incase you have anything to be followed while executing the python script mention it as well
5+
6+
7+
# Python Script
8+
9+
## Script - Music Downloader
10+
11+
Python script to download music automatically from a .txt file. You can insert multiple lines of titles and their YouTube video links. The format for the music-list.txt file is: "music title" "youtube-link". The "music title" is what you rename the music as, it could be anything you'd like.
12+
MusicDownloader.py
13+

Music Downloader/music-list.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Rick Astley - Never Gonna Give You Up https://youtu.be/dQw4w9WgXcQ
2+
a-ha - Take On Me https://youtu.be/djV11Xbc914

PasswordGenerator.py renamed to Password Generator/PasswordGenerator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ def colored(r, g, b, text):
7979

8080
final_pass =colored(200,200,50, (shuffle_(shuffle_(shuffle_(pass_word)))))
8181

82-
print(f"\nYour computer generated password is : {final_pass}\n\n")
82+
print(f"\nYour computer generated password is : {final_pass}\n\n")

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,11 @@ GeneratePassword.py
5252
## Script 10 - Simple TCP Chat Server
5353
server.py - Creates a local server on your LAN for receiving and sending messages!
5454

55+
## Script 11 - Wallpaper Changer
56+
Automatically change home wallpaper adding a random quote and stock tickers on it
57+
58+
## Script 12 - Star Pattern
59+
Create a star pattern pyramid
60+
5561
## Script 13 - compound interest calculator
5662
calculate compound interest

Star Pattern/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This repository consists of a list of python scripts to automate few tasks.
2+
3+
You can contribute by adding more python scripts which can be used to automate things. Some of already done are listed below.
4+
Incase you have anything to be followed while executing the python script mention it as well
5+
6+
7+
# Python Script
8+
9+
## Script - Star Pattern
10+
11+
Code to create star pattern
12+
starPattern.py
13+

Star Pattern/starPattern.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def starPattern(n):
2+
for i in range(1, n+1):
3+
for j in range(1, i+1):
4+
print("* ", end="")
5+
print()
6+
7+
8+
n = int(input("Enter the number of rows: "))
9+
starPattern(n)
10+
File renamed without changes.

Wallpaper Changer/wallpaperchanger.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import requests,ctypes,os,numpy as np
2+
from PIL import Image,ImageFont,ImageDraw
3+
import yfinance as yf
4+
from datetime import datetime
5+
6+
#enable or disable any functionality
7+
enable_time=True
8+
enable_tickers=True
9+
enable_quote=True
10+
11+
now = datetime.now()
12+
current_time = now.strftime("%H:%M:%S")
13+
14+
tickers=[
15+
("^GSPC","s&p500"),
16+
("aapl","aapl"),
17+
("msft","msft"),
18+
("goog","googl"),
19+
("amzn","amzn"),
20+
("tsla","tsla"),
21+
("BTC-USD","btc"),
22+
("ETH-USD","eth")
23+
]
24+
25+
def add_margin(img,top,left,bottom,right,color):
26+
width, height = img.size
27+
new_width = width + right + left
28+
new_height = height + top + bottom
29+
result = Image.new(img.mode, (new_width, new_height),color)
30+
result.paste(img, (left, top))
31+
return result
32+
def conv_to_size(path,path_to_save=None):
33+
z=Image.open(path)
34+
if z.size[0]/1920>z.size[1]/1080:
35+
vres=z.size[0]*1080/1920
36+
vres=vres-z.size[1]
37+
vres=int(vres/2)
38+
res=add_margin(z,vres,0,vres,0,(0,0,0))
39+
else:
40+
hres=z.size[1]*1920/1080
41+
hres=hres-z.size[0]
42+
hres=int(hres/2)
43+
res=add_margin(z,0,hres,0,hres,(0,0,0))
44+
if path_to_save is not None:
45+
res.save(path_to_save)
46+
else:
47+
res.save(path)
48+
def ret_change(ticker):
49+
x= yf.Ticker(ticker)
50+
z=x.history(period="3d")
51+
return (((z.iloc[-1]["Close"]-z.iloc[-2]["Close"])/z.iloc[-2]["Close"])*100).round(2),z.iloc[-1]["Close"].round(2)
52+
53+
z=os.listdir("path/to/folder/containing/images")
54+
55+
#opening random image
56+
path="path/to/folder/containing/images"+z[np.random.randint(len(z))]
57+
z=Image.open(path)
58+
59+
#check if in correct proportion, pad if it isnt
60+
if z.size[0]/z.size[1]>1.78 or z.size[0]/z.size[1]<1.76:
61+
conv_to_size(path)
62+
z=Image.open(path)
63+
64+
#resizing to perfect resolution
65+
z=z.resize((1920,1080))
66+
67+
68+
#start drawing
69+
I1 = ImageDraw.Draw(z)
70+
if enable_quote:
71+
try:#write a quote on the image if it is fetched succesfully
72+
73+
myFont = ImageFont.truetype("path/to/.ttf/font/file",20)
74+
l="http://api.quotable.io/random"
75+
r=requests.get(l)
76+
r=r.json()
77+
text=r["content"]+" - "+r["author"]
78+
79+
I1.text((10,1050), text, font=myFont, fill =(255, 255, 255))
80+
except:
81+
pass
82+
if enable_time:
83+
try:
84+
I1.text((1830,1050), current_time, font=myFont, fill =(255, 255, 255))
85+
except:
86+
pass
87+
if enable_tickers:
88+
try:
89+
ticpos=10
90+
for i,j in tickers:
91+
chn,pc=ret_change(i)
92+
I1.text((1670,ticpos),j, font=myFont, fill =(255,255,255))
93+
if chn>=0:
94+
I1.text((1750,ticpos),str(chn)+"%", font=myFont, fill =(0,255,0))
95+
I1.text((1830,ticpos),str(pc), font=myFont, fill =(0,255,0))
96+
else:
97+
I1.text((1750,ticpos),str(abs(chn))+"%", font=myFont, fill =(255,0,0))
98+
I1.text((1830,ticpos),str(pc), font=myFont, fill =(255,0,0))
99+
100+
ticpos+=25
101+
except:
102+
pass
103+
104+
try:#save as jpg
105+
save_path="path/to/save/temp/wallpaper/in/.jpg/format"
106+
z.save(save_path,quality="high")
107+
ctypes.windll.user32.SystemParametersInfoW(20, 0, save_path, 0)
108+
except:#or save as png
109+
save_path="path/to/save/temp/wallpaper/in/.png/format"
110+
z.save("D:/Pictures/temp.png",quality="high")
111+
ctypes.windll.user32.SystemParametersInfoW(20, 0, save_path , 0)

0 commit comments

Comments
 (0)