aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/utils.py')
-rw-r--r--yt_dlp/utils.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py
index 72f11691f..08e30d18f 100644
--- a/yt_dlp/utils.py
+++ b/yt_dlp/utils.py
@@ -3105,16 +3105,16 @@ def try_get(src, getter, expected_type=None):
return v
+def filter_dict(dct, cndn=lambda _, v: v is not None):
+ return {k: v for k, v in dct.items() if cndn(k, v)}
+
+
def merge_dicts(*dicts):
merged = {}
for a_dict in dicts:
for k, v in a_dict.items():
- if v is None:
- continue
- if (k not in merged
- or (isinstance(v, compat_str) and v
- and isinstance(merged[k], compat_str)
- and not merged[k])):
+ if (v is not None and k not in merged
+ or isinstance(v, str) and merged[k] == ''):
merged[k] = v
return merged