1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-15 03:27:46 +01:00
youtube-dl/youtube_dl/extractor/howcast.py

42 lines
1.5 KiB
Python
Raw Normal View History

2014-02-10 20:45:17 +01:00
from __future__ import unicode_literals
2013-06-23 22:30:16 +02:00
import re
from .common import InfoExtractor
class HowcastIE(InfoExtractor):
2014-02-10 20:45:17 +01:00
_VALID_URL = r'https?://(?:www\.)?howcast\.com/videos/(?P<id>\d+)'
2013-06-27 20:46:46 +02:00
_TEST = {
2014-02-10 20:45:17 +01:00
'url': 'http://www.howcast.com/videos/390161-How-to-Tie-a-Square-Knot-Properly',
'md5': '8b743df908c42f60cf6496586c7f12c3',
'info_dict': {
'id': '390161',
'ext': 'mp4',
2014-11-23 20:41:03 +01:00
'description': 'The square knot, also known as the reef knot, is one of the oldest, most basic knots to tie, and can be used in many different ways. Here\'s the proper way to tie a square knot.',
2014-02-10 20:45:17 +01:00
'title': 'How to Tie a Square Knot Properly',
2013-06-27 20:46:46 +02:00
}
}
2013-06-23 22:30:16 +02:00
def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id)
2013-06-23 22:30:16 +02:00
self.report_extraction(video_id)
video_url = self._search_regex(r'\'?file\'?: "(http://mobile-media\.howcast\.com/[0-9]+\.mp4)',
2014-11-23 21:39:15 +01:00
webpage, 'video URL')
2013-06-23 22:30:16 +02:00
video_description = self._html_search_regex(r'<meta content=(?:"([^"]+)"|\'([^\']+)\') name=\'description\'',
2014-11-23 21:39:15 +01:00
webpage, 'description', fatal=False)
2013-06-23 22:30:16 +02:00
2014-02-10 20:45:17 +01:00
return {
'id': video_id,
'url': video_url,
'title': self._og_search_title(webpage),
2013-06-23 22:30:16 +02:00
'description': video_description,
2014-02-10 20:45:17 +01:00
'thumbnail': self._og_search_thumbnail(webpage),
}