1616from mutagen .easyid3 import EasyID3
1717from collections import defaultdict
1818
19+
1920def main ():
2021 parser = argparse .ArgumentParser ()
2122 parser .add_argument ('--musicDir' , type = str , default = '.' )
@@ -24,9 +25,11 @@ def main():
2425
2526 genres = defaultdict (list )
2627 for dpath , dnames , fnames in os .walk (args .musicDir ):
27- if '.git' in dpath : continue
28+ if '.git' in dpath :
29+ continue
2830 for fname in fnames :
29- if os .path .splitext (fname )[1 ] != '.mp3' : continue
31+ if os .path .splitext (fname )[1 ] != '.mp3' :
32+ continue
3033 p = os .path .abspath (os .path .join (dpath , fname ))
3134 audio = EasyID3 (p )
3235 if 'genre' in audio :
@@ -41,13 +44,15 @@ def main():
4144 os .makedirs (args .playlistDir )
4245
4346 for genre , songs in genres .items ():
44- p = os .path .join (args .playlistDir , genre + '.m3u' )
47+ p = os .path .join (args .playlistDir , genre + '.m3u' )
4548 print ("Creating playlist: {}" .format (p ))
4649 with open (p , 'w' ) as f :
4750 f .write ("#EXTM3U\n " )
48- f .write ("\n " .join (sorted (songs ))+ "\n " )
51+ f .write ("\n " .join (sorted (songs )) + "\n " )
4952
5053# Maps a string such as 'The Beatles' to 'the-beatles'.
54+
55+
5156def toNeat (s ):
5257 s = s .lower ().replace ("&" , "and" )
5358
0 commit comments