Last active
February 26, 2021 22:54
-
-
Save alifarazz/b0d1ad629ab95996ab680c440ccdf589 to your computer and use it in GitHub Desktop.
Cleanup mp3 files metadata with eyed3 python library.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import eyed3 | |
| import glob | |
| def f(filename): | |
| audiofile: eyed3.mp3.Mp3AudioFile = eyed3.load(filename) | |
| # print(type(audiofile)) | |
| title = audiofile.tag.title.replace('GOOz', '') | |
| trackNumber = int(filename.split()[0]) | |
| # print(title, trackNumber) | |
| audiofile.tag.title = title | |
| audiofile.tag.track_num = trackNumber | |
| audiofile.tag.save() | |
| # return {'status': 'ok', 'file': filename} | |
| return True | |
| def main(): | |
| # r = re.compile(".*\.mp3") | |
| # filenames = os.walk(files_dir) | |
| # filenames = list(filenames)[0][2] # magic | |
| # files = filter(r.match, filenames) | |
| # do = map(lambda x: f(x, str_from, str_to), files) | |
| # result = list(do) | |
| # print(*result, sep='\n') | |
| assert all(map(f, glob.glob('*.mp3'))) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment