]>
Commit | Line | Data |
---|---|---|
8adec2b9 | 1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
8adec2b9 | 7 | from ..utils import ( |
9732d77e | 8 | float_or_none, |
8adec2b9 | 9 | str_to_int, |
9732d77e | 10 | parse_duration, |
8adec2b9 | 11 | ) |
12 | ||
9732d77e | 13 | |
8adec2b9 | 14 | class SnotrIE(InfoExtractor): |
15 | _VALID_URL = r'http?://(?:www\.)?snotr\.com/video/(?P<id>\d+)/([\w]+)' | |
9732d77e | 16 | _TESTS = [{ |
8adec2b9 | 17 | 'url': 'http://www.snotr.com/video/13708/Drone_flying_through_fireworks', |
18 | 'info_dict': { | |
19 | 'id': '13708', | |
20 | 'ext': 'flv', | |
21 | 'title': 'Drone flying through fireworks!', | |
22 | 'duration': 247, | |
9732d77e PH |
23 | 'filesize_approx': 98566144, |
24 | } | |
25 | }, { | |
8adec2b9 | 26 | 'url': 'http://www.snotr.com/video/530/David_Letteman_-_George_W_Bush_Top_10', |
27 | 'info_dict': { | |
28 | 'id': '530', | |
29 | 'ext': 'flv', | |
30 | 'title': 'David Letteman - George W. Bush Top 10', | |
31 | 'duration': 126, | |
9732d77e PH |
32 | 'filesize_approx': 8912896, |
33 | } | |
34 | }] | |
8adec2b9 | 35 | |
36 | def _real_extract(self, url): | |
37 | mobj = re.match(self._VALID_URL, url) | |
38 | video_id = mobj.group('id') | |
39 | ||
8adec2b9 | 40 | webpage = self._download_webpage(url, video_id) |
41 | title = self._og_search_title(webpage) | |
42 | ||
43 | description = self._og_search_description(webpage) | |
44 | ||
45 | video_url = "http://cdn.videos.snotr.com/%s.flv" % video_id | |
46 | ||
9732d77e PH |
47 | view_count = str_to_int(self._html_search_regex( |
48 | r'<p>\n<strong>Views:</strong>\n([\d,\.]+)</p>', | |
49 | webpage, 'view count', fatal=False)) | |
8adec2b9 | 50 | |
9732d77e PH |
51 | duration = parse_duration(self._html_search_regex( |
52 | r'<p>\n<strong>Length:</strong>\n\s*([0-9:]+).*?</p>', | |
53 | webpage, 'duration', fatal=False)) | |
8adec2b9 | 54 | |
9732d77e PH |
55 | filesize_approx = float_or_none(self._html_search_regex( |
56 | r'<p>\n<strong>Filesize:</strong>\n\s*([0-9.]+)\s*megabyte</p>', | |
57 | webpage, 'filesize', fatal=False), invscale=1024 * 1024) | |
8adec2b9 | 58 | |
59 | return { | |
60 | 'id': video_id, | |
61 | 'title': title, | |
9732d77e PH |
62 | 'url': video_url, |
63 | 'view_count': view_count, | |
64 | 'duration': duration, | |
65 | 'filesize_approx': filesize_approx, | |
66 | } |