[manyvids] Add support for preview videos (closes #14053)
[youtube-dl] / youtube_dl / extractor / manyvids.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..compat import compat_urllib_parse_unquote
6
7
8 class ManyVidsIE(InfoExtractor):
9     _VALID_URL = r'https?://www.manyvids\.com/Video/(?P<id>[0-9]+)'
10     _TEST = {
11         'url': 'https://www.manyvids.com/Video/133957/everthing-about-me/',
12         'md5': '03f11bb21c52dd12a05be21a5c7dcc97',
13         'info_dict': {
14             'id': '133957',
15             'ext': 'mp4',
16             'title': 'everthing about me',
17
18         }
19     }
20
21     def _real_extract(self, url):
22         formats = []
23         video_id = self._match_id(url)
24         webpage = self._download_webpage(url, video_id)
25         video_url = compat_urllib_parse_unquote(self._search_regex(
26             r'data-video-filepath=\"(.+?)\"', webpage, 'video URL', default=''))
27
28         title = self._html_search_regex(r'<h2[^>]+class="m-a-0"[^>]*>([^<]+)', webpage, 'title')
29         formats.append({
30             'url': video_url
31         })
32         return {
33             'id': video_id,
34             'title': title,
35             'formats': formats,
36         }