-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (57 loc) · 1.94 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
import config
import sys
import re
import lyricsgenius
genius = lyricsgenius.Genius(GENIUS_API_TOKEN)
# GET SONG
text = input("Enter a song name.\nThe first result will be the song that is played.\nMAKE SURE TO BE SPECIFIC WHEN TYPING THE SONG NAME!\n")
print(text)
song = genius.search_song(text)
print("I found a song! Here's the lyrics:"+song.lyrics)
# FORMAT LYRICS SO THAT THERE ARE NO SPACES OR BRACKETS
lyrics = song.lyrics
#m_lyrics = re.sub("[\(\[].*?[\)\]]", "", lyrics)
m_lyrics = re.sub("[\[].*?[\]]", "", lyrics)
f_lyrics = m_lyrics.split("\n")
non_empty_lines = [line for line in f_lyrics if line.strip() != ""]
final = ""
for line in non_empty_lines:
final += line + "\n"
final = final.replace("878EmbedShare URLCopyEmbedCopy", "")
f = open("ly.txt", "w")
f.write(final)
f.close()
# GET NUMBER
finalNumber = ""
num = input("Enter the number you want to send all of these lyrics to.\nMake sure that you type it correctly!\n")
if num:
number = input("Is this number correct: "+num+"\nIf it's wrong you won't be able to change it.\nType (y/n)\n")
if number == "y":
finalNumber = num
print("Running... Please wait.")
elif number == "n":
print("Terminated. Run this again.")
sys.exit()
else:
print("Not a valid input. Restart from the beginning.")
sys.exit()
# READ TXT FILE AND GET WORDS
def get_words(file_path):
with open(file_path, 'r') as f:
text = f.readlines()[0]
words = text.split()
return words
def get_lines(file_path):
with open(file_path, 'r') as f:
text = f.readlines()
return text
# SEND MESSAGE
def send_message(phone_number, message):
os.system('osascript sendMessage.applescript {} "{}"'.format(phone_number, message))
if __name__ == '__main__':
#words = get_words('ly.txt')
# for word in words:
text = get_lines('ly.txt')
for line in text:
send_message(finalNumber, line)