priority to plugin extensions
This commit is contained in:
parent
8c5e4f0d5b
commit
12300a85eb
3 changed files with 10 additions and 2 deletions
|
|
@ -28,7 +28,10 @@ class PluginPriority:
|
|||
|
||||
MODIFY_ENTRY_FIRST = 0
|
||||
|
||||
def __init__(self, modify_entry: int = 5, post_process: int = 5):
|
||||
def __init__(
|
||||
self, modify_entry_metadata: int = 5, modify_entry: int = 5, post_process: int = 5
|
||||
):
|
||||
self.modify_entry_metadata = modify_entry_metadata
|
||||
self.modify_entry = modify_entry
|
||||
self.post_process = post_process
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from typing import Tuple
|
|||
|
||||
from yt_dlp.utils import RejectedVideoReached
|
||||
|
||||
from ytdl_sub.config.plugin import PluginPriority
|
||||
from ytdl_sub.config.preset_options import Overrides
|
||||
from ytdl_sub.downloaders.source_plugin import SourcePlugin
|
||||
from ytdl_sub.downloaders.source_plugin import SourcePluginExtension
|
||||
|
|
@ -54,6 +55,8 @@ class URLDownloadState:
|
|||
|
||||
|
||||
class UrlDownloaderThumbnailPlugin(SourcePluginExtension):
|
||||
priority = PluginPriority(modify_entry=0)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
options: MultiUrlSourceOptionsValidator,
|
||||
|
|
@ -153,6 +156,8 @@ class UrlDownloaderThumbnailPlugin(SourcePluginExtension):
|
|||
|
||||
|
||||
class UrlDownloaderCollectionVariablePlugin(SourcePluginExtension):
|
||||
priority = PluginPriority(modify_entry_metadata=0)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
options: MultiUrlSourceOptionsValidator,
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ class SubscriptionDownload(BaseSubscription, ABC):
|
|||
@classmethod
|
||||
def _preprocess_entry(cls, plugins: List[Plugin], entry: Entry) -> Optional[Entry]:
|
||||
maybe_entry: Optional[Entry] = entry
|
||||
for plugin in plugins:
|
||||
for plugin in sorted(plugins, key=lambda _plugin: _plugin.priority.modify_entry_metadata):
|
||||
if (maybe_entry := plugin.modify_entry_metadata(maybe_entry)) is None:
|
||||
return None
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue