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