1234567891011121314151617181920212223242526272829303132333435 |
- from datetime import date
- import os
- from mutagen.id3 import ID3, TDRC, TIT2, TALB, TPE1, TCON, APIC
- from config import ALBUM_NAME, GENRE
- def modified_id3(file_name, artist_name, title):
- id3 = ID3()
- id3.add(TIT2(encoding=3, text=title))
- id3.add(TALB(encoding=3, text=ALBUM_NAME))
- id3.add(TPE1(encoding=3, text=artist_name))
- id3.add(TDRC(encoding=3, text=str(date.today())))
- id3.add(TCON(encoding=3, text=GENRE))
- cover_path = f"img/{artist_name}.jpg"
- print(cover_path)
- if not os.path.isfile(cover_path):
- cover_path = "img/cover.jpg"
- id3.add(
- APIC(encoding=3,
- mime=u'image/jpg',
- type=3,
- desc=u'Cover',
- data=open(cover_path, 'rb').read()))
-
- id3.save(file_name)
- track_info = {
- 'song_name': 'mfghghfgh title',
- 'album_name': 'my albdfsadcxumb name',
- 'artist_name': 'Амала Кришна дас'
- }
- # modified_id3('file.mp3', track_info['artist_name'], track_info['song_name'])
|