Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from mutagen.easyid3 import EasyID3
- import os
- import re
- def mp3list():
- for root, dirs, files in os.walk('.'):
- for filename in files:
- if os.path.splitext(filename)[1] == '.mp3':
- yield filename
- def manual_check(filename, field):
- pattern = '[a-zA-Z0-9\(\)\.\s]{1,}'
- if not re.match(pattern, field):
- print('File: {0}'.format(filename))
- print('[{0}]'.format(field))
- new = input()
- if new == '':
- return field
- else:
- return new
- else:
- return field
- for mp3file in mp3list():
- split = mp3file.split('-')
- artist = split[0].strip()
- title = split[1].strip()
- title = manual_check(mp3file, title)
- title = title.replace('w_', 'w/')
- artist = manual_check(mp3file, artist)
- print('Doing', title, artist)
- audio = EasyID3(mp3file)
- audio['title'] = title
- audio['artist'] = artist
- audio.save()
Add Comment
Please, Sign In to add comment