dhm.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. playlist_id = self._match_id(url)
  33. webpage = self._download_webpage(url, playlist_id)
  34. playlist_url = self._search_regex(
  35. r"file\s*:\s*'([^']+)'", webpage, 'playlist url')
  36. entries = self._extract_xspf_playlist(playlist_url, playlist_id)
  37. title = self._search_regex(
  38. [r'dc:title="([^"]+)"', r'<title> &raquo;([^<]+)</title>'],
  39. webpage, 'title').strip()
  40. description = self._html_search_regex(
  41. r'<p><strong>Description:</strong>(.+?)</p>',
  42. webpage, 'description', default=None)
  43. duration = parse_duration(self._search_regex(
  44. r'<em>Length\s*</em>\s*:\s*</strong>([^<]+)',
  45. webpage, 'duration', default=None))
  46. entries[0].update({
  47. 'title': title,
  48. 'description': description,
  49. 'duration': duration,
  50. })
  51. return self.playlist_result(entries, playlist_id)