]>
Commit | Line | Data |
---|---|---|
1139a54d S |
1 | from __future__ import unicode_literals |
2 | ||
d7e82645 | 3 | import re |
4 | ||
3793090b | 5 | from .amp import AMPIE |
cdc78351 | 6 | from .common import InfoExtractor |
1139a54d S |
7 | |
8 | ||
fea74aca YCH |
9 | class FoxNewsIE(AMPIE): |
10 | IE_NAME = 'foxnews' | |
5307c332 | 11 | IE_DESC = 'Fox News and Fox Business Video' |
cdc78351 | 12 | _VALID_URL = r'https?://(?P<host>video\.(?:insider\.)?fox(?:news|business)\.com)/v/(?:video-embed\.html\?video_id=)?(?P<id>\d+)' |
1139a54d S |
13 | _TESTS = [ |
14 | { | |
15 | 'url': 'http://video.foxnews.com/v/3937480/frozen-in-time/#sp=show-clips', | |
16 | 'md5': '32aaded6ba3ef0d1c04e238d01031e5e', | |
17 | 'info_dict': { | |
18 | 'id': '3937480', | |
19 | 'ext': 'flv', | |
20 | 'title': 'Frozen in Time', | |
3793090b | 21 | 'description': '16-year-old girl is size of toddler', |
1139a54d | 22 | 'duration': 265, |
c8b13fec S |
23 | 'timestamp': 1304411491, |
24 | 'upload_date': '20110503', | |
ec85ded8 | 25 | 'thumbnail': r're:^https?://.*\.jpg$', |
1139a54d S |
26 | }, |
27 | }, | |
28 | { | |
29 | 'url': 'http://video.foxnews.com/v/3922535568001/rep-luis-gutierrez-on-if-obamas-immigration-plan-is-legal/#sp=show-clips', | |
30 | 'md5': '5846c64a1ea05ec78175421b8323e2df', | |
31 | 'info_dict': { | |
32 | 'id': '3922535568001', | |
33 | 'ext': 'mp4', | |
34 | 'title': "Rep. Luis Gutierrez on if Obama's immigration plan is legal", | |
3793090b | 35 | 'description': "Congressman discusses president's plan", |
1139a54d | 36 | 'duration': 292, |
c8b13fec S |
37 | 'timestamp': 1417662047, |
38 | 'upload_date': '20141204', | |
ec85ded8 | 39 | 'thumbnail': r're:^https?://.*\.jpg$', |
1139a54d | 40 | }, |
cf074e5d | 41 | 'params': { |
42 | # m3u8 download | |
43 | 'skip_download': True, | |
44 | }, | |
1139a54d S |
45 | }, |
46 | { | |
47 | 'url': 'http://video.foxnews.com/v/video-embed.html?video_id=3937480&d=video.foxnews.com', | |
48 | 'only_matching': True, | |
49 | }, | |
8df8c278 | 50 | { |
51 | 'url': 'http://video.foxbusiness.com/v/4442309889001', | |
52 | 'only_matching': True, | |
53 | }, | |
cdc78351 YCH |
54 | { |
55 | # From http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words | |
56 | 'url': 'http://video.insider.foxnews.com/v/video-embed.html?video_id=5099377331001&autoplay=true&share_url=http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words&share_title=Student%20Group:%20Saying%20%27Politically%20Correct,%27%20%27Trash%27%20and%20%27Lame%27%20Is%20Offensive&share=true', | |
57 | 'only_matching': True, | |
58 | }, | |
1139a54d S |
59 | ] |
60 | ||
61 | def _real_extract(self, url): | |
c7fa5fa4 | 62 | host, video_id = re.match(self._VALID_URL, url).groups() |
d7e82645 | 63 | |
c7fa5fa4 | 64 | info = self._extract_feed_info( |
65 | 'http://%s/v/feed/video/%s.js?template=fox' % (host, video_id)) | |
3793090b | 66 | info['id'] = video_id |
67 | return info | |
cdc78351 YCH |
68 | |
69 | ||
fea74aca | 70 | class FoxNewsArticleIE(InfoExtractor): |
2cdbc06a | 71 | _VALID_URL = r'https?://(?:www\.)?foxnews\.com/(?!v)([^/]+/)+(?P<id>[a-z-]+)' |
fea74aca | 72 | IE_NAME = 'foxnews:article' |
2cdbc06a YCH |
73 | |
74 | _TEST = { | |
75 | 'url': 'http://www.foxnews.com/politics/2016/09/08/buzz-about-bud-clinton-camp-denies-claims-wore-earpiece-at-forum.html', | |
76 | 'md5': '62aa5a781b308fdee212ebb6f33ae7ef', | |
77 | 'info_dict': { | |
78 | 'id': '5116295019001', | |
79 | 'ext': 'mp4', | |
80 | 'title': 'Trump and Clinton asked to defend positions on Iraq War', | |
81 | 'description': 'Veterans react on \'The Kelly File\'', | |
82 | 'timestamp': 1473299755, | |
83 | 'upload_date': '20160908', | |
84 | }, | |
85 | } | |
86 | ||
87 | def _real_extract(self, url): | |
88 | display_id = self._match_id(url) | |
89 | webpage = self._download_webpage(url, display_id) | |
90 | ||
91 | video_id = self._html_search_regex( | |
92 | r'data-video-id=([\'"])(?P<id>[^\'"]+)\1', | |
93 | webpage, 'video ID', group='id') | |
94 | return self.url_result( | |
95 | 'http://video.foxnews.com/v/' + video_id, | |
fea74aca | 96 | FoxNewsIE.ie_key()) |
2cdbc06a YCH |
97 | |
98 | ||
cdc78351 YCH |
99 | class FoxNewsInsiderIE(InfoExtractor): |
100 | _VALID_URL = r'https?://insider\.foxnews\.com/([^/]+/)+(?P<id>[a-z-]+)' | |
101 | IE_NAME = 'foxnews:insider' | |
102 | ||
103 | _TEST = { | |
104 | 'url': 'http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words', | |
105 | 'md5': 'a10c755e582d28120c62749b4feb4c0c', | |
106 | 'info_dict': { | |
107 | 'id': '5099377331001', | |
108 | 'display_id': 'univ-wisconsin-student-group-pushing-silence-certain-words', | |
109 | 'ext': 'mp4', | |
110 | 'title': 'Student Group: Saying \'Politically Correct,\' \'Trash\' and \'Lame\' Is Offensive', | |
111 | 'description': 'Is campus censorship getting out of control?', | |
112 | 'timestamp': 1472168725, | |
113 | 'upload_date': '20160825', | |
ec85ded8 | 114 | 'thumbnail': r're:^https?://.*\.jpg$', |
cdc78351 | 115 | }, |
2cdbc06a YCH |
116 | 'params': { |
117 | # m3u8 download | |
118 | 'skip_download': True, | |
119 | }, | |
fea74aca | 120 | 'add_ie': [FoxNewsIE.ie_key()], |
cdc78351 YCH |
121 | } |
122 | ||
123 | def _real_extract(self, url): | |
124 | display_id = self._match_id(url) | |
125 | ||
126 | webpage = self._download_webpage(url, display_id) | |
127 | ||
128 | embed_url = self._html_search_meta('embedUrl', webpage, 'embed URL') | |
129 | ||
130 | title = self._og_search_title(webpage) | |
131 | description = self._og_search_description(webpage) | |
132 | ||
133 | return { | |
134 | '_type': 'url_transparent', | |
fea74aca | 135 | 'ie_key': FoxNewsIE.ie_key(), |
cdc78351 YCH |
136 | 'url': embed_url, |
137 | 'display_id': display_id, | |
138 | 'title': title, | |
139 | 'description': description, | |
140 | } |