]>
Commit | Line | Data |
---|---|---|
43f0537c | 1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
4 | ||
5 | from .common import InfoExtractor | |
e0942e37 S |
6 | from ..utils import ( |
7 | parse_iso8601, | |
8 | str_to_int, | |
9 | ) | |
10 | ||
43f0537c | 11 | |
12 | class CrackedIE(InfoExtractor): | |
e0942e37 | 13 | _VALID_URL = r'https?://(?:www\.)?cracked\.com/video_(?P<id>\d+)_[\da-z-]+\.html' |
43f0537c | 14 | _TEST = { |
e0942e37 S |
15 | 'url': 'http://www.cracked.com/video_19006_4-plot-holes-you-didnt-notice-in-your-favorite-movies.html', |
16 | 'md5': '4b29a5eeec292cd5eca6388c7558db9e', | |
43f0537c | 17 | 'info_dict': { |
e0942e37 | 18 | 'id': '19006', |
43f0537c | 19 | 'ext': 'mp4', |
e0942e37 S |
20 | 'title': '4 Plot Holes You Didn\'t Notice in Your Favorite Movies', |
21 | 'description': 'md5:3b909e752661db86007d10e5ec2df769', | |
22 | 'timestamp': 1405659600, | |
23 | 'upload_date': '20140718', | |
43f0537c | 24 | } |
25 | } | |
26 | ||
27 | def _real_extract(self, url): | |
28 | mobj = re.match(self._VALID_URL, url) | |
29 | video_id = mobj.group('id') | |
30 | ||
31 | webpage = self._download_webpage(url, video_id) | |
43f0537c | 32 | |
e0942e37 S |
33 | video_url = self._html_search_regex( |
34 | [r'var\s+CK_vidSrc\s*=\s*"([^"]+)"', r'<video\s+src="([^"]+)"'], webpage, 'video URL') | |
43f0537c | 35 | |
e0942e37 S |
36 | title = self._og_search_title(webpage) |
37 | description = self._og_search_description(webpage) | |
43f0537c | 38 | |
e0942e37 S |
39 | timestamp = self._html_search_regex(r'<time datetime="([^"]+)"', webpage, 'upload date', fatal=False) |
40 | if timestamp: | |
41 | timestamp = parse_iso8601(timestamp[:-6]) | |
43f0537c | 42 | |
e0942e37 S |
43 | view_count = str_to_int(self._html_search_regex( |
44 | r'<span class="views" id="viewCounts">([\d,\.]+) Views</span>', webpage, 'view count', fatal=False)) | |
45 | comment_count = str_to_int(self._html_search_regex( | |
46 | r'<span id="commentCounts">([\d,\.]+)</span>', webpage, 'comment count', fatal=False)) | |
43f0537c | 47 | |
e0942e37 S |
48 | m = re.search(r'_(?P<width>\d+)X(?P<height>\d+)\.mp4$', video_url) |
49 | if m: | |
50 | width = int(m.group('width')) | |
51 | height = int(m.group('height')) | |
52 | else: | |
53 | width = height = None | |
43f0537c | 54 | |
e0942e37 S |
55 | return { |
56 | 'id': video_id, | |
57 | 'url':video_url, | |
58 | 'title': title, | |
59 | 'description': description, | |
60 | 'timestamp': timestamp, | |
61 | 'view_count': view_count, | |
62 | 'comment_count': comment_count, | |
63 | 'height': height, | |
64 | 'width': width, | |
43f0537c | 65 | } |