aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/common.py
diff options
context:
space:
mode:
authorMatthew <colethedj@protonmail.com>2021-03-21 21:23:34 +0000
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-03-22 02:58:41 +0530
commitc224251aad3d30a2283b459fcb46ff52344d11a8 (patch)
tree43e65c16bce1a4279d4773b6440f102b9276e25a /yt_dlp/extractor/common.py
parent037cc66ec8c7cb0dfe9f333a0079201868e44e1b (diff)
downloadhypervideo-pre-c224251aad3d30a2283b459fcb46ff52344d11a8.tar.lz
hypervideo-pre-c224251aad3d30a2283b459fcb46ff52344d11a8.tar.xz
hypervideo-pre-c224251aad3d30a2283b459fcb46ff52344d11a8.zip
[youtube] Show if video is `private`, `unlisted` etc in new field `availability` (#188)
Closes: #185, https://github.com/ytdl-org/youtube-dl/issues/25631 Authored by: colethedj, pukkandan
Diffstat (limited to 'yt_dlp/extractor/common.py')
-rw-r--r--yt_dlp/extractor/common.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py
index 839bdeaf3..4205a3f8c 100644
--- a/yt_dlp/extractor/common.py
+++ b/yt_dlp/extractor/common.py
@@ -301,7 +301,11 @@ class InfoExtractor(object):
playable_in_embed: Whether this video is allowed to play in embedded
players on other sites. Can be True (=always allowed),
False (=never allowed), None (=unknown), or a string
- specifying the criteria for embedability (Eg: 'whitelist').
+ specifying the criteria for embedability (Eg: 'whitelist')
+ availability: Under what condition the video is available. One of
+ 'private', 'premium_only', 'subscriber_only', 'needs_auth',
+ 'unlisted' or 'public'. Use 'InfoExtractor._availability'
+ to set it
__post_extractor: A function to be called just before the metadata is
written to either disk, logger or console. The function
must return a dict which will be added to the info_dict.
@@ -3332,6 +3336,20 @@ class InfoExtractor(object):
def _generic_title(self, url):
return compat_urllib_parse_unquote(os.path.splitext(url_basename(url))[0])
+ @staticmethod
+ def _availability(is_private, needs_premium, needs_subscription, needs_auth, is_unlisted):
+ all_known = all(map(
+ lambda x: x is not None,
+ (is_private, needs_premium, needs_subscription, needs_auth, is_unlisted)))
+ return (
+ 'private' if is_private
+ else 'premium_only' if needs_premium
+ else 'subscriber_only' if needs_subscription
+ else 'needs_auth' if needs_auth
+ else 'unlisted' if is_unlisted
+ else 'public' if all_known
+ else None)
+
class SearchInfoExtractor(InfoExtractor):
"""