[Vidbit] Add new extractor
[youtube-dl] / youtube_dl / extractor / vidbit.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import url_basename
8 from ..compat import compat_urlparse
9
10
11 class VidbitIE(InfoExtractor):
12     _VALID_URL = r'https?://(?:www\.)?vidbit\.co/watch\?v=(?P<id>[\w-]+)'
13     _TEST = {
14         'url': 'http://www.vidbit.co/watch?v=MrM7LeaMJq',
15         'md5': 'f1a579a93282a78de7e1c53220ef0f12',
16         'info_dict': {
17             'id': 'MrM7LeaMJq',
18             'ext': 'mp4',
19             'title': 'RoboCop (1987) - Dick You\'re Fired',
20             'thumbnail': 'http://www.vidbit.co/thumbnails/MrM7LeaMJq.jpg',
21         }
22     }
23
24     def _real_extract(self, url):
25         video_id = self._match_id(url)
26         webpage = self._download_webpage(url, video_id)
27
28         return {
29             'id': video_id,
30             'title': self._html_search_regex(r'<h1>(.+)</h1>', webpage, 'title'),
31             'url': compat_urlparse.urljoin(url, self._html_search_regex(r'file:\s*(["\'])((?:(?!\1).)+)\1',
32                 webpage, 'video URL', group=2)),
33             'thumbnail': self._og_search_thumbnail(webpage),
34             'description': self._html_search_regex(r'description:(["\'])((?:(?!\1).)+)\1',
35                 webpage, 'description', None, group=2),
36         }