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