]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/quickvid.py
Initiate new release.
[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 'skip': 'Not accessible from Travis CI server',
28 }
29
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32 webpage = self._download_webpage(url, video_id)
33
34 title = self._html_search_regex(r'<h2>(.*?)</h2>', webpage, 'title')
35 view_count = int_or_none(self._html_search_regex(
36 r'(?s)<div id="views">(.*?)</div>',
37 webpage, 'view count', fatal=False))
38 video_code = self._search_regex(
39 r'(?s)<video id="video"[^>]*>(.*?)</video>', webpage, 'video code')
40 formats = [
41 {
42 'url': compat_urlparse.urljoin(url, src),
43 'format_id': determine_ext(src, None),
44 } for src in re.findall('<source\s+src="([^"]+)"', video_code)
45 ]
46 self._sort_formats(formats)
47
48 return {
49 'id': video_id,
50 'title': title,
51 'formats': formats,
52 'thumbnail': self._og_search_thumbnail(webpage),
53 'view_count': view_count,
54 }