mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-22 09:18:18 +00:00
Move register_*_metadata_processor() to new extension_points/metadata.py
This commit is contained in:
@@ -40,8 +40,8 @@ from picard.coverart.providers import (
|
|||||||
CoverArtProvider,
|
CoverArtProvider,
|
||||||
cover_art_providers,
|
cover_art_providers,
|
||||||
)
|
)
|
||||||
|
from picard.extension_points.metadata import register_album_metadata_processor
|
||||||
from picard.i18n import N_
|
from picard.i18n import N_
|
||||||
from picard.metadata import register_album_metadata_processor
|
|
||||||
|
|
||||||
|
|
||||||
class CoverArt:
|
class CoverArt:
|
||||||
|
|||||||
53
picard/extension_points/metadata.py
Normal file
53
picard/extension_points/metadata.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Picard, the next-generation MusicBrainz tagger
|
||||||
|
#
|
||||||
|
# Copyright (C) 2006-2008, 2011 Lukáš Lalinský
|
||||||
|
# Copyright (C) 2009, 2015, 2018-2023 Philipp Wolfer
|
||||||
|
# Copyright (C) 2011-2014 Michael Wiencek
|
||||||
|
# Copyright (C) 2012 Chad Wilson
|
||||||
|
# Copyright (C) 2012 Johannes Weißl
|
||||||
|
# Copyright (C) 2012-2014, 2018, 2020 Wieland Hoffmann
|
||||||
|
# Copyright (C) 2013-2014, 2016, 2018-2024 Laurent Monin
|
||||||
|
# Copyright (C) 2013-2014, 2017 Sophist-UK
|
||||||
|
# Copyright (C) 2016 Rahul Raturi
|
||||||
|
# Copyright (C) 2016-2017 Sambhav Kothari
|
||||||
|
# Copyright (C) 2017-2018 Antonio Larrosa
|
||||||
|
# Copyright (C) 2018 Vishal Choudhary
|
||||||
|
# Copyright (C) 2018 Xincognito10
|
||||||
|
# Copyright (C) 2020 Gabriel Ferreira
|
||||||
|
# Copyright (C) 2020 Ray Bouchard
|
||||||
|
# Copyright (C) 2021 Petit Minion
|
||||||
|
# Copyright (C) 2022 Bob Swift
|
||||||
|
# Copyright (C) 2022 skelly37
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU General Public License
|
||||||
|
# as published by the Free Software Foundation; either version 2
|
||||||
|
# of the License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
|
||||||
|
from picard.metadata import (
|
||||||
|
album_metadata_processors,
|
||||||
|
track_metadata_processors,
|
||||||
|
)
|
||||||
|
from picard.plugin import PluginPriority
|
||||||
|
|
||||||
|
|
||||||
|
def register_album_metadata_processor(function, priority=PluginPriority.NORMAL):
|
||||||
|
"""Registers new album-level metadata processor."""
|
||||||
|
album_metadata_processors.register(function.__module__, function, priority)
|
||||||
|
|
||||||
|
|
||||||
|
def register_track_metadata_processor(function, priority=PluginPriority.NORMAL):
|
||||||
|
"""Registers new track-level metadata processor."""
|
||||||
|
track_metadata_processors.register(function.__module__, function, priority)
|
||||||
@@ -50,10 +50,7 @@ from picard.mbjson import (
|
|||||||
artist_credit_from_node,
|
artist_credit_from_node,
|
||||||
get_score,
|
get_score,
|
||||||
)
|
)
|
||||||
from picard.plugin import (
|
from picard.plugin import PluginFunctions
|
||||||
PluginFunctions,
|
|
||||||
PluginPriority,
|
|
||||||
)
|
|
||||||
from picard.similarity import similarity2
|
from picard.similarity import similarity2
|
||||||
from picard.util import (
|
from picard.util import (
|
||||||
ReadWriteLockContext,
|
ReadWriteLockContext,
|
||||||
@@ -731,23 +728,13 @@ def _get_total_release_weight(weights):
|
|||||||
return sum(weights[w] for w in release_weights if w in weights)
|
return sum(weights[w] for w in release_weights if w in weights)
|
||||||
|
|
||||||
|
|
||||||
_album_metadata_processors = PluginFunctions(label='album_metadata_processors')
|
album_metadata_processors = PluginFunctions(label='album_metadata_processors')
|
||||||
_track_metadata_processors = PluginFunctions(label='track_metadata_processors')
|
track_metadata_processors = PluginFunctions(label='track_metadata_processors')
|
||||||
|
|
||||||
|
|
||||||
def register_album_metadata_processor(function, priority=PluginPriority.NORMAL):
|
|
||||||
"""Registers new album-level metadata processor."""
|
|
||||||
_album_metadata_processors.register(function.__module__, function, priority)
|
|
||||||
|
|
||||||
|
|
||||||
def register_track_metadata_processor(function, priority=PluginPriority.NORMAL):
|
|
||||||
"""Registers new track-level metadata processor."""
|
|
||||||
_track_metadata_processors.register(function.__module__, function, priority)
|
|
||||||
|
|
||||||
|
|
||||||
def run_album_metadata_processors(album_object, metadata, release):
|
def run_album_metadata_processors(album_object, metadata, release):
|
||||||
_album_metadata_processors.run(album_object, metadata, release)
|
album_metadata_processors.run(album_object, metadata, release)
|
||||||
|
|
||||||
|
|
||||||
def run_track_metadata_processors(album_object, metadata, track, release=None):
|
def run_track_metadata_processors(album_object, metadata, track, release=None):
|
||||||
_track_metadata_processors.run(album_object, metadata, track, release)
|
track_metadata_processors.run(album_object, metadata, track, release)
|
||||||
|
|||||||
Reference in New Issue
Block a user