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.

80 lines
2.8 KiB

9 years ago
9 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. smuggle_url,
  6. update_url_query,
  7. unescapeHTML,
  8. )
  9. class AENetworksIE(InfoExtractor):
  10. IE_NAME = 'aenetworks'
  11. IE_DESC = 'A+E Networks: A&E, Lifetime, History.com, FYI Network'
  12. _VALID_URL = r'https?://(?:www\.)?(?:(?:history|aetv|mylifetime)\.com|fyi\.tv)/(?P<type>[^/]+)/(?:[^/]+/)+(?P<id>[^/]+?)(?:$|[?#])'
  13. _TESTS = [{
  14. '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',
  15. 'info_dict': {
  16. 'id': 'g12m5Gyt3fdR',
  17. 'ext': 'mp4',
  18. 'title': "Bet You Didn't Know: Valentine's Day",
  19. 'description': 'md5:7b57ea4829b391995b405fa60bd7b5f7',
  20. },
  21. 'params': {
  22. # m3u8 download
  23. 'skip_download': True,
  24. },
  25. 'add_ie': ['ThePlatform'],
  26. 'expected_warnings': ['JSON-LD'],
  27. }, {
  28. 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
  29. 'md5': '8ff93eb073449f151d6b90c0ae1ef0c7',
  30. 'info_dict': {
  31. 'id': 'eg47EERs_JsZ',
  32. 'ext': 'mp4',
  33. 'title': 'Winter Is Coming',
  34. 'description': 'md5:641f424b7a19d8e24f26dea22cf59d74',
  35. },
  36. 'add_ie': ['ThePlatform'],
  37. }, {
  38. 'url': 'http://www.aetv.com/shows/duck-dynasty/video/inlawful-entry',
  39. 'only_matching': True
  40. }, {
  41. 'url': 'http://www.fyi.tv/shows/tiny-house-nation/videos/207-sq-ft-minnesota-prairie-cottage',
  42. 'only_matching': True
  43. }, {
  44. 'url': 'http://www.mylifetime.com/shows/project-runway-junior/video/season-1/episode-6/superstar-clients',
  45. 'only_matching': True
  46. }]
  47. def _real_extract(self, url):
  48. page_type, video_id = re.match(self._VALID_URL, url).groups()
  49. webpage = self._download_webpage(url, video_id)
  50. video_url_re = [
  51. r'data-href="[^"]*/%s"[^>]+data-release-url="([^"]+)"' % video_id,
  52. r"media_url\s*=\s*'([^']+)'"
  53. ]
  54. video_url = unescapeHTML(self._search_regex(video_url_re, webpage, 'video url'))
  55. query = {'mbr': 'true'}
  56. if page_type == 'shows':
  57. query['assetTypes'] = 'medium_video_s3'
  58. if 'switch=hds' in video_url:
  59. query['switch'] = 'hls'
  60. info = self._search_json_ld(webpage, video_id, fatal=False)
  61. info.update({
  62. '_type': 'url_transparent',
  63. 'url': smuggle_url(update_url_query(
  64. video_url, query), {
  65. 'sig': {
  66. 'key': 'crazyjava',
  67. 'secret': 's3cr3t'},
  68. 'force_smil_url': True
  69. }),
  70. })
  71. return info