-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilterSongs.py
80 lines (68 loc) · 2.86 KB
/
filterSongs.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
68
69
70
71
72
73
74
75
76
77
78
79
80
import syncedlyrics
def addToFile(lyrics, provider, song_index_f):
first_index = lyrics.index("\n")
second_index = lyrics.index("\n", first_index + 1)
third_index = lyrics.index("\n", second_index + 1)
fourth_index = lyrics.index("\n", third_index + 1)
fifth_index = lyrics.index("\n", fourth_index + 1)
sixth_index = lyrics.index("\n", fifth_index + 1)
print(lyrics[:sixth_index])
print()
goodFile = None
check = input("Keep or Stop? (y/n) or S: ")
if (check == 'y'):
goodFile = open("Songs_To_Try.txt", "a", encoding="utf-8")
goodFile.write(f"{provider}: {song}")
print("Added")
print()
return True
elif check == 'S':
goodFile = open("Songs_To_Try.txt", "a", encoding="utf-8")
goodFile.write(f"Stopped: {song_index_f}")
return 2
else:
return False
index = 0
# Go to end of file and see the index we left off at
with open("Songs_To_Try.txt", "r", encoding="utf-8") as file:
lines = file.readlines()
if len(lines) != 0:
last_line = lines[-1]
index = int(last_line.split(": ")[1])
else:
index = 0
# Open song.txt and read lines
with open("songs.txt", "r", encoding="utf-8") as file:
songs = file.readlines()
check = False
# Separate artist and song name
for song_index, song in enumerate(songs):
if song_index < index:
continue
else:
artists, song_name = song.split(" - ")
# Remove \n from song_name
song_name = song_name.strip("\n")
print(f"Artist: {artists}, Song: {song_name}")
print()
# Check Lyrics
lyrics = syncedlyrics.search(f"[{song_name}] [{artists}]", providers=["Musixmatch"])
if lyrics != None:
check = addToFile(lyrics, "Musixmatch", song_index)
if check == 2:
break
elif check == False:
lyrics = syncedlyrics.search(f"[{song_name}] [{artists}]", providers=["NetEase"])
if lyrics != None:
check = addToFile(lyrics, "NetEase", song_index)
if lyrics == None or check == False:
lyrics = syncedlyrics.search(f"[{song_name}] [{artists}]", providers=["Lyricsify"])
if lyrics != None:
check = addToFile(lyrics, "Lyricsify")
if lyrics == None or check == False:
lyrics = syncedlyrics.search(f"[{song_name}] [{artists}]", providers=["Megalobiz"])
if lyrics != None:
check = addToFile(lyrics, "Megalobiz", song_index)
elif lyrics == None:
print("No Lyrics Found")
print()