-
Notifications
You must be signed in to change notification settings - Fork 0
/
music.py
41 lines (30 loc) · 1.08 KB
/
music.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
import re
import webbrowser
def normalize(song_text):
# print("ORIGINAL: " + song_text)
song_text = re.sub("[(\[].*?[)\]]", "", song_text) # Remove parentheses () and brackets []
song_text = song_text.lstrip() # Remove whitespace on left side
song_text = song_text.rstrip() # Remove whitespace on right side
return song_text
# print("NORMALIZED: " + song_text)
class Song:
info: ""
link: ""
storeId: ""
def description(self):
return self.info
def open_link(self):
webbrowser.open(self.link) # Open browser to song stream link
def __init__(self, s):
info = (s['artist'] + ' - ' + s['title'] + ' (' + s['album'] + ' - ' + s['albumArtist'] + ')')
if s['explicitType'] == '1':
info = info + " [EXPLICIT]"
self.info = info
self.storeId = s['storeId']
class Results:
def __init__(self):
self.results = []
def add_result(self, song, operation):
self.results.append(operation + ": " + song.description())
def display_results(self):
print(self.results)