]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/dhm.py
Completely change project name to yt-dlp (#85)
[yt-dlp.git] / yt_dlp / extractor / dhm.py
CommitLineData
643fe727
OJ
1from __future__ import unicode_literals
2
3from .common import InfoExtractor
237c03c8 4from ..utils import parse_duration
643fe727
OJ
5
6
7class DHMIE(InfoExtractor):
af8c9308 8 IE_DESC = 'Filmarchiv - Deutsches Historisches Museum'
5a3b315b 9 _VALID_URL = r'https?://(?:www\.)?dhm\.de/filmarchiv/(?:[^/]+/)+(?P<id>[^/]+)'
643fe727 10
5a3b315b 11 _TESTS = [{
643fe727
OJ
12 'url': 'http://www.dhm.de/filmarchiv/die-filme/the-marshallplan-at-work-in-west-germany/',
13 'md5': '11c475f670209bf6acca0b2b7ef51827',
14 'info_dict': {
af8c9308 15 'id': 'the-marshallplan-at-work-in-west-germany',
643fe727
OJ
16 'ext': 'flv',
17 'title': 'MARSHALL PLAN AT WORK IN WESTERN GERMANY, THE',
af8c9308
S
18 'description': 'md5:1fabd480c153f97b07add61c44407c82',
19 'duration': 660,
ec85ded8 20 'thumbnail': r're:^https?://.*\.jpg$',
5a3b315b
S
21 },
22 }, {
23 'url': 'http://www.dhm.de/filmarchiv/02-mapping-the-wall/peter-g/rolle-1/',
24 'md5': '09890226332476a3e3f6f2cb74734aa5',
25 'info_dict': {
26 'id': 'rolle-1',
27 'ext': 'flv',
28 'title': 'ROLLE 1',
ec85ded8 29 'thumbnail': r're:^https?://.*\.jpg$',
5a3b315b
S
30 },
31 }]
643fe727
OJ
32
33 def _real_extract(self, url):
fb2f339f 34 playlist_id = self._match_id(url)
af8c9308 35
fb2f339f 36 webpage = self._download_webpage(url, playlist_id)
643fe727 37
af8c9308
S
38 playlist_url = self._search_regex(
39 r"file\s*:\s*'([^']+)'", webpage, 'playlist url')
643fe727 40
fb2f339f 41 entries = self._extract_xspf_playlist(playlist_url, playlist_id)
643fe727 42
af8c9308
S
43 title = self._search_regex(
44 [r'dc:title="([^"]+)"', r'<title> &raquo;([^<]+)</title>'],
45 webpage, 'title').strip()
46 description = self._html_search_regex(
47 r'<p><strong>Description:</strong>(.+?)</p>',
5a3b315b 48 webpage, 'description', default=None)
af8c9308
S
49 duration = parse_duration(self._search_regex(
50 r'<em>Length\s*</em>\s*:\s*</strong>([^<]+)',
5a3b315b 51 webpage, 'duration', default=None))
643fe727 52
fb2f339f 53 entries[0].update({
af8c9308
S
54 'title': title,
55 'description': description,
56 'duration': duration,
fb2f339f
S
57 })
58
59 return self.playlist_result(entries, playlist_id)