From dfe4f00ca2b9da6128b04ff32ba50910d07cf183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 4 Jan 2023 13:12:24 +0100 Subject: [PATCH] [ytdl] update for yt-dlp changes --- gallery_dl/ytdl.py | 17 +++++++++++------ test/test_ytdl.py | 14 +++++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/gallery_dl/ytdl.py b/gallery_dl/ytdl.py index db313c38..da86bbca 100644 --- a/gallery_dl/ytdl.py +++ b/gallery_dl/ytdl.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2021-2022 Mike Fährmann +# Copyright 2021-2023 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -199,13 +199,18 @@ def parse_command_line(module, argv): action += args yield action - if getattr(opts, "parse_metadata", None) is None: - opts.parse_metadata = [] if opts.metafromtitle is not None: - opts.parse_metadata.append("title:%s" % opts.metafromtitle) + 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 - opts.parse_metadata = list(itertools.chain.from_iterable(map( - metadataparser_actions, opts.parse_metadata))) + + opts.parse_metadata = { + k: list(itertools.chain.from_iterable(map( + metadataparser_actions, v))) + for k, v in opts.parse_metadata.items() + } else: opts.parse_metadata = () diff --git a/test/test_ytdl.py b/test/test_ytdl.py index eedb4f95..e7dce526 100644 --- a/test/test_ytdl.py +++ b/test/test_ytdl.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2022 Mike Fährmann +# Copyright 2022-2023 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as @@ -263,10 +263,14 @@ class Test_CommandlineArguments_YtDlp(Test_CommandlineArguments): def test_metadata_from_title(self): opts = self._(["--metadata-from-title", "%(artist)s - %(title)s"]) self.assertEqual(opts["postprocessors"][0], { - "key": "MetadataParser", - "when": "pre_process", - "actions": [self.module.MetadataFromFieldPP.to_action( - "title:%(artist)s - %(title)s")], + "key" : "MetadataParser", + "when" : "pre_process", + "actions": { + "pre_process": [ + self.module.MetadataFromFieldPP.to_action( + "title:%(artist)s - %(title)s") + ], + }, })