Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[youtube] Show if video is embeddable in info #27747

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions youtube_dl/extractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ class InfoExtractor(object):
* "start_time" - The start time of the chapter in seconds
* "end_time" - The end time of the chapter in seconds
* "title" (optional, string)
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').

The following fields should only be used when the video belongs to some logical
chapter or section:
Expand Down
4 changes: 4 additions & 0 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,9 @@ def extract_unavailable_message():
if not isinstance(video_info, dict):
video_info = {}

playable_in_embed = try_get(
player_response, lambda x: x['playabilityStatus']['playableInEmbed'])

video_details = try_get(
player_response, lambda x: x['videoDetails'], dict) or {}

Expand Down Expand Up @@ -2439,6 +2442,7 @@ def decrypt_sig(mobj):
'album': album,
'release_date': release_date,
'release_year': release_year,
'playable_in_embed': playable_in_embed,
}


Expand Down