You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.4 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. xpath_text,
  5. parse_duration,
  6. )
  7. class DHMIE(InfoExtractor):
  8. IE_DESC = 'Filmarchiv - Deutsches Historisches Museum'
  9. _VALID_URL = r'https?://(?:www\.)?dhm\.de/filmarchiv/(?:[^/]+/)+(?P<id>[^/]+)'
  10. _TESTS = [{
  11. 'url': 'http://www.dhm.de/filmarchiv/die-filme/the-marshallplan-at-work-in-west-germany/',
  12. 'md5': '11c475f670209bf6acca0b2b7ef51827',
  13. 'info_dict': {
  14. 'id': 'the-marshallplan-at-work-in-west-germany',
  15. 'ext': 'flv',
  16. 'title': 'MARSHALL PLAN AT WORK IN WESTERN GERMANY, THE',
  17. 'description': 'md5:1fabd480c153f97b07add61c44407c82',
  18. 'duration': 660,
  19. 'thumbnail': 're:^https?://.*\.jpg$',
  20. },
  21. }, {
  22. 'url': 'http://www.dhm.de/filmarchiv/02-mapping-the-wall/peter-g/rolle-1/',
  23. 'md5': '09890226332476a3e3f6f2cb74734aa5',
  24. 'info_dict': {
  25. 'id': 'rolle-1',
  26. 'ext': 'flv',
  27. 'title': 'ROLLE 1',
  28. 'thumbnail': 're:^https?://.*\.jpg$',
  29. },
  30. }]
  31. def _real_extract(self, url):
  32. video_id = self._match_id(url)
  33. webpage = self._download_webpage(url, video_id)
  34. playlist_url = self._search_regex(
  35. r"file\s*:\s*'([^']+)'", webpage, 'playlist url')
  36. playlist = self._download_xml(playlist_url, video_id)
  37. track = playlist.find(
  38. './{http://xspf.org/ns/0/}trackList/{http://xspf.org/ns/0/}track')
  39. video_url = xpath_text(
  40. track, './{http://xspf.org/ns/0/}location',
  41. 'video url', fatal=True)
  42. thumbnail = xpath_text(
  43. track, './{http://xspf.org/ns/0/}image',
  44. 'thumbnail')
  45. title = self._search_regex(
  46. [r'dc:title="([^"]+)"', r'<title> &raquo;([^<]+)</title>'],
  47. webpage, 'title').strip()
  48. description = self._html_search_regex(
  49. r'<p><strong>Description:</strong>(.+?)</p>',
  50. webpage, 'description', default=None)
  51. duration = parse_duration(self._search_regex(
  52. r'<em>Length\s*</em>\s*:\s*</strong>([^<]+)',
  53. webpage, 'duration', default=None))
  54. return {
  55. 'id': video_id,
  56. 'url': video_url,
  57. 'title': title,
  58. 'description': description,
  59. 'duration': duration,
  60. 'thumbnail': thumbnail,
  61. }