1 from __future__ 
import unicode_literals
 
   5 from .common 
import InfoExtractor
 
   7     compat_urllib_parse_urlparse
, 
  13 class ExtremeTubeIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'^(?:https?://)?(?:www\.)?(?P<url>extremetube\.com/.*?video/.+?(?P<videoid>[0-9]+))(?:[/?&]|$)' 
  16         'url': 'http://www.extremetube.com/video/music-video-14-british-euro-brit-european-cumshots-swallow-652431', 
  17         'md5': '1fb9228f5e3332ec8c057d6ac36f33e0', 
  21             'title': 'Music Video 14 british euro brit european cumshots swallow', 
  22             'uploader': 'unknown', 
  26         'url': 'http://www.extremetube.com/gay/video/abcde-1234', 
  27         'only_matching': True, 
  30     def _real_extract(self
, url
): 
  31         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  32         video_id 
= mobj
.group('videoid') 
  33         url 
= 'http://www.' + mobj
.group('url') 
  35         req 
= compat_urllib_request
.Request(url
) 
  36         req
.add_header('Cookie', 'age_verified=1') 
  37         webpage 
= self
._download
_webpage
(req
, video_id
) 
  39         video_title 
= self
._html
_search
_regex
( 
  40             r
'<h1 [^>]*?title="([^"]+)"[^>]*>', webpage
, 'title') 
  41         uploader 
= self
._html
_search
_regex
( 
  42             r
'>Posted by:(?=<)(?:\s|<[^>]*>)*(.+?)\|', webpage
, 'uploader', 
  44         video_url 
= compat_urllib_parse
.unquote(self
._html
_search
_regex
( 
  45             r
'video_url=(.+?)&', webpage
, 'video_url')) 
  46         path 
= compat_urllib_parse_urlparse(video_url
).path
 
  47         format 
= path
.split('/')[5].split('_')[:2] 
  48         format 
= "-".join(format
)