aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshish Gupta <39122144+Ashish0804@users.noreply.github.com>2022-01-21 12:31:25 +0530
committerGitHub <noreply@github.com>2022-01-21 12:31:25 +0530
commit78ab4f447c7aa019bb73b7d5b711c78dc4dd0f73 (patch)
tree3774cfc0f5ab6a2887aaf8c28f18e4e747998f65
parent85fee2215295b099d34350d9a9ff42c086e3aef2 (diff)
downloadhypervideo-pre-78ab4f447c7aa019bb73b7d5b711c78dc4dd0f73.tar.lz
hypervideo-pre-78ab4f447c7aa019bb73b7d5b711c78dc4dd0f73.tar.xz
hypervideo-pre-78ab4f447c7aa019bb73b7d5b711c78dc4dd0f73.zip
[Newsy] Add extractor (#2416)
Closes #2346 Authored by: Ashish0804
-rw-r--r--yt_dlp/extractor/extractors.py1
-rw-r--r--yt_dlp/extractor/newsy.py51
2 files changed, 52 insertions, 0 deletions
diff --git a/yt_dlp/extractor/extractors.py b/yt_dlp/extractor/extractors.py
index d93e36b74..7c67879ad 100644
--- a/yt_dlp/extractor/extractors.py
+++ b/yt_dlp/extractor/extractors.py
@@ -958,6 +958,7 @@ from .newgrounds import (
NewgroundsUserIE,
)
from .newstube import NewstubeIE
+from .newsy import NewsyIE
from .nextmedia import (
NextMediaIE,
NextMediaActionNewsIE,
diff --git a/yt_dlp/extractor/newsy.py b/yt_dlp/extractor/newsy.py
new file mode 100644
index 000000000..cf3164100
--- /dev/null
+++ b/yt_dlp/extractor/newsy.py
@@ -0,0 +1,51 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+from ..utils import (
+ js_to_json,
+ merge_dicts,
+)
+
+
+class NewsyIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?newsy\.com/stories/(?P<id>[^/?#$&]+)'
+
+ _TESTS = [{
+ 'url': 'https://www.newsy.com/stories/nft-trend-leads-to-fraudulent-art-auctions/',
+ 'info_dict': {
+ 'id': '609d65125b086c24fb529312',
+ 'ext': 'mp4',
+ 'title': 'NFT Art Auctions Have A Piracy Problem',
+ 'description': 'md5:971e52ab8bc97e50305475cde8284c83',
+ 'display_id': 'nft-trend-leads-to-fraudulent-art-auctions',
+ 'timestamp': 1621339200,
+ 'duration': 339630,
+ 'thumbnail': 'https://cdn.newsy.com/images/videos/x/1620927824_xyrrP4.jpg',
+ 'upload_date': '20210518'
+ },
+ 'params': {'skip_download': True}
+ }]
+
+ def _real_extract(self, url):
+ display_id = self._match_id(url)
+ webpage = self._download_webpage(url, display_id)
+ data_json = self._parse_json(self._html_search_regex(
+ r'data-video-player\s?=\s?"({[^"]+})">', webpage, 'data'), display_id, js_to_json)
+ ld_json = self._search_json_ld(webpage, display_id, fatal=False)
+
+ formats, subtitles = [], {}
+ if data_json.get('stream'):
+ fmts, subs = self._extract_m3u8_formats_and_subtitles(data_json['stream'], display_id)
+ formats.extend(fmts)
+ subtitles = self._merge_subtitles(subtitles, subs)
+ self._sort_formats(formats)
+ return merge_dicts(ld_json, {
+ 'id': data_json['id'],
+ 'display_id': display_id,
+ 'title': data_json.get('headline'),
+ 'duration': data_json.get('duration'),
+ 'thumbnail': data_json.get('image'),
+ 'formats': formats,
+ 'subtitles': subtitles,
+ })