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.

87 lines
3.0 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. 'timestamp': 1375819729,
  21. 'upload_date': '20130806',
  22. 'uploader': 'AENE-NEW',
  23. },
  24. 'params': {
  25. # m3u8 download
  26. 'skip_download': True,
  27. },
  28. 'add_ie': ['ThePlatform'],
  29. 'expected_warnings': ['JSON-LD'],
  30. }, {
  31. 'url': 'http://www.history.com/shows/mountain-men/season-1/episode-1',
  32. 'md5': '8ff93eb073449f151d6b90c0ae1ef0c7',
  33. 'info_dict': {
  34. 'id': 'eg47EERs_JsZ',
  35. 'ext': 'mp4',
  36. 'title': 'Winter Is Coming',
  37. 'description': 'md5:641f424b7a19d8e24f26dea22cf59d74',
  38. 'timestamp': 1338306241,
  39. 'upload_date': '20120529',
  40. 'uploader': 'AENE-NEW',
  41. },
  42. 'add_ie': ['ThePlatform'],
  43. }, {
  44. 'url': 'http://www.aetv.com/shows/duck-dynasty/video/inlawful-entry',
  45. 'only_matching': True
  46. }, {
  47. 'url': 'http://www.fyi.tv/shows/tiny-house-nation/videos/207-sq-ft-minnesota-prairie-cottage',
  48. 'only_matching': True
  49. }, {
  50. 'url': 'http://www.mylifetime.com/shows/project-runway-junior/video/season-1/episode-6/superstar-clients',
  51. 'only_matching': True
  52. }]
  53. def _real_extract(self, url):
  54. page_type, video_id = re.match(self._VALID_URL, url).groups()
  55. webpage = self._download_webpage(url, video_id)
  56. video_url_re = [
  57. r'data-href="[^"]*/%s"[^>]+data-release-url="([^"]+)"' % video_id,
  58. r"media_url\s*=\s*'([^']+)'"
  59. ]
  60. video_url = unescapeHTML(self._search_regex(video_url_re, webpage, 'video url'))
  61. query = {'mbr': 'true'}
  62. if page_type == 'shows':
  63. query['assetTypes'] = 'medium_video_s3'
  64. if 'switch=hds' in video_url:
  65. query['switch'] = 'hls'
  66. info = self._search_json_ld(webpage, video_id, fatal=False)
  67. info.update({
  68. '_type': 'url_transparent',
  69. 'url': smuggle_url(
  70. update_url_query(video_url, query),
  71. {
  72. 'sig': {
  73. 'key': 'crazyjava',
  74. 'secret': 's3cr3t'},
  75. 'force_smil_url': True
  76. }),
  77. })
  78. return info