-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjb_utils.py
More file actions
30 lines (18 loc) · 722 Bytes
/
jb_utils.py
File metadata and controls
30 lines (18 loc) · 722 Bytes
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
DOUBLE_DASHES = "--"
def decode_value(encoded_value: str) -> str:
return encoded_value.replace("-", " ")
def encode_value(value: str) -> str:
clean_value = remove_punctuation(value)
return clean_value.replace(" ", "-")
def encode_artist_album(artist: str, album: str) -> str:
return encode_value(artist) + DOUBLE_DASHES + encode_value(album)
def encode_artist_album_song(artist: str, album: str, song: str) -> str:
return encode_artist_album(artist, album) + DOUBLE_DASHES + encode_value(song)
def remove_punctuation(s: str) -> str:
if "'" in s:
s = s.replace("'", "")
if "!" in s:
s = s.replace("!", "")
if "?" in s:
s = s.replace("?", "")
return s