]>
Commit | Line | Data |
---|---|---|
2fb3deec S |
1 | from __future__ import unicode_literals |
2 | ||
6599c725 S |
3 | import re |
4 | ||
1cc79574 | 5 | from ..utils import ( |
2fb3deec S |
6 | int_or_none, |
7 | str_to_int, | |
1d45a23b | 8 | ) |
8804f10e | 9 | from .keezmovies import KeezMoviesIE |
2fb3deec | 10 | |
1d45a23b | 11 | |
8804f10e | 12 | class Tube8IE(KeezMoviesIE): |
58e7071a | 13 | _VALID_URL = r'https?://(?:www\.)?tube8\.com/(?:[^/]+/)+(?P<display_id>[^/]+)/(?P<id>\d+)' |
7dde358a S |
14 | _TESTS = [{ |
15 | 'url': 'http://www.tube8.com/teen/kasia-music-video/229795/', | |
16 | 'md5': '65e20c48e6abff62ed0c3965fff13a39', | |
17 | 'info_dict': { | |
18 | 'id': '229795', | |
19 | 'display_id': 'kasia-music-video', | |
20 | 'ext': 'mp4', | |
21 | 'description': 'hot teen Kasia grinding', | |
22 | 'uploader': 'unknown', | |
23 | 'title': 'Kasia music video', | |
24 | 'age_limit': 18, | |
25 | 'duration': 230, | |
6599c725 S |
26 | 'categories': ['Teen'], |
27 | 'tags': ['dancing'], | |
28 | }, | |
a616f654 | 29 | }, { |
7dde358a S |
30 | 'url': 'http://www.tube8.com/shemale/teen/blonde-cd-gets-kidnapped-by-two-blacks-and-punished-for-being-a-slutty-girl/19569151/', |
31 | 'only_matching': True, | |
32 | }] | |
1d45a23b | 33 | |
34 | def _real_extract(self, url): | |
8804f10e | 35 | webpage, info = self._extract_info(url) |
2fb3deec | 36 | |
8804f10e S |
37 | if not info['title']: |
38 | info['title'] = self._html_search_regex( | |
39 | r'videoTitle\s*=\s*"([^"]+)', webpage, 'title') | |
2fb3deec | 40 | |
2fb3deec | 41 | description = self._html_search_regex( |
6ebdfe43 | 42 | r'>Description:</strong>\s*(.+?)\s*<', webpage, 'description', fatal=False) |
2fb3deec | 43 | uploader = self._html_search_regex( |
6ebdfe43 | 44 | r'<span class="username">\s*(.+?)\s*<', |
2fb3deec S |
45 | webpage, 'uploader', fatal=False) |
46 | ||
7dde358a | 47 | like_count = int_or_none(self._search_regex( |
6ebdfe43 | 48 | r'rupVar\s*=\s*"(\d+)"', webpage, 'like count', fatal=False)) |
7dde358a | 49 | dislike_count = int_or_none(self._search_regex( |
6ebdfe43 | 50 | r'rdownVar\s*=\s*"(\d+)"', webpage, 'dislike count', fatal=False)) |
7dde358a S |
51 | view_count = str_to_int(self._search_regex( |
52 | r'<strong>Views: </strong>([\d,\.]+)\s*</li>', | |
53 | webpage, 'view count', fatal=False)) | |
54 | comment_count = str_to_int(self._search_regex( | |
55 | r'<span id="allCommentsCount">(\d+)</span>', | |
56 | webpage, 'comment count', fatal=False)) | |
1d45a23b | 57 | |
6599c725 S |
58 | category = self._search_regex( |
59 | r'Category:\s*</strong>\s*<a[^>]+href=[^>]+>([^<]+)', | |
60 | webpage, 'category', fatal=False) | |
61 | categories = [category] if category else None | |
62 | ||
63 | tags_str = self._search_regex( | |
64 | r'(?s)Tags:\s*</strong>(.+?)</(?!a)', | |
65 | webpage, 'tags', fatal=False) | |
66 | tags = [t for t in re.findall( | |
67 | r'<a[^>]+href=[^>]+>([^<]+)', tags_str)] if tags_str else None | |
68 | ||
8804f10e | 69 | info.update({ |
2fb3deec | 70 | 'description': description, |
2fb3deec | 71 | 'uploader': uploader, |
2fb3deec S |
72 | 'view_count': view_count, |
73 | 'like_count': like_count, | |
74 | 'dislike_count': dislike_count, | |
75 | 'comment_count': comment_count, | |
6599c725 S |
76 | 'categories': categories, |
77 | 'tags': tags, | |
8804f10e S |
78 | }) |
79 | ||
80 | return info |