]>
Commit | Line | Data |
---|---|---|
78ab4f44 AG |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
3 | js_to_json, | |
4 | merge_dicts, | |
5 | ) | |
6 | ||
7 | ||
8 | class NewsyIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:www\.)?newsy\.com/stories/(?P<id>[^/?#$&]+)' | |
10 | ||
11 | _TESTS = [{ | |
12 | 'url': 'https://www.newsy.com/stories/nft-trend-leads-to-fraudulent-art-auctions/', | |
13 | 'info_dict': { | |
14 | 'id': '609d65125b086c24fb529312', | |
15 | 'ext': 'mp4', | |
16 | 'title': 'NFT Art Auctions Have A Piracy Problem', | |
17 | 'description': 'md5:971e52ab8bc97e50305475cde8284c83', | |
18 | 'display_id': 'nft-trend-leads-to-fraudulent-art-auctions', | |
19 | 'timestamp': 1621339200, | |
20 | 'duration': 339630, | |
21 | 'thumbnail': 'https://cdn.newsy.com/images/videos/x/1620927824_xyrrP4.jpg', | |
22 | 'upload_date': '20210518' | |
23 | }, | |
24 | 'params': {'skip_download': True} | |
25 | }] | |
26 | ||
27 | def _real_extract(self, url): | |
28 | display_id = self._match_id(url) | |
29 | webpage = self._download_webpage(url, display_id) | |
30 | data_json = self._parse_json(self._html_search_regex( | |
31 | r'data-video-player\s?=\s?"({[^"]+})">', webpage, 'data'), display_id, js_to_json) | |
32 | ld_json = self._search_json_ld(webpage, display_id, fatal=False) | |
33 | ||
34 | formats, subtitles = [], {} | |
35 | if data_json.get('stream'): | |
36 | fmts, subs = self._extract_m3u8_formats_and_subtitles(data_json['stream'], display_id) | |
37 | formats.extend(fmts) | |
38 | subtitles = self._merge_subtitles(subtitles, subs) | |
39 | self._sort_formats(formats) | |
40 | return merge_dicts(ld_json, { | |
41 | 'id': data_json['id'], | |
42 | 'display_id': display_id, | |
43 | 'title': data_json.get('headline'), | |
44 | 'duration': data_json.get('duration'), | |
45 | 'thumbnail': data_json.get('image'), | |
46 | 'formats': formats, | |
47 | 'subtitles': subtitles, | |
48 | }) |