]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/quickvid.py
debian/control: Add recommends on aria2 | wget | curl to use external downloaders.
[youtubedl] / youtube_dl / extractor / quickvid.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6 from ..compat import (
7 compat_urlparse,
8 )
9 from ..utils import (
10 determine_ext,
11 int_or_none,
12 )
13
14
15 class QuickVidIE(InfoExtractor):
16 _VALID_URL = r'https?://(www\.)?quickvid\.org/watch\.php\?v=(?P<id>[a-zA-Z_0-9-]+)'
17 _TEST = {
18 'url': 'http://quickvid.org/watch.php?v=sUQT3RCG8dx',
19 'md5': 'c0c72dd473f260c06c808a05d19acdc5',
20 'info_dict': {
21 'id': 'sUQT3RCG8dx',
22 'ext': 'mp4',
23 'title': 'Nick Offerman\'s Summer Reading Recap',
24 'thumbnail': 're:^https?://.*\.(?:png|jpg|gif)$',
25 'view_count': int,
26 },
27 }
28
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31 webpage = self._download_webpage(url, video_id)
32
33 title = self._html_search_regex(r'<h2>(.*?)</h2>', webpage, 'title')
34 view_count = int_or_none(self._html_search_regex(
35 r'(?s)<div id="views">(.*?)</div>',
36 webpage, 'view count', fatal=False))
37 video_code = self._search_regex(
38 r'(?s)<video id="video"[^>]*>(.*?)</video>', webpage, 'video code')
39 formats = [
40 {
41 'url': compat_urlparse.urljoin(url, src),
42 'format_id': determine_ext(src, None),
43 } for src in re.findall('<source\s+src="([^"]+)"', video_code)
44 ]
45 self._sort_formats(formats)
46
47 return {
48 'id': video_id,
49 'title': title,
50 'formats': formats,
51 'thumbnail': self._og_search_thumbnail(webpage),
52 'view_count': view_count,
53 }