]>
Commit | Line | Data |
---|---|---|
d7e82645 | 1 | import re |
2 | ||
3793090b | 3 | from .amp import AMPIE |
cdc78351 | 4 | from .common import InfoExtractor |
1139a54d S |
5 | |
6 | ||
fea74aca YCH |
7 | class FoxNewsIE(AMPIE): |
8 | IE_NAME = 'foxnews' | |
5307c332 | 9 | IE_DESC = 'Fox News and Fox Business Video' |
cdc78351 | 10 | _VALID_URL = r'https?://(?P<host>video\.(?:insider\.)?fox(?:news|business)\.com)/v/(?:video-embed\.html\?video_id=)?(?P<id>\d+)' |
1139a54d S |
11 | _TESTS = [ |
12 | { | |
13 | 'url': 'http://video.foxnews.com/v/3937480/frozen-in-time/#sp=show-clips', | |
14 | 'md5': '32aaded6ba3ef0d1c04e238d01031e5e', | |
15 | 'info_dict': { | |
16 | 'id': '3937480', | |
17 | 'ext': 'flv', | |
18 | 'title': 'Frozen in Time', | |
3793090b | 19 | 'description': '16-year-old girl is size of toddler', |
1139a54d | 20 | 'duration': 265, |
c8b13fec S |
21 | 'timestamp': 1304411491, |
22 | 'upload_date': '20110503', | |
ec85ded8 | 23 | 'thumbnail': r're:^https?://.*\.jpg$', |
1139a54d S |
24 | }, |
25 | }, | |
26 | { | |
27 | 'url': 'http://video.foxnews.com/v/3922535568001/rep-luis-gutierrez-on-if-obamas-immigration-plan-is-legal/#sp=show-clips', | |
28 | 'md5': '5846c64a1ea05ec78175421b8323e2df', | |
29 | 'info_dict': { | |
30 | 'id': '3922535568001', | |
31 | 'ext': 'mp4', | |
32 | 'title': "Rep. Luis Gutierrez on if Obama's immigration plan is legal", | |
3793090b | 33 | 'description': "Congressman discusses president's plan", |
1139a54d | 34 | 'duration': 292, |
c8b13fec S |
35 | 'timestamp': 1417662047, |
36 | 'upload_date': '20141204', | |
ec85ded8 | 37 | 'thumbnail': r're:^https?://.*\.jpg$', |
1139a54d | 38 | }, |
cf074e5d | 39 | 'params': { |
40 | # m3u8 download | |
41 | 'skip_download': True, | |
42 | }, | |
1139a54d S |
43 | }, |
44 | { | |
45 | 'url': 'http://video.foxnews.com/v/video-embed.html?video_id=3937480&d=video.foxnews.com', | |
46 | 'only_matching': True, | |
47 | }, | |
8df8c278 | 48 | { |
49 | 'url': 'http://video.foxbusiness.com/v/4442309889001', | |
50 | 'only_matching': True, | |
51 | }, | |
cdc78351 YCH |
52 | { |
53 | # From http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words | |
54 | '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', | |
55 | 'only_matching': True, | |
56 | }, | |
1139a54d S |
57 | ] |
58 | ||
f51f526b S |
59 | @staticmethod |
60 | def _extract_urls(webpage): | |
61 | return [ | |
40268a79 | 62 | f'https://video.foxnews.com/v/video-embed.html?video_id={mobj.group("video_id")}' |
f51f526b | 63 | for mobj in re.finditer( |
40268a79 E |
64 | r'''(?x) |
65 | <(?:script|(?:amp-)?iframe)[^>]+\bsrc=["\'] | |
66 | (?:https?:)?//video\.foxnews\.com/v/(?:video-embed\.html|embed\.js)\? | |
67 | (?:[^>"\']+&)?(?:video_)?id=(?P<video_id>\d+) | |
68 | ''', webpage)] | |
f51f526b | 69 | |
1139a54d | 70 | def _real_extract(self, url): |
5ad28e7f | 71 | host, video_id = self._match_valid_url(url).groups() |
d7e82645 | 72 | |
c7fa5fa4 | 73 | info = self._extract_feed_info( |
74 | 'http://%s/v/feed/video/%s.js?template=fox' % (host, video_id)) | |
3793090b | 75 | info['id'] = video_id |
76 | return info | |
cdc78351 YCH |
77 | |
78 | ||
fea74aca | 79 | class FoxNewsArticleIE(InfoExtractor): |
91aa502d | 80 | _VALID_URL = r'https?://(?:www\.)?(?:insider\.)?foxnews\.com/(?!v)([^/]+/)+(?P<id>[a-z-]+)' |
fea74aca | 81 | IE_NAME = 'foxnews:article' |
2cdbc06a | 82 | |
f51f526b S |
83 | _TESTS = [{ |
84 | # data-video-id | |
2cdbc06a | 85 | 'url': 'http://www.foxnews.com/politics/2016/09/08/buzz-about-bud-clinton-camp-denies-claims-wore-earpiece-at-forum.html', |
f51f526b | 86 | 'md5': '83d44e1aff1433e7a29a7b537d1700b5', |
2cdbc06a YCH |
87 | 'info_dict': { |
88 | 'id': '5116295019001', | |
89 | 'ext': 'mp4', | |
90 | 'title': 'Trump and Clinton asked to defend positions on Iraq War', | |
91 | 'description': 'Veterans react on \'The Kelly File\'', | |
f51f526b | 92 | 'timestamp': 1473301045, |
2cdbc06a YCH |
93 | 'upload_date': '20160908', |
94 | }, | |
f51f526b S |
95 | }, { |
96 | # iframe embed | |
97 | 'url': 'http://www.foxnews.com/us/2018/03/09/parkland-survivor-kyle-kashuv-on-meeting-trump-his-app-to-prevent-another-school-shooting.amp.html?__twitter_impression=true', | |
98 | 'info_dict': { | |
99 | 'id': '5748266721001', | |
100 | 'ext': 'flv', | |
101 | 'title': 'Kyle Kashuv has a positive message for the Trump White House', | |
102 | 'description': 'Marjory Stoneman Douglas student disagrees with classmates.', | |
103 | 'thumbnail': r're:^https?://.*\.jpg$', | |
104 | 'duration': 229, | |
105 | 'timestamp': 1520594670, | |
106 | 'upload_date': '20180309', | |
107 | }, | |
108 | 'params': { | |
109 | 'skip_download': True, | |
110 | }, | |
91aa502d S |
111 | }, { |
112 | 'url': 'http://insider.foxnews.com/2016/08/25/univ-wisconsin-student-group-pushing-silence-certain-words', | |
113 | 'only_matching': True, | |
f51f526b | 114 | }] |
2cdbc06a YCH |
115 | |
116 | def _real_extract(self, url): | |
117 | display_id = self._match_id(url) | |
118 | webpage = self._download_webpage(url, display_id) | |
119 | ||
120 | video_id = self._html_search_regex( | |
121 | r'data-video-id=([\'"])(?P<id>[^\'"]+)\1', | |
f51f526b S |
122 | webpage, 'video ID', group='id', default=None) |
123 | if video_id: | |
124 | return self.url_result( | |
125 | 'http://video.foxnews.com/v/' + video_id, FoxNewsIE.ie_key()) | |
126 | ||
2cdbc06a | 127 | return self.url_result( |
f51f526b | 128 | FoxNewsIE._extract_urls(webpage)[0], FoxNewsIE.ie_key()) |