]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/nfb.py
1 from .common
import InfoExtractor
2 from ..utils
import int_or_none
5 class NFBIE(InfoExtractor
):
6 _VALID_URL
= r
'https?://(?:www\.)?nfb\.ca/film/(?P<id>[^/?#&]+)'
8 'url': 'https://www.nfb.ca/film/trafficopter/',
12 'title': 'Trafficopter',
13 'description': 'md5:060228455eb85cf88785c41656776bc0',
14 'thumbnail': r
're:^https?://.*\.jpg$',
15 'uploader': 'Barrie Howells',
20 def _real_extract(self
, url
):
21 video_id
= self
._match
_id
(url
)
23 webpage
= self
._download
_webpage
('https://www.nfb.ca/film/%s/' % video_id
, video_id
)
25 iframe
= self
._html
_search
_regex
(
26 r
'<[^>]+\bid=["\']player
-iframe
["\'][^>]*src=["\']([^
"\']+)',
27 webpage, 'iframe', default=None, fatal=True)
28 if iframe.startswith('/'):
29 iframe = f'https://www.nfb.ca{iframe}'
31 player = self._download_webpage(iframe, video_id)
33 source = self._html_search_regex(
34 r'source:\s*\'([^\']+)',
35 player, 'source', default=None, fatal=True)
37 formats, subtitles = self._extract_m3u8_formats_and_subtitles(source, video_id, ext='mp4')
38 self._sort_formats(formats)
42 'title': self._html_search_regex(
43 r'<[^>]+\bid=["\']titleHeader
["\'][^>]*>\s*<h1[^>]*>\s*([^<]+?)\s*</h1>',
44 webpage, 'title', default=None),
45 'description': self._html_search_regex(
46 r'<[^>]+\bid=["\']tabSynopsis
["\'][^>]*>\s*<p[^>]*>\s*([^<]+)',
47 webpage, 'description', default=None),
48 'thumbnail': self._html_search_regex(
49 r'poster:\s*\'([^\']+)',
50 player, 'thumbnail', default=None),
51 'uploader': self._html_search_regex(
52 r'<[^>]+\bitemprop=["\']name
["\'][^>]*>([^<]+)',
53 webpage, 'uploader', default=None),
54 'release_year': int_or_none(self._html_search_regex(
55 r'<[^>]+\bitemprop=["\']datePublished
["\'][^>]*>([^<]+)',
56 webpage, 'release_year', default=None)),
58 'subtitles': subtitles,