Compare commits

..

No commits in common. "38bb163fe158f707a2c4dfada640e98b0e015e2a" and "daeb7ec631727ca7749e036f66af4af65e0d2a04" have entirely different histories.

4 changed files with 79 additions and 42 deletions

View File

@ -493,6 +493,7 @@
- **gem.cbc.ca**: [*cbcgem*](## "netrc machine") - **gem.cbc.ca**: [*cbcgem*](## "netrc machine")
- **gem.cbc.ca:live** - **gem.cbc.ca:live**
- **gem.cbc.ca:playlist** - **gem.cbc.ca:playlist**
- **generic**: Generic downloader that works on some sites
- **Genius** - **Genius**
- **GeniusLyrics** - **GeniusLyrics**
- **Gettr** - **Gettr**
@ -1471,7 +1472,6 @@
- **TuneInPodcast** - **TuneInPodcast**
- **TuneInPodcastEpisode** - **TuneInPodcastEpisode**
- **TuneInStation** - **TuneInStation**
- **Turbo**
- **tv.dfb.de** - **tv.dfb.de**
- **TV2** - **TV2**
- **TV2Article** - **TV2Article**
@ -1601,6 +1601,7 @@
- **ViMP:Playlist** - **ViMP:Playlist**
- **Vine** - **Vine**
- **vine:user** - **vine:user**
- **Viously**
- **Viqeo** - **Viqeo**
- **Viu** - **Viu**
- **viu:ott**: [*viu*](## "netrc machine") - **viu:ott**: [*viu*](## "netrc machine")

View File

@ -1216,10 +1216,7 @@ from .nexx import (
NexxIE, NexxIE,
NexxEmbedIE, NexxEmbedIE,
) )
from .nfb import ( from .nfb import NFBIE
NFBIE,
ONFIE,
)
from .nfhsnetwork import NFHSNetworkIE from .nfhsnetwork import NFHSNetworkIE
from .nfl import ( from .nfl import (
NFLIE, NFLIE,
@ -1347,6 +1344,7 @@ from .onet import (
OnetMVPIE, OnetMVPIE,
OnetPlIE, OnetPlIE,
) )
from .onf import ONFIE
from .onionstudios import OnionStudiosIE from .onionstudios import OnionStudiosIE
from .opencast import ( from .opencast import (
OpencastIE, OpencastIE,

View File

@ -2,17 +2,31 @@ from .common import InfoExtractor
from ..utils import int_or_none from ..utils import int_or_none
class NFBBaseIE(InfoExtractor): class NFBIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?nfb\.ca/film/(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://www.nfb.ca/film/trafficopter/',
'info_dict': {
'id': 'trafficopter',
'ext': 'mp4',
'title': 'Trafficopter',
'description': 'md5:060228455eb85cf88785c41656776bc0',
'thumbnail': r're:^https?://.*\.jpg$',
'uploader': 'Barrie Howells',
'release_year': 1972,
},
}]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(f'https://{self.domain}/film/%s/' % video_id, video_id) webpage = self._download_webpage('https://www.nfb.ca/film/%s/' % video_id, video_id)
iframe = self._html_search_regex( iframe = self._html_search_regex(
r'<[^>]+\bid=["\']player-iframe["\'][^>]*src=["\']([^"\']+)', r'<[^>]+\bid=["\']player-iframe["\'][^>]*src=["\']([^"\']+)',
webpage, 'iframe', default=None, fatal=True) webpage, 'iframe', default=None, fatal=True)
if iframe.startswith('/'): if iframe.startswith('/'):
iframe = f'https://{self.domain}{iframe}' iframe = f'https://www.nfb.ca{iframe}'
player = self._download_webpage(iframe, video_id) player = self._download_webpage(iframe, video_id)
@ -42,37 +56,3 @@ class NFBBaseIE(InfoExtractor):
'formats': formats, 'formats': formats,
'subtitles': subtitles, 'subtitles': subtitles,
} }
class NFBIE(NFBBaseIE):
_VALID_URL = r'https?://(?:www\.)?nfb\.ca/film/(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://www.nfb.ca/film/trafficopter/',
'info_dict': {
'id': 'trafficopter',
'ext': 'mp4',
'title': 'Trafficopter',
'description': 'md5:060228455eb85cf88785c41656776bc0',
'thumbnail': r're:^https?://.*\.jpg$',
'uploader': 'Barrie Howells',
'release_year': 1972,
},
}]
domain = 'www.nfb.ca'
class ONFIE(NFBBaseIE):
_VALID_URL = r'https?://(?:www\.)?onf\.ca/film/(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://www.onf.ca/film/mal-du-siecle/',
'info_dict': {
'id': 'mal-du-siecle',
'ext': 'mp4',
'title': 'Le mal du siècle',
'description': 'md5:1abf774d77569ebe603419f2d344102b',
'thumbnail': r're:^https?://.*\.jpg$',
'uploader': 'Catherine Lepage',
'release_year': 2019
},
}]
domain = 'www.onf.ca'

58
yt_dlp/extractor/onf.py Normal file
View File

@ -0,0 +1,58 @@
from .common import InfoExtractor
from ..utils import int_or_none
class ONFIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?onf\.ca/film/(?P<id>[^/?#&]+)'
_TESTS = [{
'url': 'https://www.onf.ca/film/mal-du-siecle/',
'info_dict': {
'id': 'mal-du-siecle',
'ext': 'mp4',
'title': 'Le mal du siècle',
'description': 'md5:1abf774d77569ebe603419f2d344102b',
'thumbnail': r're:^https?://.*\.jpg$',
'uploader': 'Catherine Lepage',
'release_year': 2019
},
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage('https://www.onf.ca/film/%s/' % video_id, video_id)
iframe = self._html_search_regex(
r'<[^>]+\bid=["\']player-iframe["\'][^>]*src=["\']([^"\']+)',
webpage, 'iframe', default=None, fatal=True)
if iframe.startswith('/'):
iframe = f'https://www.onf.ca{iframe}'
player = self._download_webpage(iframe, video_id)
source = self._html_search_regex(
r'source:\s*\'([^\']+)',
player, 'source', default=None, fatal=True)
formats, subtitles = self._extract_m3u8_formats_and_subtitles(source, video_id, ext='mp4')
return {
'id': video_id,
'title': self._html_search_regex(
r'<[^>]+\bid=["\']titleHeader["\'][^>]*>\s*<h1[^>]*>\s*([^<]+?)\s*</h1>',
webpage, 'title', default=None),
'description': self._html_search_regex(
r'<[^>]+\bid=["\']tabSynopsis["\'][^>]*>\s*<p[^>]*>\s*([^<]+)',
webpage, 'description', default=None),
'thumbnail': self._html_search_regex(
r'poster:\s*\'([^\']+)',
player, 'thumbnail', default=None),
'uploader': self._html_search_regex(
r'<[^>]+\bitemprop=["\']name["\'][^>]*>([^<]+)',
webpage, 'uploader', default=None),
'release_year': int_or_none(self._html_search_regex(
r'<[^>]+\bitemprop=["\']datePublished["\'][^>]*>([^<]+)',
webpage, 'release_year', default=None)),
'formats': formats,
'subtitles': subtitles,
}