forked from Mp3-Automated-Tag-Editor/Automated_Mp3tag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
title_generator.py
51 lines (39 loc) · 1.11 KB
/
title_generator.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
import os
def regex_title_gen(x):
fname = x
c = 0
song = fname.split(" - ")[c]
if(".is" in (song) or ".com" in (song) or ".info" in (song)):
c += 1
song = fname.split("-")[c]
artist = os.path.splitext("".join(fname.split(" - ")[c+1:]))[0]
if("Official" in artist):
idx = artist.rfind("Official")
artist = artist[0:idx]
elif("official" in artist):
idx = artist.rfind("official")
artist = artist[0:idx]
elif("Music" in artist):
idx = artist.rfind("Music")
artist = artist[0:idx]
elif("Lyric" in artist):
idx = artist.rfind("Lyric")
artist = artist[0:idx]
else:
artist = artist
if(len(song) == 0):
song = artist
if(song == ""):
song = artist
if (artist == ""):
artist = song
artist = artist.replace("_", " ").replace("(", " ")
song = song.replace("_", " ").replace("(", "")
temp = song
song = artist
artist = temp
song = song.strip()
artist = artist.strip()
#print("song: " + song)
#print("artist: "+artist)
return song,artist