1 from .common
import InfoExtractor
2 from ..networking
.exceptions
import HTTPError
16 class PuhuTVIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-izle'
21 'url': 'https://puhutv.com/sut-kardesler-izle',
22 'md5': 'a347470371d56e1585d1b2c8dab01c96',
25 'display_id': 'sut-kardesler',
27 'title': 'Süt Kardeşler',
28 'description': 'md5:ca09da25b7e57cbb5a9280d6e48d17aa',
29 'thumbnail': r
're:^https?://.*\.jpg$',
31 'creator': 'Arzu Film',
32 'timestamp': 1561062602,
33 'upload_date': '20190620',
39 # episode, geo restricted, bypassable with --geo-verification-proxy
40 'url': 'https://puhutv.com/jet-sosyete-1-bolum-izle',
41 'only_matching': True,
44 'url': 'https://puhutv.com/dip-1-bolum-izle',
45 'only_matching': True,
53 def _real_extract(self
, url
):
54 display_id
= self
._match
_id
(url
)
56 info
= self
._download
_json
(
57 urljoin(url
, f
'/api/slug/{display_id}-izle'),
60 video_id
= str(info
['id'])
61 show
= info
.get('title') or {}
62 title
= info
.get('name') or show
['name']
63 if info
.get('display_name'):
64 title
= '{} {}'.format(title
, info
['display_name'])
67 videos
= self
._download
_json
(
68 f
'https://puhutv.com/api/assets/{video_id}/videos',
69 display_id
, 'Downloading video JSON',
70 headers
=self
.geo_verification_headers())
71 except ExtractorError
as e
:
72 if isinstance(e
.cause
, HTTPError
) and e
.cause
.status
== 403:
73 self
.raise_geo_restricted()
79 for video
in videos
['data']['videos']:
80 media_url
= url_or_none(video
.get('url'))
81 if not media_url
or media_url
in urls
:
83 urls
.append(media_url
)
85 playlist
= video
.get('is_playlist')
86 if (video
.get('stream_type') == 'hls' and playlist
is True) or 'playlist.m3u8' in media_url
:
87 formats
.extend(self
._extract
_m
3u8_formats
(
88 media_url
, video_id
, 'mp4', entry_protocol
='m3u8_native',
89 m3u8_id
='hls', fatal
=False))
92 quality
= int_or_none(video
.get('quality'))
98 video_format
= video
.get('video_format')
99 is_hls
= (video_format
== 'hls' or '/hls/' in media_url
or '/chunklist.m3u8' in media_url
) and playlist
is False
102 f
['protocol'] = 'm3u8_native'
103 elif video_format
== 'mp4':
108 format_id
+= f
'-{quality}p'
109 f
['format_id'] = format_id
113 show
, lambda x
: x
['producer']['name'], str)
115 content
= info
.get('content') or {}
118 content
, lambda x
: x
['images']['wide'], dict) or {}
120 for image_id
, image_url
in images
.items():
121 if not isinstance(image_url
, str):
123 if not image_url
.startswith(('http', '//')):
124 image_url
= f
'https://{image_url}'
125 t
= parse_resolution(image_id
)
133 for genre
in show
.get('genres') or []:
134 if not isinstance(genre
, dict):
136 genre_name
= genre
.get('name')
137 if genre_name
and isinstance(genre_name
, str):
138 tags
.append(genre_name
)
141 for subtitle
in content
.get('subtitles') or []:
142 if not isinstance(subtitle
, dict):
144 lang
= subtitle
.get('language')
145 sub_url
= url_or_none(subtitle
.get('url') or subtitle
.get('file'))
146 if not lang
or not isinstance(lang
, str) or not sub_url
:
148 subtitles
[self
._SUBTITLE
_LANGS
.get(lang
, lang
)] = [{
154 'display_id': display_id
,
156 'description': info
.get('description') or show
.get('description'),
157 'season_id': str_or_none(info
.get('season_id')),
158 'season_number': int_or_none(info
.get('season_number')),
159 'episode_number': int_or_none(info
.get('episode_number')),
160 'release_year': int_or_none(show
.get('released_at')),
161 'timestamp': unified_timestamp(info
.get('created_at')),
163 'view_count': int_or_none(content
.get('watch_count')),
164 'duration': float_or_none(content
.get('duration_in_ms'), 1000),
166 'subtitles': subtitles
,
167 'thumbnails': thumbnails
,
172 class PuhuTVSerieIE(InfoExtractor
):
173 _VALID_URL
= r
'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-detay'
174 IE_NAME
= 'puhutv:serie'
176 'url': 'https://puhutv.com/deniz-yildizi-detay',
178 'title': 'Deniz Yıldızı',
179 'id': 'deniz-yildizi',
181 'playlist_mincount': 205,
183 # a film detail page which is using same url with serie page
184 'url': 'https://puhutv.com/kaybedenler-kulubu-detay',
185 'only_matching': True,
188 def _extract_entries(self
, seasons
):
189 for season
in seasons
:
190 season_id
= season
.get('id')
195 while has_more
is True:
196 season
= self
._download
_json
(
197 f
'https://galadriel.puhutv.com/seasons/{season_id}',
198 season_id
, f
'Downloading page {page}', query
={
202 episodes
= season
.get('episodes')
203 if isinstance(episodes
, list):
205 slug_path
= str_or_none(ep
.get('slugPath'))
208 video_id
= str_or_none(int_or_none(ep
.get('id')))
209 yield self
.url_result(
210 f
'https://puhutv.com/{slug_path}',
211 ie
=PuhuTVIE
.ie_key(), video_id
=video_id
,
212 video_title
=ep
.get('name') or ep
.get('eventLabel'))
214 has_more
= season
.get('hasMore')
216 def _real_extract(self
, url
):
217 playlist_id
= self
._match
_id
(url
)
219 info
= self
._download
_json
(
220 urljoin(url
, f
'/api/slug/{playlist_id}-detay'),
223 seasons
= info
.get('seasons')
225 return self
.playlist_result(
226 self
._extract
_entries
(seasons
), playlist_id
, info
.get('name'))
228 # For films, these are using same url with series
229 video_id
= info
.get('slug') or info
['assets'][0]['slug']
230 return self
.url_result(
231 f
'https://puhutv.com/{video_id}-izle',
232 PuhuTVIE
.ie_key(), video_id
)