]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tube8.py
Merge pull request #1 from e7appew/python3
[youtubedl] / youtube_dl / extractor / tube8.py
1 from __future__ import unicode_literals
2
3 from ..utils import (
4 int_or_none,
5 str_to_int,
6 )
7 from .keezmovies import KeezMoviesIE
8
9
10 class Tube8IE(KeezMoviesIE):
11 _VALID_URL = r'https?://(?:www\.)?tube8\.com/(?:[^/]+/)+(?P<display_id>[^/]+)/(?P<id>\d+)'
12 _TESTS = [{
13 'url': 'http://www.tube8.com/teen/kasia-music-video/229795/',
14 'md5': '65e20c48e6abff62ed0c3965fff13a39',
15 'info_dict': {
16 'id': '229795',
17 'display_id': 'kasia-music-video',
18 'ext': 'mp4',
19 'description': 'hot teen Kasia grinding',
20 'uploader': 'unknown',
21 'title': 'Kasia music video',
22 'age_limit': 18,
23 'duration': 230,
24 }
25 }, {
26 'url': 'http://www.tube8.com/shemale/teen/blonde-cd-gets-kidnapped-by-two-blacks-and-punished-for-being-a-slutty-girl/19569151/',
27 'only_matching': True,
28 }]
29
30 def _real_extract(self, url):
31 webpage, info = self._extract_info(url)
32
33 if not info['title']:
34 info['title'] = self._html_search_regex(
35 r'videoTitle\s*=\s*"([^"]+)', webpage, 'title')
36
37 description = self._html_search_regex(
38 r'>Description:</strong>\s*(.+?)\s*<', webpage, 'description', fatal=False)
39 uploader = self._html_search_regex(
40 r'<span class="username">\s*(.+?)\s*<',
41 webpage, 'uploader', fatal=False)
42
43 like_count = int_or_none(self._search_regex(
44 r'rupVar\s*=\s*"(\d+)"', webpage, 'like count', fatal=False))
45 dislike_count = int_or_none(self._search_regex(
46 r'rdownVar\s*=\s*"(\d+)"', webpage, 'dislike count', fatal=False))
47 view_count = str_to_int(self._search_regex(
48 r'<strong>Views: </strong>([\d,\.]+)\s*</li>',
49 webpage, 'view count', fatal=False))
50 comment_count = str_to_int(self._search_regex(
51 r'<span id="allCommentsCount">(\d+)</span>',
52 webpage, 'comment count', fatal=False))
53
54 info.update({
55 'description': description,
56 'uploader': uploader,
57 'view_count': view_count,
58 'like_count': like_count,
59 'dislike_count': dislike_count,
60 'comment_count': comment_count,
61 })
62
63 return info