Skip to content

Commit

Permalink
[ted] Prefer own formats over external sources (closes #29142)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed May 29, 2021
1 parent f3cd1d9 commit 6511b8e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions youtube_dl/extractor/ted.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class TEDIE(InfoExtractor):
'params': {
'skip_download': True,
},
}, {
# with own formats and private Youtube external
'url': 'https://www.ted.com/talks/spencer_wells_a_family_tree_for_humanity',
'only_matching': True,
}]

_NATIVE_FORMATS = {
Expand Down Expand Up @@ -210,16 +214,6 @@ def _talk_info(self, url, video_name):

player_talk = talk_info['player_talks'][0]

external = player_talk.get('external')
if isinstance(external, dict):
service = external.get('service')
if isinstance(service, compat_str):
ext_url = None
if service.lower() == 'youtube':
ext_url = external.get('code')

return self.url_result(ext_url or external['uri'])

resources_ = player_talk.get('resources') or talk_info.get('resources')

http_url = None
Expand Down Expand Up @@ -294,6 +288,16 @@ def _talk_info(self, url, video_name):
'vcodec': 'none',
})

if not formats:
external = player_talk.get('external')
if isinstance(external, dict):
service = external.get('service')
if isinstance(service, compat_str):
ext_url = None
if service.lower() == 'youtube':
ext_url = external.get('code')
return self.url_result(ext_url or external['uri'])

self._sort_formats(formats)

video_id = compat_str(talk_info['id'])
Expand Down

0 comments on commit 6511b8e

Please sign in to comment.