history.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import smuggle_url
  4. class HistoryIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?history\.com/(?:[^/]+/)+(?P<id>[^/]+?)(?:$|[?#])'
  6. _TESTS = [{
  7. 'url': 'http://www.history.com/topics/valentines-day/history-of-valentines-day/videos/bet-you-didnt-know-valentines-day?m=528e394da93ae&s=undefined&f=1&free=false',
  8. 'info_dict': {
  9. 'id': 'g12m5Gyt3fdR',
  10. 'ext': 'mp4',
  11. 'title': "Bet You Didn't Know: Valentine's Day",
  12. 'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7',
  13. },
  14. 'params': {
  15. # m3u8 download
  16. 'skip_download': True,
  17. },
  18. 'add_ie': ['ThePlatform'],
  19. }, {
  20. 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
  21. 'info_dict': {
  22. 'id': 'eg47EERs_JsZ',
  23. 'ext': 'mp4',
  24. 'title': "Winter Is Coming",
  25. 'description': 'md5:a40e370925074260b1c8a633c632c63a',
  26. },
  27. 'params': {
  28. # m3u8 download
  29. 'skip_download': True,
  30. },
  31. 'add_ie': ['ThePlatform'],
  32. }]
  33. def _real_extract(self, url):
  34. video_id = self._match_id(url)
  35. webpage = self._download_webpage(url, video_id)
  36. video_url_re = [
  37. r'data-href="[^"]*/%s"[^>]+data-release-url="([^"]+)"' % video_id,
  38. r"media_url\s*=\s*'([^']+)'"
  39. ]
  40. video_url = self._search_regex(video_url_re, webpage, 'video url')
  41. return self.url_result(smuggle_url(video_url, {'sig': {'key': 'crazyjava', 'secret': 's3cr3t'}}))