1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_urllib_parse_unquote
14 class XTubeIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?(?P<url>xtube\.com/watch\.php\?v=(?P<id>[^/?&#]+))'
17 'url': 'http://www.xtube.com/watch.php?v=kVTUy_G222_',
18 'md5': '092fbdd3cbe292c920ef6fc6a8a9cdab',
22 'title': 'strange erotica',
23 'description': 'contains:an ET kind of thing',
24 'uploader': 'greenshowers',
30 def _real_extract(self
, url
):
31 video_id
= self
._match
_id
(url
)
33 req
= sanitized_Request(url
)
34 req
.add_header('Cookie', 'age_verified=1')
35 webpage
= self
._download
_webpage
(req
, video_id
)
37 video_title
= self
._html
_search
_regex
(
38 r
'<p class="title">([^<]+)', webpage
, 'title')
39 video_uploader
= self
._html
_search
_regex
(
40 [r
"var\s+contentOwnerId\s*=\s*'([^']+)",
41 r
'By:\s*<a href="/community/profile\.php\?user=([^"]+)'],
42 webpage
, 'uploader', fatal
=False)
43 video_description
= self
._html
_search
_regex
(
44 r
'<p class="fieldsDesc">([^<]+)',
45 webpage
, 'description', fatal
=False)
46 duration
= parse_duration(self
._html
_search
_regex
(
47 r
'<span class="bold">Runtime:</span> ([^<]+)</p>',
48 webpage
, 'duration', fatal
=False))
49 view_count
= str_to_int(self
._html
_search
_regex
(
50 r
'<span class="bold">Views:</span> ([\d,\.]+)</p>',
51 webpage
, 'view count', fatal
=False))
52 comment_count
= str_to_int(self
._html
_search
_regex
(
53 r
'<div id="commentBar">([\d,\.]+) Comments</div>',
54 webpage
, 'comment count', fatal
=False))
57 for format_id
, video_url
in re
.findall(
58 r
'flashvars\.quality_(.+?)\s*=\s*"([^"]+)"', webpage
):
60 'url': compat_urllib_parse_unquote(video_url
),
61 'format_id': format_id
,
63 m
= re
.search(r
'^(?P<height>\d+)[pP]', format_id
)
65 fmt
['height'] = int(m
.group('height'))
69 video_url
= compat_urllib_parse_unquote(self
._search
_regex
(
70 r
'flashvars\.video_url\s*=\s*"([^"]+)"',
71 webpage
, 'video URL'))
72 formats
.append({'url': video_url
})
74 self
._sort
_formats
(formats
)
79 'uploader': video_uploader
,
80 'description': video_description
,
82 'view_count': view_count
,
83 'comment_count': comment_count
,
89 class XTubeUserIE(InfoExtractor
):
90 IE_DESC
= 'XTube user profile'
91 _VALID_URL
= r
'https?://(?:www\.)?xtube\.com/community/profile\.php\?(.*?)user=(?P<username>[^&#]+)(?:$|[&#])'
93 'url': 'http://www.xtube.com/community/profile.php?user=greenshowers',
98 'playlist_mincount': 155,
101 def _real_extract(self
, url
):
102 mobj
= re
.match(self
._VALID
_URL
, url
)
103 username
= mobj
.group('username')
105 profile_page
= self
._download
_webpage
(
106 url
, username
, note
='Retrieving profile page')
108 video_count
= int(self
._search
_regex
(
109 r
'<strong>%s\'s Videos \
(([0-9]+)\
)</strong
>' % username, profile_page,
114 page_count = (video_count + PAGE_SIZE + 1) // PAGE_SIZE
115 for n in range(1, page_count + 1):
116 lpage_url = 'http
://www
.xtube
.com
/user_videos
.php?page
=%d&u
=%s' % (n, username)
117 lpage = self._download_webpage(
119 note='Downloading page
%d/%d' % (n, page_count))
121 re.findall(r'addthis
:url
="([^"]+)"', lpage))