]>
Commit | Line | Data |
---|---|---|
8adec2b9 | 1 | from .common import InfoExtractor |
8adec2b9 | 2 | from ..utils import ( |
9732d77e | 3 | parse_duration, |
19f35402 YCH |
4 | parse_filesize, |
5 | str_to_int, | |
8adec2b9 | 6 | ) |
7 | ||
9732d77e | 8 | |
8adec2b9 | 9 | class SnotrIE(InfoExtractor): |
10 | _VALID_URL = r'http?://(?:www\.)?snotr\.com/video/(?P<id>\d+)/([\w]+)' | |
9732d77e | 11 | _TESTS = [{ |
8adec2b9 | 12 | 'url': 'http://www.snotr.com/video/13708/Drone_flying_through_fireworks', |
13 | 'info_dict': { | |
14 | 'id': '13708', | |
19f35402 | 15 | 'ext': 'mp4', |
8adec2b9 | 16 | 'title': 'Drone flying through fireworks!', |
19f35402 YCH |
17 | 'duration': 248, |
18 | 'filesize_approx': 40700000, | |
da8fb858 | 19 | 'description': 'A drone flying through Fourth of July Fireworks', |
ec85ded8 | 20 | 'thumbnail': r're:^https?://.*\.jpg$', |
19f35402 YCH |
21 | }, |
22 | 'expected_warnings': ['description'], | |
9732d77e | 23 | }, { |
8adec2b9 | 24 | 'url': 'http://www.snotr.com/video/530/David_Letteman_-_George_W_Bush_Top_10', |
25 | 'info_dict': { | |
26 | 'id': '530', | |
19f35402 | 27 | 'ext': 'mp4', |
8adec2b9 | 28 | 'title': 'David Letteman - George W. Bush Top 10', |
29 | 'duration': 126, | |
19f35402 | 30 | 'filesize_approx': 8500000, |
da8fb858 | 31 | 'description': 'The top 10 George W. Bush moments, brought to you by David Letterman!', |
ec85ded8 | 32 | 'thumbnail': r're:^https?://.*\.jpg$', |
9732d77e PH |
33 | } |
34 | }] | |
8adec2b9 | 35 | |
36 | def _real_extract(self, url): | |
5ad28e7f | 37 | mobj = self._match_valid_url(url) |
8adec2b9 | 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) | |
ad120ae1 YCH |
44 | info_dict = self._parse_html5_media_entries( |
45 | url, webpage, video_id, m3u8_entry_protocol='m3u8_native')[0] | |
8adec2b9 | 46 | |
9732d77e | 47 | view_count = str_to_int(self._html_search_regex( |
19f35402 | 48 | r'<p[^>]*>\s*<strong[^>]*>Views:</strong>\s*<span[^>]*>([\d,\.]+)', |
9732d77e | 49 | webpage, 'view count', fatal=False)) |
8adec2b9 | 50 | |
9732d77e | 51 | duration = parse_duration(self._html_search_regex( |
19f35402 | 52 | r'<p[^>]*>\s*<strong[^>]*>Length:</strong>\s*<span[^>]*>([\d:]+)', |
9732d77e | 53 | webpage, 'duration', fatal=False)) |
8adec2b9 | 54 | |
19f35402 YCH |
55 | filesize_approx = parse_filesize(self._html_search_regex( |
56 | r'<p[^>]*>\s*<strong[^>]*>Filesize:</strong>\s*<span[^>]*>([^<]+)', | |
57 | webpage, 'filesize', fatal=False)) | |
8adec2b9 | 58 | |
19f35402 | 59 | info_dict.update({ |
8adec2b9 | 60 | 'id': video_id, |
da8fb858 | 61 | 'description': description, |
8adec2b9 | 62 | 'title': title, |
9732d77e PH |
63 | 'view_count': view_count, |
64 | 'duration': duration, | |
65 | 'filesize_approx': filesize_approx, | |
19f35402 YCH |
66 | }) |
67 | ||
68 | return info_dict |