__init__.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. PLUGIN_NAME = "Ami (Metadata)"
  2. PLUGIN_AUTHOR = "SuperSaltyGamer"
  3. PLUGIN_DESCRIPTION = "Enhancements to the metadata pane."
  4. PLUGIN_VERSION = "1.0.0"
  5. PLUGIN_API_VERSIONS = ["2.10"]
  6. PLUGIN_LICENSE = "AGPL-3.0"
  7. from picard.config import config
  8. from picard.ui.metadatabox import MetadataBox, TagDiff
  9. from picard.util.tags import TAG_NAMES
  10. TAG_NAMES.update({
  11. "comment": "Comment",
  12. "disctotal": "Disc Total",
  13. "encoder": "Encoder",
  14. "mqa": "MQA",
  15. "source": "Source",
  16. "tracktotal": "Track Total",
  17. "upc": "UPC",
  18. "url": "URL",
  19. })
  20. original_update_tags = MetadataBox._update_tags
  21. def override_update_tags(self: MetadataBox, new_selection=True, drop_album_caches=False):
  22. ret: TagDiff = original_update_tags(self, new_selection, drop_album_caches)
  23. if ret is None:
  24. return ret
  25. last_index = -1
  26. for top_tag in config.setting["metadatabox_top_tags"]:
  27. forced = top_tag.startswith("!")
  28. top_tag = top_tag.lstrip("!")
  29. index = next((i for i, tag in enumerate(ret.tag_names) if tag == top_tag), -1)
  30. if index != -1:
  31. last_index = index
  32. elif forced:
  33. last_index += 1
  34. ret.tag_names.insert(last_index, top_tag)
  35. return ret
  36. MetadataBox._update_tags = override_update_tags