ebb-earl-co / tidal-wave

Waving at the TIDAL music service
Apache License 2.0
38 stars 2 forks source link

Bugfix: Dolby Atmos Files' Metadata #59

Closed ebb-earl-co closed 7 months ago

ebb-earl-co commented 7 months ago

As pointed out in #54 , the metadata for .m4a files with E-AC3 codec was a bit wonky, due to using .mka as the intermediate container when re-ordering the audio and cover image streams. This pull request fixes this, as well as a few other things.

Additionally, for all files, but most pertinently to Dolby Atmos files, the process for adding metadata pertaining to a track's mixer and engineer has changed. To wit, the engineer tag for either .flac or .m4a looks for the following values, in a chain of if-not-exists-then-try-the-next-one:

self.engineer: Optional[Tuple[str]] = \
    self.get_contributors("Engineer") or \
    self.get_contributors("Mastering Engineer") or \
    self.get_contributors("Immersive Mastering Engineer")

Similarly for mixer tag:

self.mixer: Optional[Tuple[str]] = \
    self.get_contributors("Mixer") or \
    self.get_contributors("Mix Engineer") or \
    self.get_contributors("Mixing Engineer") or \
    self.get_contributors("Atmos Mixing Engineer")

TIDAL's API is inconsistent on which variation is offered on a track-by-track basis, even within the same album!

Most importantly, however, this pull request changes the order of operations in getting and setting a track's metadata and its supporting files. Now, the order is the following:

  1. Get track's metadata track.Track.get_metadata()
  2. Check track.Track.metadata.media_metadata.tags against the selected audio format
  3. Get the track's album, unless it's being passed in by the album.Album.get_tracks() process
  4. If track's album is not None, execute track.Track.set_album_dir()
  5. track.Track.save_artist_image()
  6. track.Track.save_artist_bio()
  7. track.Track.get_credits()
  8. track.Track.get_stream()
  9. track.Track.set_manifest()
  10. track.Track.set_filename()
  11. track.Track.set_outfile()
  12. track.Track.get_lyrics()
  13. track.Track.set_urls()
  14. track.Track.download(), which uses either track.Track.download_url() or track.Track.download_urls() depending on the number of URLs (i.e., DASH versus TIDAL's JSON)
  15. track.Track.set_mutagen()
  16. track.Track.save_album_cover() if album cover was returned by the API and the album cover file successfully was written
  17. track.Track.set_cover_image_tag()
  18. If the track has an album cover stream as well as the audio stream, track.Track.reorder_streams()
  19. track.Track.craft_tags()
  20. track.Track.set_tags()