Saving MP3 Tags to Songs - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Saving MP3 Tags to Songs (/thread-32798.html) |
Saving MP3 Tags to Songs - giddyhead - Mar-07-2021 Is there a Mp3 module that has the same attributes as TinyTag and can also save the Tags to MP3 Songs? RE: Saving MP3 Tags to Songs - jehoshua - Mar-07-2021 Is this what you are after ? https://pypi.org/project/mp3-tagger/ - "This Python package allows to access ID3 tags in MP3 files. There are the usual operations such as set, get, update, delete" RE: Saving MP3 Tags to Songs - giddyhead - Mar-08-2021 Thanks for the information. I checked on it but unfortunately at this time the mp3-tagger does not have attributes like tag.disc, tag.disc_total, tag.track_total. RE: Saving MP3 Tags to Songs - jehoshua - Mar-08-2021 Tinytag has those attributes - https://pythonawesome.com/a-library-for-reading-music-meta-data-of-mp3-ogg-flac-and-wave-files/ RE: Saving MP3 Tags to Songs - giddyhead - Mar-08-2021 Thanks for that. How can I save using those mp3 Tags. RE: Saving MP3 Tags to Songs - jehoshua - Mar-08-2021 The tags are simply chunks of data, and can be written included with the output song/MP3. Maybe "eyeD3" is the tool for this ??. Some documentation on it at https://eyed3.readthedocs.io/en/latest/ and an example at https://stackoverflow.com/questions/38510694/how-to-add-album-art-to-mp3-file-using-python-3 RE: Saving MP3 Tags to Songs - giddyhead - Mar-08-2021 Thanks. I used eyed3 and the below gettags3 works gettags3 = [audiofile.tag.album, audiofile.tag.album_artist, audiofile.tag.title, audiofile.tag.track_num, audiofile.tag.genre]for some reason tags: artist, track, track-total, disc, disc-num, disc-total, year and comment produce the same error for each tags for instance: AttributeError: 'Tag' object has no attribute 'disc'I decided to add mutagen as well and used to add the dates: from mutagen.easyid3 import EasyID3 audio["date"] = str(yrz.value)When I tried print('comment' ,audio["comment"])I got an error of raise EasyID3KeyError("%r is not a valid key" % key) mutagen.easyid3.EasyID3KeyError: "'Comment' is not a valid key"when I search I found it could be used where can I find the keys/tags/attributes that can be used? Thanks RE: Saving MP3 Tags to Songs - giddyhead - Mar-09-2021 Update: Hello everyone. The following is my add tags to list and save attempt attempt: from mutagen.easyid3 import EasyID3 from mutagen.mp3 import MP3 mtags=[] for root, dirs, files, in os.walk('C:\Users\mrdrj\Desktop\SJ\NASB - Copy\'): for name in files: if name.endswith(('.mp3', '.m4a', '.flac', '.alac')): tracks.append(name) # Add Media Files try: audio = EasyID3(root + '\' + name) mtags = audio['album'], audio['bpm'], audio['compilation'], audio['composer'], audio['copyright'], audio['encodedby'], audio['lyricist'], audio['length'], audio['media'], audio['mood'], audio['title'], audio['version'], audio['artist'], audio['albumartist'], audio['conductor'], audio['arranger'], audio['discnumber'], audio['organization'], audio['tracknumber'], audio['author'], audio['albumartistsort'], audio['albumsort'], audio['composersort'], audio['artistsort'], audio['titlesort'], audio['isrc'], audio['discsubtitle'], audio['language'], audio['genre'], audio['date'], audio['originaldate'], audio['performer:*'] except TinyTagException: print('Error') audio.save() #Save funtion works. print(audio['albumartist']) # Test to see if it works and doesWhen ran I get the following errors: How can this be solved? Thanks Traceback (most recent call last): File "C:\Users\mrdrj\Desktop\Desktop\pythonProject\New MP3 Tags.py", line 211, in <module> ain = audio['album'], audio['bpm'], audio['compilation'], audio['composer'], audio['copyright'], audio['encodedby'], audio['lyricist'], audio['length'], audio['media'], audio['mood'], audio['title'], audio['version'], audio['artist'], audio['albumartist'], audio['conductor'], audio['arranger'], audio['discnumber'], audio['organization'], audio['tracknumber'], audio['author'], audio['albumartistsort'], audio['albumsort'], audio['composersort'], audio['artistsort'], audio['titlesort'], audio['isrc'], audio['discsubtitle'], audio['language'], audio['genre'], audio['date'], audio['originaldate'], audio['performer:*'] File "C:\Users\mrdrj\AppData\Local\Programs\Python\Python39\lib\site-packages\mutagen\easyid3.py", line 213, in __getitem__ return func(self.__id3, key) File "C:\Users\mrdrj\AppData\Local\Programs\Python\Python39\lib\site-packages\mutagen\easyid3.py", line 120, in getter return list(id3[frameid]) File "C:\Users\mrdrj\AppData\Local\Programs\Python\Python39\lib\site-packages\mutagen\_util.py", line 537, in __getitem__ return self.__dict[key] KeyError: 'TBPM' RE: Saving MP3 Tags to Songs - jehoshua - Mar-09-2021 It seems you are trying to access a key that doesn't exist in mutagens dictionary. The following code should show what keys can be accessed print(EasyID3.valid_keys.keys())Possibly related, see https://gist.github.com/pschwede/3193087 - "Add bpm tags to your music collection" RE: Saving MP3 Tags to Songs - giddyhead - Mar-10-2021 When I used print(EasyID3.valid_keys.keys())I get the below keys: dict_keys(['album', 'bpm', 'compilation', 'composer', 'copyright', 'encodedby', 'lyricist', 'length', 'media', 'mood', 'title', 'version', 'artist', 'albumartist', 'conductor', 'arranger', 'discnumber', 'organization', 'tracknumber', 'author', 'albumartistsort', 'albumsort', 'composersort', 'artistsort', 'titlesort', 'isrc', 'discsubtitle', 'language', 'genre', 'date', 'originaldate', 'performer:*', 'musicbrainz_trackid', 'website', 'replaygain_*_gain', 'replaygain_*_peak', 'musicbrainz_artistid', 'musicbrainz_albumid', 'musicbrainz_albumartistid', 'musicbrainz_trmid', 'musicip_puid', 'musicip_fingerprint', 'musicbrainz_albumstatus', 'musicbrainz_albumtype', 'releasecountry', 'musicbrainz_discid', 'asin', 'performer', 'barcode', 'catalognumber', 'musicbrainz_releasetrackid', 'musicbrainz_releasegroupid', 'musicbrainz_workid', 'acoustid_fingerprint', 'acoustid_id']) When I ran it multiple times and multiple errors fixed it dwindle down to mtags:audio['album'], audio['length'], audio['title'], audio['artist'], audio['albumartist'], audio['tracknumber'], audio['genre'], audio['date']not sure why it happened? |