mirror of
https://github.com/glomatico/gamdl.git
synced 2026-06-13 12:15:18 +03:00
Refactor MP4 tag generation in MediaTags
This commit is contained in:
+39
-38
@@ -44,22 +44,18 @@ class MediaTags:
|
||||
|
||||
def as_mp4_tags(self, date_format: str = None) -> dict:
|
||||
disc_mp4 = [
|
||||
[
|
||||
self.disc if self.disc is not None else 0,
|
||||
self.disc_total if self.disc_total is not None else 0,
|
||||
]
|
||||
self.disc if self.disc is not None else 0,
|
||||
self.disc_total if self.disc_total is not None else 0,
|
||||
]
|
||||
if disc_mp4[0][0] == 0 and disc_mp4[0][1] == 0:
|
||||
disc_mp4 = [None]
|
||||
if disc_mp4[0] == 0 and disc_mp4[1] == 0:
|
||||
disc_mp4 = None
|
||||
|
||||
track_mp4 = [
|
||||
[
|
||||
self.track if self.track is not None else 0,
|
||||
self.track_total if self.track_total is not None else 0,
|
||||
]
|
||||
self.track if self.track is not None else 0,
|
||||
self.track_total if self.track_total is not None else 0,
|
||||
]
|
||||
if track_mp4[0][0] == 0 and track_mp4[0][1] == 0:
|
||||
track_mp4 = [None]
|
||||
if track_mp4[0] == 0 and track_mp4[1] == 0:
|
||||
track_mp4 = None
|
||||
|
||||
if isinstance(self.date, datetime.date):
|
||||
if date_format is None:
|
||||
@@ -72,35 +68,40 @@ class MediaTags:
|
||||
date_mp4 = None
|
||||
|
||||
mp4_tags = {
|
||||
"\xa9alb": [self.album],
|
||||
"aART": [self.album_artist],
|
||||
"plID": [self.album_id],
|
||||
"soal": [self.album_sort],
|
||||
"\xa9ART": [self.artist],
|
||||
"atID": [self.artist_id],
|
||||
"soar": [self.artist_sort],
|
||||
"\xa9cmt": [self.comment],
|
||||
"cpil": [bool(self.compilation) if self.compilation is not None else None],
|
||||
"\xa9wrt": [self.composer],
|
||||
"cmID": [self.composer_id],
|
||||
"soco": [self.composer_sort],
|
||||
"cprt": [self.copyright],
|
||||
"\xa9day": [date_mp4],
|
||||
"\xa9alb": self.album,
|
||||
"aART": self.album_artist,
|
||||
"plID": self.album_id,
|
||||
"soal": self.album_sort,
|
||||
"\xa9ART": self.artist,
|
||||
"atID": self.artist_id,
|
||||
"soar": self.artist_sort,
|
||||
"\xa9cmt": self.comment,
|
||||
"cpil": bool(self.compilation) if self.compilation is not None else None,
|
||||
"\xa9wrt": self.composer,
|
||||
"cmID": self.composer_id,
|
||||
"soco": self.composer_sort,
|
||||
"cprt": self.copyright,
|
||||
"\xa9day": date_mp4,
|
||||
"disk": disc_mp4,
|
||||
"pgap": [bool(self.gapless) if self.gapless is not None else None],
|
||||
"\xa9gen": [self.genre],
|
||||
"\xa9lyr": [self.lyrics],
|
||||
"geID": [self.genre_id],
|
||||
"stik": [int(self.media_type) if self.media_type is not None else None],
|
||||
"rtng": [int(self.rating) if self.rating is not None else None],
|
||||
"sfID": [self.storefront],
|
||||
"\xa9nam": [self.title],
|
||||
"cnID": [self.title_id],
|
||||
"sonm": [self.title_sort],
|
||||
"pgap": bool(self.gapless) if self.gapless is not None else None,
|
||||
"\xa9gen": self.genre,
|
||||
"\xa9lyr": self.lyrics,
|
||||
"geID": self.genre_id,
|
||||
"stik": int(self.media_type) if self.media_type is not None else None,
|
||||
"rtng": int(self.rating) if self.rating is not None else None,
|
||||
"sfID": self.storefront,
|
||||
"\xa9nam": self.title,
|
||||
"cnID": self.title_id,
|
||||
"sonm": self.title_sort,
|
||||
"trkn": track_mp4,
|
||||
"xid ": [self.xid],
|
||||
"xid ": self.xid,
|
||||
}
|
||||
|
||||
return {
|
||||
k: ([v] if not isinstance(v, bool) else v)
|
||||
for k, v in mp4_tags.items()
|
||||
if v is not None
|
||||
}
|
||||
return {k: v for k, v in mp4_tags.items() if v[0] is not None}
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
Reference in New Issue
Block a user