4 from .common
import InfoExtractor
5 from ..utils
import int_or_none
, traverse_obj
, urlencode_postdata
8 class FreeTvBaseIE(InfoExtractor
):
9 def _get_api_response(self
, content_id
, resource_type
, postdata
):
10 return self
._download
_json
(
11 'https://www.freetv.com/wordpress/wp-admin/admin-ajax.php',
12 content_id
, data
=urlencode_postdata(postdata
),
13 note
=f
'Downloading {content_id} {resource_type} JSON')['data']
16 class FreeTvMoviesIE(FreeTvBaseIE
):
17 _VALID_URL
= r
'https?://(?:www\.)?freetv\.com/peliculas/(?P<id>[^/]+)'
19 'url': 'https://www.freetv.com/peliculas/atrapame-si-puedes/',
20 'md5': 'dc62d5abf0514726640077cd1591aa92',
23 'title': 'AtrĂ¡pame Si Puedes',
24 'description': 'md5:ca63bc00898aeb2f64ec87c6d3a5b982',
28 'url': 'https://www.freetv.com/peliculas/monstruoso/',
29 'md5': '509c15c68de41cb708d1f92d071f20aa',
32 'title': 'Monstruoso',
33 'description': 'md5:333fc19ee327b457b980e54a911ea4a3',
38 def _extract_video(self
, content_id
, action
='olyott_video_play'):
39 api_response
= self
._get
_api
_response
(content_id
, 'video', {
41 'contentID': content_id
,
44 video_id
, video_url
= api_response
['displayMeta']['contentID'], api_response
['displayMeta']['streamURLVideo']
45 formats
, subtitles
= self
._extract
_m
3u8_formats
_and
_subtitles
(video_url
, video_id
, 'mp4')
49 'title': traverse_obj(api_response
, ('displayMeta', 'title')),
50 'description': traverse_obj(api_response
, ('displayMeta', 'desc')),
52 'subtitles': subtitles
,
55 def _real_extract(self
, url
):
56 display_id
= self
._match
_id
(url
)
57 webpage
= self
._download
_webpage
(url
, display_id
)
59 return self
._extract
_video
(
61 r
'class=["\'][^
>]+postid
-(?P
<video_id
>\d
+)',
62 r'<link
[^
>]+freetv
.com
/\?p
=(?P
<video_id
>\d
+)',
63 r'<div
[^
>]+data
-params
=["\'][^>]+post_id=(?P<video_id>\d+)',
64 ), webpage, 'video id', group='video_id'))
67 class FreeTvIE(FreeTvBaseIE):
68 IE_NAME = 'freetv:series'
69 _VALID_URL = r'https?://(?:www\.)?freetv\.com/series/(?P<id>[^/]+)'
71 'url': 'https://www.freetv.com/series/el-detective-l/',
73 'id': 'el-detective-l',
74 'title': 'El Detective L',
75 'description': 'md5:f9f1143bc33e9856ecbfcbfb97a759be',
79 'url': 'https://www.freetv.com/series/esmeraldas/',
82 'title': 'Esmeraldas',
83 'description': 'md5:43d7ec45bd931d8268a4f5afaf4c77bf',
87 'url': 'https://www.freetv.com/series/las-aventuras-de-leonardo/',
89 'id': 'las-aventuras-de-leonardo',
90 'title': 'Las Aventuras de Leonardo',
91 'description': 'md5:0c47130846c141120a382aca059288f6',
97 def _extract_series_season(self, season_id, series_title):
98 episodes = self._get_api_response(season_id, 'series', {
99 'contentID': season_id,
100 'action': 'olyott_get_dynamic_series_content',
105 for episode in episodes:
106 video_id = str(episode['contentID'])
107 formats, subtitles = self._extract_m3u8_formats_and_subtitles(episode['streamURL'], video_id, 'mp4')
111 'title': episode.get('fullTitle'),
112 'description': episode.get('description'),
114 'subtitles': subtitles,
115 'thumbnail': episode.get('thumbnail'),
116 'series': series_title,
117 'series_id': traverse_obj(episode, ('contentMeta', 'displayMeta', 'seriesID')),
118 'season_id': traverse_obj(episode, ('contentMeta', 'displayMeta', 'seasonID')),
119 'season_number': traverse_obj(
120 episode, ('contentMeta', 'displayMeta', 'seasonNum'), expected_type=int_or_none),
121 'episode_number': traverse_obj(
122 episode, ('contentMeta', 'displayMeta', 'episodeNum'), expected_type=int_or_none),
125 def _real_extract(self, url):
126 display_id = self._match_id(url)
127 webpage = self._download_webpage(url, display_id)
129 title = self._html_search_regex(
130 r'<h1[^>]+class=["\']synopis
[^
>]>(?P
<title
>[^
<]+)', webpage, 'title
', group='title
', fatal=False)
131 description = self._html_search_regex(
132 r'<div
[^
>]+class=["\']+synopis content[^>]><p>(?P<description>[^<]+)',
133 webpage, 'description', group='description', fatal=False)
135 return self.playlist_result(
136 itertools.chain.from_iterable(
137 self._extract_series_season(season_id, title)
138 for season_id in re.findall(r'<option[^>]+value=["\'](\d
+)["\']', webpage)),
139 display_id, title, description)