[ytdl} fix dfe4f00c for legacy yt-dlp
This commit is contained in:
@@ -199,18 +199,27 @@ def parse_command_line(module, argv):
|
|||||||
action += args
|
action += args
|
||||||
yield action
|
yield action
|
||||||
|
|
||||||
if opts.metafromtitle is not None:
|
parse_metadata = getattr(opts, "parse_metadata", None)
|
||||||
if "pre_process" not in opts.parse_metadata:
|
if isinstance(parse_metadata, dict):
|
||||||
opts.parse_metadata["pre_process"] = []
|
if opts.metafromtitle is not None:
|
||||||
opts.parse_metadata["pre_process"].append(
|
if "pre_process" not in parse_metadata:
|
||||||
"title:%s" % opts.metafromtitle)
|
parse_metadata["pre_process"] = []
|
||||||
opts.metafromtitle = None
|
parse_metadata["pre_process"].append(
|
||||||
|
"title:%s" % opts.metafromtitle)
|
||||||
|
opts.parse_metadata = {
|
||||||
|
k: list(itertools.chain.from_iterable(map(
|
||||||
|
metadataparser_actions, v)))
|
||||||
|
for k, v in parse_metadata.items()
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
if parse_metadata is None:
|
||||||
|
parse_metadata = []
|
||||||
|
if opts.metafromtitle is not None:
|
||||||
|
parse_metadata.append("title:%s" % opts.metafromtitle)
|
||||||
|
opts.parse_metadata = list(itertools.chain.from_iterable(map(
|
||||||
|
metadataparser_actions, parse_metadata)))
|
||||||
|
|
||||||
opts.parse_metadata = {
|
opts.metafromtitle = None
|
||||||
k: list(itertools.chain.from_iterable(map(
|
|
||||||
metadataparser_actions, v)))
|
|
||||||
for k, v in opts.parse_metadata.items()
|
|
||||||
}
|
|
||||||
else:
|
else:
|
||||||
opts.parse_metadata = ()
|
opts.parse_metadata = ()
|
||||||
|
|
||||||
|
|||||||
@@ -262,15 +262,21 @@ class Test_CommandlineArguments_YtDlp(Test_CommandlineArguments):
|
|||||||
|
|
||||||
def test_metadata_from_title(self):
|
def test_metadata_from_title(self):
|
||||||
opts = self._(["--metadata-from-title", "%(artist)s - %(title)s"])
|
opts = self._(["--metadata-from-title", "%(artist)s - %(title)s"])
|
||||||
|
|
||||||
|
try:
|
||||||
|
legacy = (self.module.version.__version__ < "2023.01.01")
|
||||||
|
except AttributeError:
|
||||||
|
legacy = True
|
||||||
|
|
||||||
|
actions = [self.module.MetadataFromFieldPP.to_action(
|
||||||
|
"title:%(artist)s - %(title)s")]
|
||||||
|
if not legacy:
|
||||||
|
actions = {"pre_process": actions}
|
||||||
|
|
||||||
self.assertEqual(opts["postprocessors"][0], {
|
self.assertEqual(opts["postprocessors"][0], {
|
||||||
"key" : "MetadataParser",
|
"key" : "MetadataParser",
|
||||||
"when" : "pre_process",
|
"when" : "pre_process",
|
||||||
"actions": {
|
"actions": actions,
|
||||||
"pre_process": [
|
|
||||||
self.module.MetadataFromFieldPP.to_action(
|
|
||||||
"title:%(artist)s - %(title)s")
|
|
||||||
],
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user