mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-26 02:55:17 +00:00
parent
4cc99d7b6c
commit
0a1a8e3005
1 changed files with 10 additions and 17 deletions
|
@ -5,7 +5,6 @@
|
||||||
merge_dicts,
|
merge_dicts,
|
||||||
parse_count,
|
parse_count,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
urljoin,
|
|
||||||
)
|
)
|
||||||
from ..utils.traversal import traverse_obj
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
@ -16,8 +15,7 @@ class NFBBaseIE(InfoExtractor):
|
||||||
|
|
||||||
def _extract_ep_data(self, webpage, video_id, fatal=False):
|
def _extract_ep_data(self, webpage, video_id, fatal=False):
|
||||||
return self._search_json(
|
return self._search_json(
|
||||||
r'const\s+episodesData\s*=', webpage, 'episode data', video_id,
|
r'episodesData\s*:', webpage, 'episode data', video_id, fatal=fatal) or {}
|
||||||
contains_pattern=r'\[\s*{(?s:.+)}\s*\]', fatal=fatal) or []
|
|
||||||
|
|
||||||
def _extract_ep_info(self, data, video_id, slug=None):
|
def _extract_ep_info(self, data, video_id, slug=None):
|
||||||
info = traverse_obj(data, (lambda _, v: video_id in v['embed_url'], {
|
info = traverse_obj(data, (lambda _, v: video_id in v['embed_url'], {
|
||||||
|
@ -224,18 +222,14 @@ def _real_extract(self, url):
|
||||||
# type_ can change from film to serie(s) after redirect; new slug may have episode number
|
# type_ can change from film to serie(s) after redirect; new slug may have episode number
|
||||||
type_, slug = self._match_valid_url(urlh.url).group('type', 'id')
|
type_, slug = self._match_valid_url(urlh.url).group('type', 'id')
|
||||||
|
|
||||||
embed_url = urljoin(f'https://www.{site}.ca', self._html_search_regex(
|
player_data = self._search_json(
|
||||||
r'<[^>]+\bid=["\']player-iframe["\'][^>]*\bsrc=["\']([^"\']+)', webpage, 'embed url'))
|
r'window\.PLAYER_OPTIONS\[[^\]]+\]\s*=', webpage, 'player data', slug)
|
||||||
video_id = self._match_id(embed_url) # embed url has unique slug
|
video_id = self._match_id(player_data['overlay']['url']) # overlay url always has unique slug
|
||||||
player = self._download_webpage(embed_url, video_id, 'Downloading player page')
|
|
||||||
if 'MESSAGE_GEOBLOCKED' in player:
|
|
||||||
self.raise_geo_restricted(countries=self._GEO_COUNTRIES)
|
|
||||||
|
|
||||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
||||||
self._html_search_regex(r'source:\s*\'([^\']+)', player, 'm3u8 url'),
|
player_data['source'], video_id, 'mp4', m3u8_id='hls')
|
||||||
video_id, 'mp4', m3u8_id='hls')
|
|
||||||
|
|
||||||
if dv_source := self._html_search_regex(r'dvSource:\s*\'([^\']+)', player, 'dv', default=None):
|
if dv_source := url_or_none(player_data.get('dvSource')):
|
||||||
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
fmts, subs = self._extract_m3u8_formats_and_subtitles(
|
||||||
dv_source, video_id, 'mp4', m3u8_id='dv', preference=-2, fatal=False)
|
dv_source, video_id, 'mp4', m3u8_id='dv', preference=-2, fatal=False)
|
||||||
for fmt in fmts:
|
for fmt in fmts:
|
||||||
|
@ -246,17 +240,16 @@ def _real_extract(self, url):
|
||||||
info = {
|
info = {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': self._html_search_regex(
|
'title': self._html_search_regex(
|
||||||
r'<[^>]+\bid=["\']titleHeader["\'][^>]*>\s*<h1[^>]*>\s*([^<]+?)\s*</h1>',
|
r'["\']nfb_version_title["\']\s*:\s*["\']([^"\']+)',
|
||||||
webpage, 'title', default=None),
|
webpage, 'title', default=None),
|
||||||
'description': self._html_search_regex(
|
'description': self._html_search_regex(
|
||||||
r'<[^>]+\bid=["\']tabSynopsis["\'][^>]*>\s*<p[^>]*>\s*([^<]+)',
|
r'<[^>]+\bid=["\']tabSynopsis["\'][^>]*>\s*<p[^>]*>\s*([^<]+)',
|
||||||
webpage, 'description', default=None),
|
webpage, 'description', default=None),
|
||||||
'thumbnail': self._html_search_regex(
|
'thumbnail': url_or_none(player_data.get('poster')),
|
||||||
r'poster:\s*\'([^\']+)', player, 'thumbnail', default=None),
|
|
||||||
'uploader': self._html_search_regex(
|
'uploader': self._html_search_regex(
|
||||||
r'<[^>]+\bitemprop=["\']name["\'][^>]*>([^<]+)', webpage, 'uploader', default=None),
|
r'<[^>]+\bitemprop=["\']director["\'][^>]*>([^<]+)', webpage, 'uploader', default=None),
|
||||||
'release_year': int_or_none(self._html_search_regex(
|
'release_year': int_or_none(self._html_search_regex(
|
||||||
r'<[^>]+\bitemprop=["\']datePublished["\'][^>]*>([^<]+)',
|
r'["\']nfb_version_year["\']\s*:\s*["\']([^"\']+)',
|
||||||
webpage, 'release_year', default=None)),
|
webpage, 'release_year', default=None)),
|
||||||
} if type_ == 'film' else self._extract_ep_info(self._extract_ep_data(webpage, video_id, slug), video_id)
|
} if type_ == 'film' else self._extract_ep_info(self._extract_ep_data(webpage, video_id, slug), video_id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue