mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 18:53:21 +01:00
[ytdl} fix dfe4f00c
for legacy yt-dlp
This commit is contained in:
parent
f29ba089ff
commit
fa144f38ed
@ -199,18 +199,27 @@ def parse_command_line(module, argv):
|
||||
action += args
|
||||
yield action
|
||||
|
||||
if opts.metafromtitle is not None:
|
||||
if "pre_process" not in opts.parse_metadata:
|
||||
opts.parse_metadata["pre_process"] = []
|
||||
opts.parse_metadata["pre_process"].append(
|
||||
"title:%s" % opts.metafromtitle)
|
||||
opts.metafromtitle = None
|
||||
parse_metadata = getattr(opts, "parse_metadata", None)
|
||||
if isinstance(parse_metadata, dict):
|
||||
if opts.metafromtitle is not None:
|
||||
if "pre_process" not in parse_metadata:
|
||||
parse_metadata["pre_process"] = []
|
||||
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 = {
|
||||
k: list(itertools.chain.from_iterable(map(
|
||||
metadataparser_actions, v)))
|
||||
for k, v in opts.parse_metadata.items()
|
||||
}
|
||||
opts.metafromtitle = None
|
||||
else:
|
||||
opts.parse_metadata = ()
|
||||
|
||||
|
@ -262,15 +262,21 @@ class Test_CommandlineArguments_YtDlp(Test_CommandlineArguments):
|
||||
|
||||
def test_metadata_from_title(self):
|
||||
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], {
|
||||
"key" : "MetadataParser",
|
||||
"when" : "pre_process",
|
||||
"actions": {
|
||||
"pre_process": [
|
||||
self.module.MetadataFromFieldPP.to_action(
|
||||
"title:%(artist)s - %(title)s")
|
||||
],
|
||||
},
|
||||
"actions": actions,
|
||||
})
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user