]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/freetv.py
4 from .common
import InfoExtractor
12 class FreeTvBaseIE(InfoExtractor
):
13 def _get_api_response(self
, content_id
, resource_type
, postdata
):
14 return self
._download
_json
(
15 'https://www.freetv.com/wordpress/wp-admin/admin-ajax.php',
16 content_id
, data
=urlencode_postdata(postdata
),
17 note
=f
'Downloading {content_id} {resource_type} JSON')['data']
20 class FreeTvMoviesIE(FreeTvBaseIE
):
21 _VALID_URL
= r
'https?://(?:www\.)?freetv\.com/peliculas/(?P<id>[^/]+)'
23 'url': 'https://www.freetv.com/peliculas/atrapame-si-puedes/',
24 'md5': 'dc62d5abf0514726640077cd1591aa92',
27 'title': 'AtrĂ¡pame Si Puedes',
28 'description': 'md5:ca63bc00898aeb2f64ec87c6d3a5b982',
32 'url': 'https://www.freetv.com/peliculas/monstruoso/',
33 'md5': '509c15c68de41cb708d1f92d071f20aa',
36 'title': 'Monstruoso',
37 'description': 'md5:333fc19ee327b457b980e54a911ea4a3',
42 def _extract_video(self
, content_id
, action
='olyott_video_play'):
43 api_response
= self
._get
_api
_response
(content_id
, 'video', {
45 'contentID': content_id
,
48 video_id
, video_url
= api_response
['displayMeta']['contentID'], api_response
['displayMeta']['streamURLVideo']
49 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(video_url
, video_id
, 'mp4')
50 self
._sort
_formats
(formats
)
54 'title': traverse_obj(api_response
, ('displayMeta', 'title')),
55 'description': traverse_obj(api_response
, ('displayMeta', 'desc')),
57 'subtitles': subtitles
,
60 def _real_extract(self
, url
):
61 display_id
= self
._match
_id
(url
)
62 webpage
= self
._download
_webpage
(url
, display_id
)
64 return self
._extract
_video
(
66 r
'class=["\'][^
>]+postid
-(?P
<video_id
>\d
+)',
67 r'<link
[^
>]+freetv
.com
/\?p
=(?P
<video_id
>\d
+)',
68 r'<div
[^
>]+data
-params
=["\'][^>]+post_id=(?P<video_id>\d+)',
69 ), webpage, 'video id', group='video_id'))
72 class FreeTvIE(FreeTvBaseIE):
73 IE_NAME = 'freetv:series'
74 _VALID_URL = r'https?://(?:www\.)?freetv\.com/series/(?P<id>[^/]+)'
76 'url': 'https://www.freetv.com/series/el-detective-l/',
78 'id': 'el-detective-l',
79 'title': 'El Detective L',
80 'description': 'md5:f9f1143bc33e9856ecbfcbfb97a759be'
84 'url': 'https://www.freetv.com/series/esmeraldas/',
87 'title': 'Esmeraldas',
88 'description': 'md5:43d7ec45bd931d8268a4f5afaf4c77bf'
92 'url': 'https://www.freetv.com/series/las-aventuras-de-leonardo/',
94 'id': 'las-aventuras-de-leonardo',
95 'title': 'Las Aventuras de Leonardo',
96 'description': 'md5:0c47130846c141120a382aca059288f6'
102 def _extract_series_season(self, season_id, series_title):
103 episodes = self._get_api_response(season_id, 'series', {
104 'contentID': season_id,
105 'action': 'olyott_get_dynamic_series_content',
110 for episode in episodes:
111 video_id = str(episode['contentID'])
112 formats, subtitles = self._extract_m3u8_formats_and_subtitles(episode['streamURL'], video_id, 'mp4')
113 self._sort_formats(formats)
117 'title': episode.get('fullTitle'),
118 'description': episode.get('description'),
120 'subtitles': subtitles,
121 'thumbnail': episode.get('thumbnail'),
122 'series': series_title,
123 'series_id': traverse_obj(episode, ('contentMeta', 'displayMeta', 'seriesID')),
124 'season_id': traverse_obj(episode, ('contentMeta', 'displayMeta', 'seasonID')),
125 'season_number': traverse_obj(
126 episode, ('contentMeta', 'displayMeta', 'seasonNum'), expected_type=int_or_none),
127 'episode_number': traverse_obj(
128 episode, ('contentMeta', 'displayMeta', 'episodeNum'), expected_type=int_or_none),
131 def _real_extract(self, url):
132 display_id = self._match_id(url)
133 webpage = self._download_webpage(url, display_id)
135 title = self._html_search_regex(
136 r'<h1[^>]+class=["\']synopis
[^
>]>(?P
<title
>[^
<]+)', webpage, 'title
', group='title
', fatal=False)
137 description = self._html_search_regex(
138 r'<div
[^
>]+class=["\']+synopis content[^>]><p>(?P<description>[^<]+)',
139 webpage, 'description', group='description', fatal=False)
141 return self.playlist_result(
142 itertools.chain.from_iterable(
143 self._extract_series_season(season_id, title)
144 for season_id in re.findall(r'<option[^>]+value=["\'](\d
+)["\']', webpage)),
145 display_id, title, description)