2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
   5 from ..compat 
import compat_urllib_parse_unquote
 
  12 class NozIE(InfoExtractor
): 
  13     _VALID_URL 
= r
'https?://(?:www\.)?noz\.de/video/(?P<id>[0-9]+)/' 
  15         'url': 'http://www.noz.de/video/25151/32-Deutschland-gewinnt-Badminton-Lnderspiel-in-Melle', 
  20             'title': '3:2 - Deutschland gewinnt Badminton-Länderspiel in Melle', 
  21             'description': 'Vor rund 370 Zuschauern gewinnt die deutsche Badminton-Nationalmannschaft am Donnerstag ein EM-Vorbereitungsspiel gegen Frankreich in Melle. Video Moritz Frankenberg.', 
  22             'thumbnail': 're:^http://.*\.jpg', 
  26     def _real_extract(self
, url
): 
  27         video_id 
= self
._match
_id
(url
) 
  28         webpage 
= self
._download
_webpage
(url
, video_id
) 
  29         description 
= self
._og
_search
_description
(webpage
) 
  31         edge_url 
= self
._html
_search
_regex
( 
  32             r
'<script\s+(?:type="text/javascript"\s+)?src="(.*?/videojs_.*?)"', 
  34         edge_content 
= self
._download
_webpage
(edge_url
, 'meta configuration') 
  36         config_url_encoded 
= self
._search
_regex
( 
  37             r
'so\.addVariable\("config_url","[^,]*,(.*?)"', 
  38             edge_content
, 'config URL' 
  40         config_url 
= compat_urllib_parse_unquote(config_url_encoded
) 
  42         doc 
= self
._download
_xml
(config_url
, 'video configuration') 
  43         title 
= xpath_text(doc
, './/title') 
  44         thumbnail 
= xpath_text(doc
, './/article/thumbnail/url') 
  45         duration 
= int_or_none(xpath_text( 
  46             doc
, './/article/movie/file/duration')) 
  48         for qnode 
in doc
.findall('.//article/movie/file/qualities/qual'): 
  49             video_node 
= qnode
.find('./html_urls/video_url[@format="video/mp4"]') 
  50             if video_node 
is None: 
  53                 'url': video_node
.text
, 
  54                 'format_name': xpath_text(qnode
, './name'), 
  55                 'format_id': xpath_text(qnode
, './id'), 
  56                 'height': int_or_none(xpath_text(qnode
, './height')), 
  57                 'width': int_or_none(xpath_text(qnode
, './width')), 
  58                 'tbr': int_or_none(xpath_text(qnode
, './bitrate'), scale
=1000), 
  60         self
._sort
_formats
(formats
) 
  67             'description': description
, 
  68             'thumbnail': thumbnail
,