Добавление тега "жанр" (#123)
This commit is contained in:
parent
a84a40f38c
commit
6edae0e037
1 changed files with 14 additions and 4 deletions
18
ymd/core.py
18
ymd/core.py
|
|
@ -13,6 +13,7 @@ from mutagen.flac import FLAC, Picture
|
|||
from mutagen.id3._frames import (
|
||||
APIC,
|
||||
TALB,
|
||||
TCON,
|
||||
TDRC,
|
||||
TIT2,
|
||||
TPE1,
|
||||
|
|
@ -161,16 +162,19 @@ def set_tags(
|
|||
album_cover: Optional[AlbumCover],
|
||||
compatibility_level: int,
|
||||
) -> None:
|
||||
album = track.albums[0] if track.albums else Album()
|
||||
track_artists = [a.name for a in track.artists if a.name]
|
||||
album_artists = [a.name for a in album.artists if a.name]
|
||||
|
||||
file_type = CONTAINER_MUTAGEN_MAPPING.get(container)
|
||||
if file_type is None:
|
||||
raise ValueError(f"Unknown container: {container}")
|
||||
|
||||
tag = file_type(path)
|
||||
album = track.albums[0] if track.albums else Album()
|
||||
album_title = full_title(album)
|
||||
track_title = full_title(track)
|
||||
track_artists = [a.name for a in track.artists if a.name]
|
||||
album_artists = [a.name for a in album.artists if a.name]
|
||||
genre = None
|
||||
if album.genre:
|
||||
genre = album.genre
|
||||
track_number = None
|
||||
disc_number = None
|
||||
if position := album.track_position:
|
||||
|
|
@ -200,6 +204,8 @@ def set_tags(
|
|||
tag["TRCK"] = TRCK(encoding=3, text=str(track_number))
|
||||
if disc_number:
|
||||
tag["TPOS"] = TPOS(encoding=3, text=str(disc_number))
|
||||
if genre:
|
||||
tag["TCON"] = TCON(encoding=3, text=genre)
|
||||
|
||||
if lyrics:
|
||||
tag["USLT"] = USLT(encoding=3, text=lyrics)
|
||||
|
|
@ -234,6 +240,8 @@ def set_tags(
|
|||
tag["trkn"] = [(track_number, 0)]
|
||||
if disc_number:
|
||||
tag["disk"] = [(disc_number, 0)]
|
||||
if genre:
|
||||
tag["\xa9gen"] = genre
|
||||
|
||||
if lyrics:
|
||||
tag["\xa9lyr"] = lyrics
|
||||
|
|
@ -259,6 +267,8 @@ def set_tags(
|
|||
tag["tracknumber"] = str(track_number)
|
||||
if disc_number:
|
||||
tag["discnumber"] = str(disc_number)
|
||||
if genre:
|
||||
tag["genre"] = genre
|
||||
|
||||
if lyrics:
|
||||
tag["lyrics"] = lyrics
|
||||
|
|
|
|||
Loading…
Reference in a new issue