mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-14 21:23:05 +00:00
use m3u8 extractor
This commit is contained in:
parent
9a8afadd17
commit
4d24983442
@ -19,11 +19,6 @@ class FrontendMastersBaseIE(InfoExtractor):
|
|||||||
|
|
||||||
_NETRC_MACHINE = 'frontendmasters'
|
_NETRC_MACHINE = 'frontendmasters'
|
||||||
|
|
||||||
_QUALITIES = {
|
|
||||||
'low': {'width': 480, 'height': 360},
|
|
||||||
'mid': {'width': 1280, 'height': 720},
|
|
||||||
'high': {'width': 1920, 'height': 1080}
|
|
||||||
}
|
|
||||||
|
|
||||||
def _perform_login(self, username, password):
|
def _perform_login(self, username, password):
|
||||||
login_page = self._download_webpage(
|
login_page = self._download_webpage(
|
||||||
@ -130,40 +125,32 @@ class FrontendMastersIE(FrontendMastersBaseIE):
|
|||||||
'url': 'frontendmasters:a2qogef6ba',
|
'url': 'frontendmasters:a2qogef6ba',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
lesson_id = self._match_id(url)
|
lesson_id = self._match_id(url)
|
||||||
|
|
||||||
source_url = '%s/video/%s/source' % (self._API_BASE, lesson_id)
|
source_url = f'{self._API_BASE}/video/{lesson_id}/source'
|
||||||
|
headers = {
|
||||||
|
'Referer': 'https://frontendmasters.com/',
|
||||||
|
}
|
||||||
|
cookies = self._get_cookies("https://frontendmasters.com/")
|
||||||
|
fem_auth_mod = cookies.get('fem_auth_mod')
|
||||||
|
if fem_auth_mod:
|
||||||
|
headers['Cookie'] = f'fem_auth_mod={fem_auth_mod.value}'
|
||||||
|
|
||||||
formats = []
|
json = self._download_json(
|
||||||
for ext in ('webm', 'mp4'):
|
source_url,
|
||||||
for quality in ('low', 'mid', 'high'):
|
'Downloading source JSON', query={
|
||||||
resolution = self._QUALITIES[quality].copy()
|
'f': 'm3u8'
|
||||||
format_id = '%s-%s' % (ext, quality)
|
}, headers=headers)
|
||||||
format_url = self._download_json(
|
|
||||||
source_url, lesson_id,
|
|
||||||
'Downloading %s source JSON' % format_id, query={
|
|
||||||
'f': ext,
|
|
||||||
'r': resolution['height'],
|
|
||||||
}, headers={
|
|
||||||
'Referer': url,
|
|
||||||
}, fatal=False)['url']
|
|
||||||
|
|
||||||
if not format_url:
|
video_url = json.get('url')
|
||||||
continue
|
|
||||||
|
formats = self._extract_m3u8_formats(video_url, lesson_id)
|
||||||
|
|
||||||
f = resolution.copy()
|
|
||||||
f.update({
|
|
||||||
'url': format_url,
|
|
||||||
'ext': ext,
|
|
||||||
'format_id': format_id,
|
|
||||||
})
|
|
||||||
formats.append(f)
|
|
||||||
|
|
||||||
subtitles = {
|
subtitles = {
|
||||||
'en': [{
|
'en': [{
|
||||||
'url': '%s/transcripts/%s.vtt' % (self._API_BASE, lesson_id),
|
'url': f'{self._API_BASE}/transcripts/{lesson_id}.vtt'
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user