1 from __future__ import unicode_literals
6 from .common import InfoExtractor
16 class XTubeIE(InfoExtractor):
17 _VALID_URL = r'https?://(?:www\.)?(?P<url>xtube\.com/watch\.php\?v=(?P<id>[^/?&]+))'
19 'url': 'http://www.xtube.com/watch.php?v=kVTUy_G222_',
20 'md5': '092fbdd3cbe292c920ef6fc6a8a9cdab',
24 'title': 'strange erotica',
25 'description': 'http://www.xtube.com an ET kind of thing',
26 'uploader': 'greenshowers',
32 def _real_extract(self, url):
33 mobj = re.match(self._VALID_URL, url)
34 video_id = mobj.group('id')
35 url = 'http://www.' + mobj.group('url')
37 req = compat_urllib_request.Request(url)
38 req.add_header('Cookie', 'age_verified=1')
39 webpage = self._download_webpage(req, video_id)
41 video_title = self._html_search_regex(r'<p class="title">([^<]+)', webpage, 'title')
42 video_uploader = self._html_search_regex(
43 r'so_s\.addVariable\("owner_u", "([^"]+)', webpage, 'uploader', fatal=False)
44 video_description = self._html_search_regex(
45 r'<p class="fieldsDesc">([^<]+)', webpage, 'description', fatal=False)
46 duration = parse_duration(self._html_search_regex(
47 r'<span class="bold">Runtime:</span> ([^<]+)</p>', webpage, 'duration', fatal=False))
48 view_count = self._html_search_regex(
49 r'<span class="bold">Views:</span> ([\d,\.]+)</p>', webpage, 'view count', fatal=False)
51 view_count = str_to_int(view_count)
52 comment_count = self._html_search_regex(
53 r'<div id="commentBar">([\d,\.]+) Comments</div>', webpage, 'comment count', fatal=False)
55 comment_count = str_to_int(comment_count)
57 player_quality_option = json.loads(self._html_search_regex(
58 r'playerQualityOption = ({.+?});', webpage, 'player quality option'))
60 QUALITIES = ['3gp', 'mp4_normal', 'mp4_high', 'flv', 'mp4_ultra', 'mp4_720', 'mp4_1080']
64 'format_id': format_id,
65 'preference': QUALITIES.index(format_id) if format_id in QUALITIES else -1,
66 } for format_id, furl in player_quality_option.items()
68 self._sort_formats(formats)
73 'uploader': video_uploader,
74 'description': video_description,
76 'view_count': view_count,
77 'comment_count': comment_count,
83 class XTubeUserIE(InfoExtractor):
84 IE_DESC = 'XTube user profile'
85 _VALID_URL = r'https?://(?:www\.)?xtube\.com/community/profile\.php\?(.*?)user=(?P<username>[^&#]+)(?:$|[&#])'
87 'url': 'http://www.xtube.com/community/profile.php?user=greenshowers',
91 'playlist_mincount': 155,
94 def _real_extract(self, url):
95 mobj = re.match(self._VALID_URL, url)
96 username = mobj.group('username')
98 profile_page = self._download_webpage(
99 url, username, note='Retrieving profile page')
101 video_count = int(self._search_regex(
102 r'<strong>%s\'s Videos \(([0-9]+)\)</strong>' % username, profile_page,
107 page_count = (video_count + PAGE_SIZE + 1) // PAGE_SIZE
108 for n in range(1, page_count + 1):
109 lpage_url = 'http://www.xtube.com/user_videos.php?page=%d&u=%s' % (n, username)
110 lpage = self._download_webpage(
112 note='Downloading page %d/%d' % (n, page_count))
114 re.findall(r'addthis:url="([^"]+)"', lpage))