logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

washingtonpost.py (5257B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class WashingtonPostIE(InfoExtractor):
  6. IE_NAME = 'washingtonpost'
  7. _VALID_URL = r'(?:washingtonpost:|https?://(?:www\.)?washingtonpost\.com/(?:video|posttv)/(?:[^/]+/)*)(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
  8. _EMBED_URL = r'https?://(?:www\.)?washingtonpost\.com/video/c/embed/[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}'
  9. _TESTS = [{
  10. 'url': 'https://www.washingtonpost.com/video/c/video/480ba4ee-1ec7-11e6-82c2-a7dcb313287d',
  11. 'md5': '6f537e1334b714eb15f9563bd4b9cdfa',
  12. 'info_dict': {
  13. 'id': '480ba4ee-1ec7-11e6-82c2-a7dcb313287d',
  14. 'ext': 'mp4',
  15. 'title': 'Egypt finds belongings, debris from plane crash',
  16. 'description': 'md5:a17ceee432f215a5371388c1f680bd86',
  17. 'upload_date': '20160520',
  18. 'timestamp': 1463775187,
  19. },
  20. }, {
  21. 'url': 'https://www.washingtonpost.com/video/world/egypt-finds-belongings-debris-from-plane-crash/2016/05/20/480ba4ee-1ec7-11e6-82c2-a7dcb313287d_video.html',
  22. 'only_matching': True,
  23. }, {
  24. 'url': 'https://www.washingtonpost.com/posttv/world/iraq-to-track-down-antiquities-after-islamic-state-museum-rampage/2015/02/28/7c57e916-bf86-11e4-9dfb-03366e719af8_video.html',
  25. 'only_matching': True,
  26. }]
  27. @classmethod
  28. def _extract_urls(cls, webpage):
  29. return re.findall(
  30. r'<iframe[^>]+\bsrc=["\'](%s)' % cls._EMBED_URL, webpage)
  31. def _real_extract(self, url):
  32. video_id = self._match_id(url)
  33. return self.url_result(
  34. 'arcpublishing:wapo:' + video_id, 'ArcPublishing', video_id)
  35. class WashingtonPostArticleIE(InfoExtractor):
  36. IE_NAME = 'washingtonpost:article'
  37. _VALID_URL = r'https?://(?:www\.)?washingtonpost\.com/(?:[^/]+/)*(?P<id>[^/?#]+)'
  38. _TESTS = [{
  39. 'url': 'http://www.washingtonpost.com/sf/national/2014/03/22/sinkhole-of-bureaucracy/',
  40. 'info_dict': {
  41. 'id': 'sinkhole-of-bureaucracy',
  42. 'title': 'Sinkhole of bureaucracy',
  43. },
  44. 'playlist': [{
  45. 'md5': 'b9be794ceb56c7267d410a13f99d801a',
  46. 'info_dict': {
  47. 'id': 'fc433c38-b146-11e3-b8b3-44b1d1cd4c1f',
  48. 'ext': 'mp4',
  49. 'title': 'Breaking Points: The Paper Mine',
  50. 'duration': 1290,
  51. 'description': 'Overly complicated paper pushing is nothing new to government bureaucracy. But the way federal retirement applications are filed may be the most outdated. David Fahrenthold explains.',
  52. 'timestamp': 1395440416,
  53. 'upload_date': '20140321',
  54. },
  55. }, {
  56. 'md5': '1fff6a689d8770966df78c8cb6c8c17c',
  57. 'info_dict': {
  58. 'id': '41255e28-b14a-11e3-b8b3-44b1d1cd4c1f',
  59. 'ext': 'mp4',
  60. 'title': 'The town bureaucracy sustains',
  61. 'description': 'Underneath the friendly town of Boyers is a sea of government paperwork. In a disused limestone mine, hundreds of locals now track, file and process retirement applications for the federal government. We set out to find out what it\'s like to do paperwork 230 feet underground.',
  62. 'duration': 2220,
  63. 'timestamp': 1395441819,
  64. 'upload_date': '20140321',
  65. },
  66. }],
  67. }, {
  68. 'url': 'http://www.washingtonpost.com/blogs/wonkblog/wp/2014/12/31/one-airline-figured-out-how-to-make-sure-its-airplanes-never-disappear/',
  69. 'info_dict': {
  70. 'id': 'one-airline-figured-out-how-to-make-sure-its-airplanes-never-disappear',
  71. 'title': 'One airline figured out how to make sure its airplanes never disappear',
  72. },
  73. 'playlist': [{
  74. 'md5': 'a7c1b5634ba5e57a6a82cdffa5b1e0d0',
  75. 'info_dict': {
  76. 'id': '0e4bb54c-9065-11e4-a66f-0ca5037a597d',
  77. 'ext': 'mp4',
  78. 'description': 'Washington Post transportation reporter Ashley Halsey III explains why a plane\'s black box needs to be recovered from a crash site instead of having its information streamed in real time throughout the flight.',
  79. 'upload_date': '20141230',
  80. 'timestamp': 1419972442,
  81. 'title': 'Why black boxes don’t transmit data in real time',
  82. }
  83. }]
  84. }]
  85. @classmethod
  86. def suitable(cls, url):
  87. return False if WashingtonPostIE.suitable(url) else super(WashingtonPostArticleIE, cls).suitable(url)
  88. def _real_extract(self, url):
  89. page_id = self._match_id(url)
  90. webpage = self._download_webpage(url, page_id)
  91. title = self._og_search_title(webpage)
  92. uuids = re.findall(r'''(?x)
  93. (?:
  94. <div\s+class="posttv-video-embed[^>]*?data-uuid=|
  95. data-video-uuid=
  96. )"([^"]+)"''', webpage)
  97. entries = [self.url_result('washingtonpost:%s' % uuid, 'WashingtonPost', uuid) for uuid in uuids]
  98. return {
  99. '_type': 'playlist',
  100. 'entries': entries,
  101. 'id': page_id,
  102. 'title': title,
  103. }