Mar-07-2021, 02:53 AM
Is there a Mp3 module that has the same attributes as TinyTag and can also save the Tags to MP3 Songs?
Saving MP3 Tags to Songs
|
Mar-07-2021, 02:53 AM
Is there a Mp3 module that has the same attributes as TinyTag and can also save the Tags to MP3 Songs?
Mar-07-2021, 10:44 PM
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"
Mar-08-2021, 12:58 AM
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.
Mar-08-2021, 04:43 AM
Tinytag has those attributes - https://pythonawesome.com/a-library-for-...ave-files/
Mar-08-2021, 05:47 AM
Thanks for that. How can I save using those mp3 Tags.
Mar-08-2021, 06:41 AM
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/3851...g-python-3
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
Mar-09-2021, 05:12 AM
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'
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"
Mar-10-2021, 02:17 AM
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? |
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Loop through tags inside tags in Selenium/Python | xpack24 | 1 | 7,270 |
Oct-23-2019, 10:15 AM Last Post: Larz60+ |