]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/spiegel.py
9ed7d3b39e227806971fe98f43e1c1018b84ad3c
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   7 from ..utils 
import compat_urlparse
 
  10 class SpiegelIE(InfoExtractor
): 
  11     _VALID_URL 
= r
'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<videoID>[0-9]+)(?:\.html)?(?:#.*)?$' 
  13         'url': 'http://www.spiegel.de/video/vulkan-tungurahua-in-ecuador-ist-wieder-aktiv-video-1259285.html', 
  14         'md5': '2c2754212136f35fb4b19767d242f66e', 
  18             'title': 'Vulkanausbruch in Ecuador: Der "Feuerschlund" ist wieder aktiv', 
  19             'description': 'md5:8029d8310232196eb235d27575a8b9f4', 
  23         'url': 'http://www.spiegel.de/video/schach-wm-videoanalyse-des-fuenften-spiels-video-1309159.html', 
  24         'md5': 'f2cdf638d7aa47654e251e1aee360af1', 
  28             'title': 'Schach-WM in der Videoanalyse: Carlsen nutzt die Fehlgriffe des Titelverteidigers', 
  29             'description': 'md5:c2322b65e58f385a820c10fa03b2d088', 
  34     def _real_extract(self
, url
): 
  35         m 
= re
.match(self
._VALID
_URL
, url
) 
  36         video_id 
= m
.group('videoID') 
  38         webpage 
= self
._download
_webpage
(url
, video_id
) 
  40         title 
= self
._html
_search
_regex
( 
  41             r
'<div class="module-title">(.*?)</div>', webpage
, 'title') 
  42         description 
= self
._html
_search
_meta
('description', webpage
, 'description') 
  44         base_url 
= self
._search
_regex
( 
  45             r
'var\s+server\s*=\s*"([^"]+)\"', webpage
, 'server URL') 
  47         xml_url 
= base_url 
+ video_id 
+ '.xml' 
  48         idoc 
= self
._download
_xml
(xml_url
, video_id
) 
  52                 'format_id': n
.tag
.rpartition('type')[2], 
  53                 'url': base_url 
+ n
.find('./filename').text
, 
  54                 'width': int(n
.find('./width').text
), 
  55                 'height': int(n
.find('./height').text
), 
  56                 'abr': int(n
.find('./audiobitrate').text
), 
  57                 'vbr': int(n
.find('./videobitrate').text
), 
  58                 'vcodec': n
.find('./codec').text
, 
  62             # Blacklist type 6, it's extremely LQ and not available on the same server 
  63             if n
.tag
.startswith('type') and n
.tag 
!= 'type6' 
  65         duration 
= float(idoc
[0].findall('./duration')[0].text
) 
  67         self
._sort
_formats
(formats
) 
  72             'description': description
, 
  78 class SpiegelArticleIE(InfoExtractor
): 
  79     _VALID_URL 
= 'https?://www\.spiegel\.de/(?!video/)[^?#]*?-(?P<id>[0-9]+)\.html' 
  80     IE_NAME 
= 'Spiegel:Article' 
  81     IE_DESC 
= 'Articles on spiegel.de' 
  83         'url': 'http://www.spiegel.de/sport/sonst/badminton-wm-die-randsportart-soll-populaerer-werden-a-987092.html', 
  87             'title': 'Faszination Badminton: Nennt es bloß nicht Federball', 
  88             'description': 're:^Patrick Kämnitz gehört.{100,}', 
  92     def _real_extract(self
, url
): 
  93         m 
= re
.match(self
._VALID
_URL
, url
) 
  94         video_id 
= m
.group('id') 
  96         webpage 
= self
._download
_webpage
(url
, video_id
) 
  97         video_link 
= self
._search
_regex
( 
  98             r
'<a href="([^"]+)" onclick="return spOpenVideo\(this,', webpage
, 
 100         video_url 
= compat_urlparse
.urljoin( 
 101             self
.http_scheme() + '//spiegel.de/', video_link
)