16
16
from mutagen .easyid3 import EasyID3
17
17
from collections import defaultdict
18
18
19
+
19
20
def main ():
20
21
parser = argparse .ArgumentParser ()
21
22
parser .add_argument ('--musicDir' , type = str , default = '.' )
@@ -24,9 +25,11 @@ def main():
24
25
25
26
genres = defaultdict (list )
26
27
for dpath , dnames , fnames in os .walk (args .musicDir ):
27
- if '.git' in dpath : continue
28
+ if '.git' in dpath :
29
+ continue
28
30
for fname in fnames :
29
- if os .path .splitext (fname )[1 ] != '.mp3' : continue
31
+ if os .path .splitext (fname )[1 ] != '.mp3' :
32
+ continue
30
33
p = os .path .abspath (os .path .join (dpath , fname ))
31
34
audio = EasyID3 (p )
32
35
if 'genre' in audio :
@@ -41,13 +44,15 @@ def main():
41
44
os .makedirs (args .playlistDir )
42
45
43
46
for genre , songs in genres .items ():
44
- p = os .path .join (args .playlistDir , genre + '.m3u' )
47
+ p = os .path .join (args .playlistDir , genre + '.m3u' )
45
48
print ("Creating playlist: {}" .format (p ))
46
49
with open (p , 'w' ) as f :
47
50
f .write ("#EXTM3U\n " )
48
- f .write ("\n " .join (sorted (songs ))+ "\n " )
51
+ f .write ("\n " .join (sorted (songs )) + "\n " )
49
52
50
53
# Maps a string such as 'The Beatles' to 'the-beatles'.
54
+
55
+
51
56
def toNeat (s ):
52
57
s = s .lower ().replace ("&" , "and" )
53
58
0 commit comments