[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / trtcocuk.py
blob0c899f1e766313460b27aa0619be4dff51147201
1 from .common import InfoExtractor
2 from ..utils import ExtractorError, int_or_none, parse_iso8601, traverse_obj
5 class TrtCocukVideoIE(InfoExtractor):
6 _VALID_URL = r'https?://www\.trtcocuk\.net\.tr/video/(?P<id>[\w-]+)'
7 _TESTS = [{
8 'url': 'https://www.trtcocuk.net.tr/video/kaptan-pengu-ve-arkadaslari-1',
9 'info_dict': {
10 'id': '3789738',
11 'ext': 'mp4',
12 'season_number': 1,
13 'series': '"Kaptan Pengu ve Arkadaşları"',
14 'season': 'Season 1',
15 'title': 'Kaptan Pengu ve Arkadaşları 1 Bölüm İzle TRT Çocuk',
16 'release_date': '20201209',
17 'release_timestamp': 1607513774,
19 }, {
20 'url': 'https://www.trtcocuk.net.tr/video/sef-rokanin-lezzet-dunyasi-17',
21 'info_dict': {
22 'id': '10260842',
23 'ext': 'mp4',
24 'series': '"Şef Roka\'nın Lezzet Dünyası"',
25 'title': 'Şef Roka\'nın Lezzet Dünyası 17 Bölüm İzle TRT Çocuk',
29 def _real_extract(self, url):
30 display_id = self._match_id(url)
31 webpage = self._download_webpage(url, display_id)
32 nuxtjs_data = self._search_nuxt_data(webpage, display_id)['data']
34 try:
35 video_url = self._parse_json(nuxtjs_data['video'], display_id)
36 except ExtractorError:
37 video_url = nuxtjs_data['video']
38 formats, subtitles = self._extract_m3u8_formats_and_subtitles(video_url, display_id)
40 return {
41 'id': str(nuxtjs_data['id']),
42 'formats': formats,
43 'subtitles': subtitles,
44 'season_number': int_or_none(nuxtjs_data.get('season')),
45 'release_timestamp': parse_iso8601(nuxtjs_data.get('publishedDate')),
46 'series': traverse_obj(nuxtjs_data, ('show', 0, 'title')),
47 'title': self._html_extract_title(webpage), # TODO: get better title