mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-28 17:41:01 +01:00
TEDIE: download the best quality video and use the new _search_regex functions
Also extracts the description.
This commit is contained in:
parent
038a3a1a61
commit
f4c8bbcfc2
@ -363,10 +363,10 @@
|
|||||||
"name": "TED",
|
"name": "TED",
|
||||||
"url": "http://www.ted.com/talks/dan_dennett_on_our_consciousness.html",
|
"url": "http://www.ted.com/talks/dan_dennett_on_our_consciousness.html",
|
||||||
"file": "102.mp4",
|
"file": "102.mp4",
|
||||||
"md5": "7bc087e71d16f18f9b8ab9fa62a8a031",
|
"md5": "8cd9dfa41ee000ce658fd48fb5d89a61",
|
||||||
"info_dict": {
|
"info_dict": {
|
||||||
"title": "Dan Dennett: The illusion of consciousness",
|
"title": "Dan Dennett: The illusion of consciousness",
|
||||||
"thumbnail": "http://images.ted.com/images/ted/488_389x292.jpg"
|
"description": "md5:c6fa72e6eedbd938c9caf6b2702f5922"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3792,10 +3792,6 @@ def _real_extract(self, url):
|
|||||||
self.to_screen(u'Getting info of playlist %s: "%s"' % (playlist_id,name))
|
self.to_screen(u'Getting info of playlist %s: "%s"' % (playlist_id,name))
|
||||||
return [self._playlist_videos_info(url,name,playlist_id)]
|
return [self._playlist_videos_info(url,name,playlist_id)]
|
||||||
|
|
||||||
def _talk_video_link(self,mediaSlug):
|
|
||||||
'''Returns the video link for that mediaSlug'''
|
|
||||||
return 'http://download.ted.com/talks/%s.mp4' % mediaSlug
|
|
||||||
|
|
||||||
def _playlist_videos_info(self,url,name,playlist_id=0):
|
def _playlist_videos_info(self,url,name,playlist_id=0):
|
||||||
'''Returns the videos of the playlist'''
|
'''Returns the videos of the playlist'''
|
||||||
video_RE=r'''
|
video_RE=r'''
|
||||||
@ -3808,9 +3804,8 @@ def _playlist_videos_info(self,url,name,playlist_id=0):
|
|||||||
m_videos=re.finditer(video_RE,webpage,re.VERBOSE)
|
m_videos=re.finditer(video_RE,webpage,re.VERBOSE)
|
||||||
m_names=re.finditer(video_name_RE,webpage)
|
m_names=re.finditer(video_name_RE,webpage)
|
||||||
|
|
||||||
playlist_RE = r'div class="headline">(\s*?)<h1>(\s*?)<span>(?P<playlist_title>.*?)</span>'
|
playlist_title = self._html_search_regex(r'div class="headline">\s*?<h1>\s*?<span>(.*?)</span>',
|
||||||
m_playlist = re.search(playlist_RE, webpage)
|
webpage, 'playlist title')
|
||||||
playlist_title = m_playlist.group('playlist_title')
|
|
||||||
|
|
||||||
playlist_entries = []
|
playlist_entries = []
|
||||||
for m_video, m_name in zip(m_videos,m_names):
|
for m_video, m_name in zip(m_videos,m_names):
|
||||||
@ -3821,27 +3816,28 @@ def _playlist_videos_info(self,url,name,playlist_id=0):
|
|||||||
|
|
||||||
def _talk_info(self, url, video_id=0):
|
def _talk_info(self, url, video_id=0):
|
||||||
"""Return the video for the talk in the url"""
|
"""Return the video for the talk in the url"""
|
||||||
m=re.match(self._VALID_URL, url,re.VERBOSE)
|
m = re.match(self._VALID_URL, url,re.VERBOSE)
|
||||||
videoName=m.group('name')
|
video_name = m.group('name')
|
||||||
webpage=self._download_webpage(url, video_id, 'Downloading \"%s\" page' % videoName)
|
webpage = self._download_webpage(url, video_id, 'Downloading \"%s\" page' % video_name)
|
||||||
|
self.report_extraction(video_name)
|
||||||
# If the url includes the language we get the title translated
|
# If the url includes the language we get the title translated
|
||||||
title_RE=r'<span id="altHeadline" >(?P<title>.*)</span>'
|
title = self._html_search_regex(r'<span id="altHeadline" >(?P<title>.*)</span>',
|
||||||
title=re.search(title_RE, webpage).group('title')
|
webpage, 'title')
|
||||||
info_RE=r'''<script\ type="text/javascript">var\ talkDetails\ =(.*?)
|
json_data = self._search_regex(r'<script.*?>var talkDetails = ({.*?})</script>',
|
||||||
"id":(?P<videoID>[\d]+).*?
|
webpage, 'json data')
|
||||||
"mediaSlug":"(?P<mediaSlug>[\w\d]+?)"'''
|
info = json.loads(json_data)
|
||||||
thumb_RE=r'</span>[\s.]*</div>[\s.]*<img src="(?P<thumbnail>.*?)"'
|
desc = self._html_search_regex(r'<div class="talk-intro">.*?<p.*?>(.*?)</p>',
|
||||||
thumb_match=re.search(thumb_RE,webpage)
|
webpage, 'description', flags = re.DOTALL)
|
||||||
info_match=re.search(info_RE,webpage,re.VERBOSE)
|
|
||||||
video_id=info_match.group('videoID')
|
thumbnail = self._search_regex(r'</span>[\s.]*</div>[\s.]*<img src="(.*?)"',
|
||||||
mediaSlug=info_match.group('mediaSlug')
|
webpage, 'thumbnail')
|
||||||
video_url=self._talk_video_link(mediaSlug)
|
|
||||||
info = {
|
info = {
|
||||||
'id': video_id,
|
'id': info['id'],
|
||||||
'url': video_url,
|
'url': info['htmlStreams'][-1]['file'],
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': title,
|
'title': title,
|
||||||
'thumbnail': thumb_match.group('thumbnail')
|
'thumbnail': thumbnail,
|
||||||
|
'description': desc,
|
||||||
}
|
}
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user