2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
   7     compat_urllib_parse_unquote
, 
  19 class IzleseneIE(InfoExtractor
): 
  21         https?://(?:(?:www|m)\.)?izlesene\.com/ 
  22         (?:video|embedplayer)/(?:[^/]+/)?(?P<id>[0-9]+) 
  26             'url': 'http://www.izlesene.com/video/sevincten-cildirtan-dogum-gunu-hediyesi/7599694', 
  27             'md5': '4384f9f0ea65086734b881085ee05ac2', 
  31                 'title': 'Sevinçten Çıldırtan Doğum Günü Hediyesi', 
  32                 'description': 'md5:253753e2655dde93f59f74b572454f6d', 
  33                 'thumbnail': r
're:^https?://.*\.jpg', 
  34                 'uploader_id': 'pelikzzle', 
  36                 'upload_date': '20140702', 
  42             'url': 'http://www.izlesene.com/video/tarkan-dortmund-2006-konseri/17997', 
  43             'md5': '97f09b6872bffa284cb7fa4f6910cb72', 
  47                 'title': 'Tarkan Dortmund 2006 Konseri', 
  48                 'thumbnail': r
're:^https://.*\.jpg', 
  49                 'uploader_id': 'parlayankiz', 
  51                 'upload_date': '20061112', 
  58     def _real_extract(self
, url
): 
  59         video_id 
= self
._match
_id
(url
) 
  61         webpage 
= self
._download
_webpage
('http://www.izlesene.com/video/%s' % video_id
, video_id
) 
  63         video 
= self
._parse
_json
( 
  65                 r
'videoObj\s*=\s*({.+?})\s*;\s*\n', webpage
, 'streams'), 
  68         title 
= video
.get('videoTitle') or self
._og
_search
_title
(webpage
) 
  71         for stream 
in video
['media']['level']: 
  72             source_url 
= stream
.get('source') 
  73             if not source_url 
or not isinstance(source_url
, compat_str
): 
  75             ext 
= determine_ext(url
, 'mp4') 
  76             quality 
= stream
.get('value') 
  77             height 
= int_or_none(quality
) 
  79                 'format_id': '%sp' % quality 
if quality 
else 'sd', 
  80                 'url': compat_urllib_parse_unquote(source_url
), 
  84         self
._sort
_formats
(formats
) 
  86         description 
= self
._og
_search
_description
(webpage
, default
=None) 
  87         thumbnail 
= video
.get('posterURL') or self
._proto
_relative
_url
( 
  88             self
._og
_search
_thumbnail
(webpage
), scheme
='http:') 
  90         uploader 
= self
._html
_search
_regex
( 
  91             r
"adduserUsername\s*=\s*'([^']+)';", 
  92             webpage
, 'uploader', fatal
=False) 
  93         timestamp 
= parse_iso8601(self
._html
_search
_meta
( 
  94             'uploadDate', webpage
, 'upload date')) 
  96         duration 
= float_or_none(video
.get('duration') or self
._html
_search
_regex
( 
  97             r
'videoduration["\']?\s
*=\s
*(["\'])(?P<value>(?:(?!\1).)+)\1', 
  98             webpage, 'duration', fatal=False, group='value'), scale=1000) 
 100         view_count = str_to_int(get_element_by_id('videoViewCount', webpage)) 
 101         comment_count = self._html_search_regex( 
 102             r'comment_count\s*=\s*\'([^\']+)\';', 
 103             webpage, 'comment_count', fatal=False) 
 108             'description': description, 
 109             'thumbnail': thumbnail, 
 110             'uploader_id': uploader, 
 111             'timestamp': timestamp, 
 112             'duration': duration, 
 113             'view_count': int_or_none(view_count), 
 114             'comment_count': int_or_none(comment_count), 
 115             'age_limit': self._family_friendly_search(webpage),