]>
Commit | Line | Data |
---|---|---|
01c46659 | 1 | # coding: utf-8 |
fac55558 PH |
2 | from __future__ import unicode_literals |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
fac55558 PH |
7 | |
8 | ||
9 | class WashingtonPostIE(InfoExtractor): | |
4b464a6a | 10 | IE_NAME = 'washingtonpost' |
29f7c58a | 11 | _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})' |
ba5c3caf | 12 | _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}' |
29f7c58a | 13 | _TESTS = [{ |
4b464a6a | 14 | 'url': 'https://www.washingtonpost.com/video/c/video/480ba4ee-1ec7-11e6-82c2-a7dcb313287d', |
15 | 'md5': '6f537e1334b714eb15f9563bd4b9cdfa', | |
16 | 'info_dict': { | |
17 | 'id': '480ba4ee-1ec7-11e6-82c2-a7dcb313287d', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Egypt finds belongings, debris from plane crash', | |
20 | 'description': 'md5:a17ceee432f215a5371388c1f680bd86', | |
21 | 'upload_date': '20160520', | |
29f7c58a | 22 | 'timestamp': 1463775187, |
4b464a6a | 23 | }, |
29f7c58a | 24 | }, { |
25 | 'url': 'https://www.washingtonpost.com/video/world/egypt-finds-belongings-debris-from-plane-crash/2016/05/20/480ba4ee-1ec7-11e6-82c2-a7dcb313287d_video.html', | |
26 | 'only_matching': True, | |
27 | }, { | |
28 | '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', | |
29 | 'only_matching': True, | |
30 | }] | |
4b464a6a | 31 | |
55719459 JH |
32 | @classmethod |
33 | def _extract_urls(cls, webpage): | |
34 | return re.findall( | |
35 | r'<iframe[^>]+\bsrc=["\'](%s)' % cls._EMBED_URL, webpage) | |
36 | ||
4b464a6a | 37 | def _real_extract(self, url): |
38 | video_id = self._match_id(url) | |
29f7c58a | 39 | return self.url_result( |
40 | 'arcpublishing:wapo:' + video_id, 'ArcPublishing', video_id) | |
4b464a6a | 41 | |
42 | ||
43 | class WashingtonPostArticleIE(InfoExtractor): | |
44 | IE_NAME = 'washingtonpost:article' | |
45 | _VALID_URL = r'https?://(?:www\.)?washingtonpost\.com/(?:[^/]+/)*(?P<id>[^/?#]+)' | |
01c46659 | 46 | _TESTS = [{ |
fac55558 | 47 | 'url': 'http://www.washingtonpost.com/sf/national/2014/03/22/sinkhole-of-bureaucracy/', |
8029857d | 48 | 'info_dict': { |
01c46659 | 49 | 'id': 'sinkhole-of-bureaucracy', |
8029857d S |
50 | 'title': 'Sinkhole of bureaucracy', |
51 | }, | |
fac55558 | 52 | 'playlist': [{ |
10723362 | 53 | 'md5': 'b9be794ceb56c7267d410a13f99d801a', |
fac55558 PH |
54 | 'info_dict': { |
55 | 'id': 'fc433c38-b146-11e3-b8b3-44b1d1cd4c1f', | |
56 | 'ext': 'mp4', | |
57 | 'title': 'Breaking Points: The Paper Mine', | |
10723362 | 58 | 'duration': 1290, |
fac55558 | 59 | '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.', |
29f7c58a | 60 | 'timestamp': 1395440416, |
61 | 'upload_date': '20140321', | |
fac55558 PH |
62 | }, |
63 | }, { | |
10723362 | 64 | 'md5': '1fff6a689d8770966df78c8cb6c8c17c', |
fac55558 PH |
65 | 'info_dict': { |
66 | 'id': '41255e28-b14a-11e3-b8b3-44b1d1cd4c1f', | |
67 | 'ext': 'mp4', | |
68 | 'title': 'The town bureaucracy sustains', | |
69 | '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.', | |
10723362 | 70 | 'duration': 2220, |
29f7c58a | 71 | 'timestamp': 1395441819, |
72 | 'upload_date': '20140321', | |
fac55558 | 73 | }, |
01c46659 PH |
74 | }], |
75 | }, { | |
76 | 'url': 'http://www.washingtonpost.com/blogs/wonkblog/wp/2014/12/31/one-airline-figured-out-how-to-make-sure-its-airplanes-never-disappear/', | |
77 | 'info_dict': { | |
78 | 'id': 'one-airline-figured-out-how-to-make-sure-its-airplanes-never-disappear', | |
79 | 'title': 'One airline figured out how to make sure its airplanes never disappear', | |
80 | }, | |
81 | 'playlist': [{ | |
82 | 'md5': 'a7c1b5634ba5e57a6a82cdffa5b1e0d0', | |
83 | 'info_dict': { | |
84 | 'id': '0e4bb54c-9065-11e4-a66f-0ca5037a597d', | |
85 | 'ext': 'mp4', | |
86 | '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.', | |
87 | 'upload_date': '20141230', | |
29f7c58a | 88 | 'timestamp': 1419972442, |
01c46659 PH |
89 | 'title': 'Why black boxes don’t transmit data in real time', |
90 | } | |
fac55558 | 91 | }] |
01c46659 | 92 | }] |
fac55558 | 93 | |
4b464a6a | 94 | @classmethod |
95 | def suitable(cls, url): | |
96 | return False if WashingtonPostIE.suitable(url) else super(WashingtonPostArticleIE, cls).suitable(url) | |
97 | ||
fac55558 | 98 | def _real_extract(self, url): |
99673f04 | 99 | page_id = self._match_id(url) |
fac55558 | 100 | webpage = self._download_webpage(url, page_id) |
99673f04 | 101 | |
fac55558 | 102 | title = self._og_search_title(webpage) |
01c46659 PH |
103 | |
104 | uuids = re.findall(r'''(?x) | |
105 | (?: | |
106 | <div\s+class="posttv-video-embed[^>]*?data-uuid=| | |
107 | data-video-uuid= | |
108 | )"([^"]+)"''', webpage) | |
4b464a6a | 109 | entries = [self.url_result('washingtonpost:%s' % uuid, 'WashingtonPost', uuid) for uuid in uuids] |
fac55558 PH |
110 | |
111 | return { | |
112 | '_type': 'playlist', | |
113 | 'entries': entries, | |
114 | 'id': page_id, | |
115 | 'title': title, | |
116 | } |