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.

31 lines
1.1 KiB

  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. 'md5': '6fe632d033c92aa10b8d4a9be047a7c5',
  9. 'info_dict': {
  10. 'id': 'bLx5Dv5Aka1G',
  11. 'ext': 'mp4',
  12. 'title': "Bet You Didn't Know: Valentine's Day",
  13. 'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7',
  14. },
  15. 'add_ie': ['ThePlatform'],
  16. }]
  17. def _real_extract(self, url):
  18. video_id = self._match_id(url)
  19. webpage = self._download_webpage(url, video_id)
  20. video_url = self._search_regex(
  21. r'data-href="[^"]*/%s"[^>]+data-release-url="([^"]+)"' % video_id,
  22. webpage, 'video url')
  23. return self.url_result(smuggle_url(video_url, {'sig': {'key': 'crazyjava', 'secret': 's3cr3t'}}))