dhm.py 2.0 KB

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