1 from __future__ import unicode_literals
5 from .common import InfoExtractor
16 class FourTubeIE(InfoExtractor):
18 _VALID_URL = r'https?://(?:www\.)?4tube\.com/videos/(?P<id>\d+)'
21 'url': 'http://www.4tube.com/videos/209733/hot-babe-holly-michaels-gets-her-ass-stuffed-by-black',
22 'md5': '6516c8ac63b03de06bc8eac14362db4f',
26 'title': 'Hot Babe Holly Michaels gets her ass stuffed by black',
27 'uploader': 'WCP Club',
28 'uploader_id': 'wcp-club',
29 'upload_date': '20131031',
30 'timestamp': 1383263892,
39 def _real_extract(self, url):
40 video_id = self._match_id(url)
41 webpage = self._download_webpage(url, video_id)
43 title = self._html_search_meta('name', webpage)
44 timestamp = parse_iso8601(self._html_search_meta(
45 'uploadDate', webpage))
46 thumbnail = self._html_search_meta('thumbnailUrl', webpage)
47 uploader_id = self._html_search_regex(
48 r'<a class="img-avatar" href="[^"]+/channels/([^/"]+)" title="Go to [^"]+ page">',
49 webpage, 'uploader id', fatal=False)
50 uploader = self._html_search_regex(
51 r'<a class="img-avatar" href="[^"]+/channels/[^/"]+" title="Go to ([^"]+) page">',
52 webpage, 'uploader', fatal=False)
54 categories_html = self._search_regex(
55 r'(?s)><i class="icon icon-tag"></i>\s*Categories / Tags\s*.*?<ul class="list">(.*?)</ul>',
56 webpage, 'categories', fatal=False)
60 c.strip() for c in re.findall(
61 r'(?s)<li><a.*?>(.*?)</a>', categories_html)]
63 view_count = str_to_int(self._search_regex(
64 r'<meta itemprop="interactionCount" content="UserPlays:([0-9,]+)">',
65 webpage, 'view count', fatal=False))
66 like_count = str_to_int(self._search_regex(
67 r'<meta itemprop="interactionCount" content="UserLikes:([0-9,]+)">',
68 webpage, 'like count', fatal=False))
69 duration = parse_duration(self._html_search_meta('duration', webpage))
71 media_id = self._search_regex(
72 r'<button[^>]+data-id=(["\'])(?P<id>\d+)\1[^>]+data-quality=', webpage,
73 'media id', default=None, group='id')
76 for _, quality in re.findall(r'<button[^>]+data-quality=(["\'])(.+?)\1', webpage)]
77 if not (media_id and sources):
78 player_js = self._download_webpage(
80 r'<script[^>]id=(["\'])playerembed\1[^>]+src=(["\'])(?P<url>.+?)\2',
81 webpage, 'player JS', group='url'),
82 video_id, 'Downloading player JS')
83 params_js = self._search_regex(
84 r'\$\.ajax\(url,\ opts\);\s*\}\s*\}\)\(([0-9,\[\] ]+)\)',
85 player_js, 'initialization parameters')
86 params = self._parse_json('[%s]' % params_js, video_id)
88 sources = ['%s' % p for p in params[2]]
90 token_url = 'http://tkn.4tube.com/{0}/desktop/{1}'.format(
91 media_id, '+'.join(sources))
93 b'Content-Type': b'application/x-www-form-urlencoded',
94 b'Origin': b'http://www.4tube.com',
96 token_req = compat_urllib_request.Request(token_url, b'{}', headers)
97 tokens = self._download_json(token_req, video_id)
99 'url': tokens[format]['token'],
100 'format_id': format + 'p',
101 'resolution': format + 'p',
102 'quality': int(format),
103 } for format in sources]
104 self._sort_formats(formats)
110 'categories': categories,
111 'thumbnail': thumbnail,
112 'uploader': uploader,
113 'uploader_id': uploader_id,
114 'timestamp': timestamp,
115 'like_count': like_count,
116 'view_count': view_count,
117 'duration': duration,