add support for --match-filter
This commit is contained in:
parent
0b3cf653f5
commit
8f313d7f58
2 changed files with 18 additions and 1 deletions
|
|
@ -465,6 +465,13 @@ def arg_converter(args: str) -> dict:
|
|||
if "postprocessors" in diff:
|
||||
diff["postprocessors"] = [pp for pp in diff["postprocessors"] if pp not in default_opts["postprocessors"]]
|
||||
|
||||
if "match_filter" in diff:
|
||||
import inspect
|
||||
|
||||
matchFilter = inspect.getclosurevars(diff["match_filter"].func).nonlocals["filters"]
|
||||
if isinstance(matchFilter, set):
|
||||
diff["match_filter"] = {"filters": list(matchFilter)}
|
||||
|
||||
from .encoder import Encoder
|
||||
|
||||
return json.loads(json.dumps(diff, cls=Encoder))
|
||||
|
|
@ -691,7 +698,7 @@ def get(
|
|||
if not path:
|
||||
return data
|
||||
|
||||
# If data is not a dict or list, attempt to convert it (similar to PHP's get_object_vars).
|
||||
# If data is not a dict or list, attempt to convert it.
|
||||
if not isinstance(data, dict | list):
|
||||
try:
|
||||
data = vars(data)
|
||||
|
|
|
|||
|
|
@ -142,4 +142,14 @@ class YTDLPOpts(metaclass=Singleton):
|
|||
|
||||
data["impersonate"] = ImpersonateTarget.from_str(data["impersonate"])
|
||||
|
||||
if (
|
||||
"match_filter" in data
|
||||
and isinstance(data["match_filter"], dict)
|
||||
and "filters" in data["match_filter"]
|
||||
and len(data["match_filter"]["filters"]) > 0
|
||||
):
|
||||
from yt_dlp.utils import match_filter_func
|
||||
|
||||
data["match_filter"] = match_filter_func(data["match_filter"]["filters"])
|
||||
|
||||
return data
|
||||
|
|
|
|||
Loading…
Reference in a new issue