-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathid3_talb_remove.py
32 lines (29 loc) · 1.1 KB
/
id3_talb_remove.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
#!/usr/bin/env python3
import os
import sys
import mutagen.id3
def writePlaylist(dirpath, filenames):
m3uExt = ".m3u"
m3ufilename = os.path.join(dirpath, os.path.basename(dirpath)) + m3uExt
with open(m3ufilename, 'w') as playlist:
for filename in filenames:
if filename[0] != "." and os.path.splitext(filename)[1] != m3uExt:
playlist.write(filename + "\n")
for path in sys.argv[1:]:
for dirpath, dirnames, filenames in os.walk(path):
album = os.path.basename(os.path.abspath(dirpath))
talb = mutagen.id3.TALB(text=album)
print("Walking {}:".format(dirpath))
#print("added playlist")
#writePlaylist(dirpath, filenames)
for filename in filenames:
sys.stdout.write(" tagging {}".format(filename))
try:
song_path = os.path.join(dirpath, filename)
song = mutagen.id3.ID3(song_path)
song.delall("TALB")
#song.add(talb)
song.save()
print()
except:
print(" skipped (no id3 tags)")