2 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class WashingtonPostIE(InfoExtractor):
14 IE_NAME = 'washingtonpost'
15 _VALID_URL = r'(?:washingtonpost:|https?://(?:www\.)?washingtonpost\.com/video/(?:[^/]+/)*)(?P<id>[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12})'
17 'url': 'https://www.washingtonpost.com/video/c/video/480ba4ee-1ec7-11e6-82c2-a7dcb313287d',
18 'md5': '6f537e1334b714eb15f9563bd4b9cdfa',
20 'id': '480ba4ee-1ec7-11e6-82c2-a7dcb313287d',
22 'title': 'Egypt finds belongings, debris from plane crash',
23 'description': 'md5:a17ceee432f215a5371388c1f680bd86',
24 'upload_date': '20160520',
25 'uploader': 'Reuters',
26 'timestamp': 1463778452,
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32 video_data = self._download_json(
33 'http://www.washingtonpost.com/posttv/c/videojson/%s?resType=jsonp' % video_id,
34 video_id, transform_source=strip_jsonp)[0]['contentConfig']
35 title = video_data['title']
39 for s in video_data.get('streams', []):
41 if not s_url or s_url in urls:
44 video_type = s.get('type')
45 if video_type == 'smil':
47 elif video_type in ('ts', 'hls'):
48 m3u8_formats = self._extract_m3u8_formats(
49 s_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False)
50 for m3u8_format in m3u8_formats:
51 width = m3u8_format.get('width')
54 vbr = self._search_regex(
55 r'%d_%d_(\d+)' % (width, m3u8_format['height']), m3u8_format['url'], 'vbr', default=None)
58 'vbr': int_or_none(vbr),
60 formats.extend(m3u8_formats)
62 width = int_or_none(s.get('width'))
63 vbr = int_or_none(s.get('bitrate'))
64 has_width = width != 0
67 '%s-%d-%d' % (video_type, width, vbr)
70 'vbr': vbr if has_width else None,
72 'height': int_or_none(s.get('height')),
73 'acodec': s.get('audioCodec'),
74 'vcodec': s.get('videoCodec') if has_width else 'none',
75 'filesize': int_or_none(s.get('fileSize')),
84 source_media_url = video_data.get('sourceMediaURL')
87 'format_id': 'source_media',
88 'url': source_media_url,
91 formats, ('width', 'height', 'vbr', 'filesize', 'tbr', 'format_id'))
96 'description': video_data.get('blurb'),
97 'uploader': video_data.get('credits', {}).get('source'),
99 'duration': int_or_none(video_data.get('videoDuration'), 100),
100 'timestamp': int_or_none(
101 video_data.get('dateConfig', {}).get('dateFirstPublished'), 1000),
105 class WashingtonPostArticleIE(InfoExtractor):
106 IE_NAME = 'washingtonpost:article'
107 _VALID_URL = r'https?://(?:www\.)?washingtonpost\.com/(?:[^/]+/)*(?P<id>[^/?#]+)'
109 'url': 'http://www.washingtonpost.com/sf/national/2014/03/22/sinkhole-of-bureaucracy/',
111 'id': 'sinkhole-of-bureaucracy',
112 'title': 'Sinkhole of bureaucracy',
115 'md5': 'b9be794ceb56c7267d410a13f99d801a',
117 'id': 'fc433c38-b146-11e3-b8b3-44b1d1cd4c1f',
119 'title': 'Breaking Points: The Paper Mine',
121 '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.',
122 'uploader': 'The Washington Post',
123 'timestamp': 1395527908,
124 'upload_date': '20140322',
127 'md5': '1fff6a689d8770966df78c8cb6c8c17c',
129 'id': '41255e28-b14a-11e3-b8b3-44b1d1cd4c1f',
131 'title': 'The town bureaucracy sustains',
132 '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.',
134 'timestamp': 1395528005,
135 'upload_date': '20140322',
136 'uploader': 'The Washington Post',
140 'url': 'http://www.washingtonpost.com/blogs/wonkblog/wp/2014/12/31/one-airline-figured-out-how-to-make-sure-its-airplanes-never-disappear/',
142 'id': 'one-airline-figured-out-how-to-make-sure-its-airplanes-never-disappear',
143 'title': 'One airline figured out how to make sure its airplanes never disappear',
146 'md5': 'a7c1b5634ba5e57a6a82cdffa5b1e0d0',
148 'id': '0e4bb54c-9065-11e4-a66f-0ca5037a597d',
150 '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.',
151 'upload_date': '20141230',
152 'uploader': 'The Washington Post',
153 'timestamp': 1419974765,
154 'title': 'Why black boxes don’t transmit data in real time',
160 def suitable(cls, url):
161 return False if WashingtonPostIE.suitable(url) else super(WashingtonPostArticleIE, cls).suitable(url)
163 def _real_extract(self, url):
164 page_id = self._match_id(url)
165 webpage = self._download_webpage(url, page_id)
167 title = self._og_search_title(webpage)
169 uuids = re.findall(r'''(?x)
171 <div\s+class="posttv-video-embed[^>]*?data-uuid=|
173 )"([^"]+)"''', webpage)
174 entries = [self.url_result('washingtonpost:%s' % uuid, 'WashingtonPost', uuid) for uuid in uuids]