[DHM] Add extractor description
[youtube-dl] / youtube_dl / extractor / dhm.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6 import urllib2
7 import xml.etree.ElementTree as ET
8 import re
9
10
11 class DHMIE(InfoExtractor):
12     IE_DESC = 'Deutsches Historisches Museum'
13     _VALID_URL = r'http://www\.dhm\.de/filmarchiv/(?P<id>.*?)'
14
15     _TEST = {
16         'url': 'http://www.dhm.de/filmarchiv/die-filme/the-marshallplan-at-work-in-west-germany/',
17         'md5': '11c475f670209bf6acca0b2b7ef51827',
18         'info_dict': {
19             'id': 'marshallwg',
20             'ext': 'flv',
21             'title': 'MARSHALL PLAN AT WORK IN WESTERN GERMANY, THE',
22             'thumbnail': 'http://www.dhm.de/filmarchiv/video/mpworkwg.jpg',
23         }
24     }
25
26     def _real_extract(self, url):
27         video_id = ''
28         webpage = self._download_webpage(url, video_id)
29
30         title = self._html_search_regex(
31             r'dc:title=\"(.*?)\"', webpage, 'title')
32
33         playlist_url = self._html_search_regex(
34             r'file: \'(.*?)\'', webpage, 'playlist URL')
35
36         xml_file = urllib2.urlopen(playlist_url)
37         data = xml_file.read()
38         xml_file.close()
39
40         root = ET.fromstring(data)
41         video_url = root[0][0][0].text
42         thumbnail = root[0][0][2].text
43
44         m = re.search('video/(.+?).flv', video_url)
45         if m:
46             video_id = m.group(1)
47
48         return {
49             'id': video_id,
50             'title': title,
51             'url': video_url,
52             'thumbnail': thumbnail,
53         }