aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 29d62130a..437257f5b 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -6543,6 +6543,31 @@ def traverse_obj(obj, *paths, **kwargs):
return None if default is NO_DEFAULT else default
+def value(value):
+ return lambda _: value
+
+
+class require(ExtractorError):
+ def __init__(self, name, expected=False):
+ super(require, self).__init__(
+ 'Unable to extract {0}'.format(name), expected=expected)
+
+ def __call__(self, value):
+ if value is None:
+ raise self
+
+ return value
+
+
+def unpack(func, **kwargs):
+ """Make a function that applies `partial(func, **kwargs)` to its argument as *args"""
+ @functools.wraps(func)
+ def inner(items):
+ return func(*items, **kwargs)
+
+ return inner
+
+
def T(*x):
""" For use in yt-dl instead of {type, ...} or set((type, ...)) """
return set(x)