]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/puhutv.py
1 from .common
import InfoExtractor
19 class PuhuTVIE(InfoExtractor
):
20 _VALID_URL
= r
'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-izle'
24 'url': 'https://puhutv.com/sut-kardesler-izle',
25 'md5': 'a347470371d56e1585d1b2c8dab01c96',
28 'display_id': 'sut-kardesler',
30 'title': 'Süt Kardeşler',
31 'description': 'md5:ca09da25b7e57cbb5a9280d6e48d17aa',
32 'thumbnail': r
're:^https?://.*\.jpg$',
34 'creator': 'Arzu Film',
35 'timestamp': 1561062602,
36 'upload_date': '20190620',
42 # episode, geo restricted, bypassable with --geo-verification-proxy
43 'url': 'https://puhutv.com/jet-sosyete-1-bolum-izle',
44 'only_matching': True,
47 'url': 'https://puhutv.com/dip-1-bolum-izle',
48 'only_matching': True,
56 def _real_extract(self
, url
):
57 display_id
= self
._match
_id
(url
)
59 info
= self
._download
_json
(
60 urljoin(url
, '/api/slug/%s-izle' % display_id
),
63 video_id
= compat_str(info
['id'])
64 show
= info
.get('title') or {}
65 title
= info
.get('name') or show
['name']
66 if info
.get('display_name'):
67 title
= '%s %s' % (title
, info
['display_name'])
70 videos
= self
._download
_json
(
71 'https://puhutv.com/api/assets/%s/videos' % video_id
,
72 display_id
, 'Downloading video JSON',
73 headers
=self
.geo_verification_headers())
74 except ExtractorError
as e
:
75 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
76 self
.raise_geo_restricted()
82 for video
in videos
['data']['videos']:
83 media_url
= url_or_none(video
.get('url'))
84 if not media_url
or media_url
in urls
:
86 urls
.append(media_url
)
88 playlist
= video
.get('is_playlist')
89 if (video
.get('stream_type') == 'hls' and playlist
is True) or 'playlist.m3u8' in media_url
:
90 formats
.extend(self
._extract
_m
3u8_formats
(
91 media_url
, video_id
, 'mp4', entry_protocol
='m3u8_native',
92 m3u8_id
='hls', fatal
=False))
95 quality
= int_or_none(video
.get('quality'))
101 video_format
= video
.get('video_format')
102 is_hls
= (video_format
== 'hls' or '/hls/' in media_url
or '/chunklist.m3u8' in media_url
) and playlist
is False
105 f
['protocol'] = 'm3u8_native'
106 elif video_format
== 'mp4':
111 format_id
+= '-%sp' % quality
112 f
['format_id'] = format_id
116 show
, lambda x
: x
['producer']['name'], compat_str
)
118 content
= info
.get('content') or {}
121 content
, lambda x
: x
['images']['wide'], dict) or {}
123 for image_id
, image_url
in images
.items():
124 if not isinstance(image_url
, compat_str
):
126 if not image_url
.startswith(('http', '//')):
127 image_url
= 'https://%s' % image_url
128 t
= parse_resolution(image_id
)
136 for genre
in show
.get('genres') or []:
137 if not isinstance(genre
, dict):
139 genre_name
= genre
.get('name')
140 if genre_name
and isinstance(genre_name
, compat_str
):
141 tags
.append(genre_name
)
144 for subtitle
in content
.get('subtitles') or []:
145 if not isinstance(subtitle
, dict):
147 lang
= subtitle
.get('language')
148 sub_url
= url_or_none(subtitle
.get('url') or subtitle
.get('file'))
149 if not lang
or not isinstance(lang
, compat_str
) or not sub_url
:
151 subtitles
[self
._SUBTITLE
_LANGS
.get(lang
, lang
)] = [{
157 'display_id': display_id
,
159 'description': info
.get('description') or show
.get('description'),
160 'season_id': str_or_none(info
.get('season_id')),
161 'season_number': int_or_none(info
.get('season_number')),
162 'episode_number': int_or_none(info
.get('episode_number')),
163 'release_year': int_or_none(show
.get('released_at')),
164 'timestamp': unified_timestamp(info
.get('created_at')),
166 'view_count': int_or_none(content
.get('watch_count')),
167 'duration': float_or_none(content
.get('duration_in_ms'), 1000),
169 'subtitles': subtitles
,
170 'thumbnails': thumbnails
,
175 class PuhuTVSerieIE(InfoExtractor
):
176 _VALID_URL
= r
'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-detay'
177 IE_NAME
= 'puhutv:serie'
179 'url': 'https://puhutv.com/deniz-yildizi-detay',
181 'title': 'Deniz Yıldızı',
182 'id': 'deniz-yildizi',
184 'playlist_mincount': 205,
186 # a film detail page which is using same url with serie page
187 'url': 'https://puhutv.com/kaybedenler-kulubu-detay',
188 'only_matching': True,
191 def _extract_entries(self
, seasons
):
192 for season
in seasons
:
193 season_id
= season
.get('id')
198 while has_more
is True:
199 season
= self
._download
_json
(
200 'https://galadriel.puhutv.com/seasons/%s' % season_id
,
201 season_id
, 'Downloading page %s' % page
, query
={
205 episodes
= season
.get('episodes')
206 if isinstance(episodes
, list):
208 slug_path
= str_or_none(ep
.get('slugPath'))
211 video_id
= str_or_none(int_or_none(ep
.get('id')))
212 yield self
.url_result(
213 'https://puhutv.com/%s' % slug_path
,
214 ie
=PuhuTVIE
.ie_key(), video_id
=video_id
,
215 video_title
=ep
.get('name') or ep
.get('eventLabel'))
217 has_more
= season
.get('hasMore')
219 def _real_extract(self
, url
):
220 playlist_id
= self
._match
_id
(url
)
222 info
= self
._download
_json
(
223 urljoin(url
, '/api/slug/%s-detay' % playlist_id
),
226 seasons
= info
.get('seasons')
228 return self
.playlist_result(
229 self
._extract
_entries
(seasons
), playlist_id
, info
.get('name'))
231 # For films, these are using same url with series
232 video_id
= info
.get('slug') or info
['assets'][0]['slug']
233 return self
.url_result(
234 'https://puhutv.com/%s-izle' % video_id
,
235 PuhuTVIE
.ie_key(), video_id
)