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