2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..compat import compat_str
20 class PuhuTVIE(InfoExtractor):
21 _VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[a-z0-9-]+)-izle'
26 'url': 'https://puhutv.com/sut-kardesler-izle',
27 'md5': 'a347470371d56e1585d1b2c8dab01c96',
29 'id': 'sut-kardesler',
32 'title': 'Süt Kardeşler',
33 'thumbnail': r're:^https?://.*\.jpg$',
34 'uploader': 'Arzu Film',
35 'description': 'md5:405fd024df916ca16731114eb18e511a',
37 'upload_date': '20160729',
42 # An Episode and geo restricted
43 'url': 'https://puhutv.com/jet-sosyete-1-bolum-izle',
44 'only_matching': True,
48 'url': 'https://puhutv.com/dip-1-bolum-izle',
49 'only_matching': True,
58 def _real_extract(self, url):
59 video_id = self._match_id(url)
60 info = self._download_json(
61 'https://puhutv.com/api/slug/%s-izle' % video_id, video_id)['data']
63 display_id = compat_str(info['id'])
64 title = info['title']['name']
65 if info.get('display_name'):
66 title = '%s %s' % (title, info.get('display_name'))
68 description = try_get(info, lambda x: x['title']['description'], compat_str) or info.get('description')
69 timestamp = unified_timestamp(info.get('created_at'))
70 upload_date = unified_strdate(info.get('created_at'))
71 uploader = try_get(info, lambda x: x['title']['producer']['name'], compat_str)
72 uploader_id = str_or_none(try_get(info, lambda x: x['title']['producer']['id']))
73 view_count = int_or_none(try_get(info, lambda x: x['content']['watch_count']))
74 duration = float_or_none(try_get(info, lambda x: x['content']['duration_in_ms']), scale=1000)
75 thumbnail = try_get(info, lambda x: x['content']['images']['wide']['main'], compat_str)
76 release_year = int_or_none(try_get(info, lambda x: x['title']['released_at']))
77 webpage_url = info.get('web_url')
79 season_number = int_or_none(info.get('season_number'))
80 season_id = int_or_none(info.get('season_id'))
81 episode_number = int_or_none(info.get('episode_number'))
84 for tag in try_get(info, lambda x: x['title']['genres'], list) or []:
85 if isinstance(tag.get('name'), compat_str):
86 tags.append(tag.get('name'))
89 thumbs_dict = try_get(info, lambda x: x['content']['images']['wide'], dict) or {}
90 for id, url in thumbs_dict.items():
91 if not url_or_none(url):
94 'url': 'https://%s' % url,
99 for subtitle in try_get(info, lambda x: x['content']['subtitles'], list) or []:
100 if not isinstance(subtitle, dict):
102 lang = subtitle.get('language')
103 sub_url = url_or_none(subtitle.get('url'))
104 if not lang or not isinstance(lang, compat_str) or not sub_url:
106 subtitles[self._SUBTITLE_LANGS.get(lang, lang)] = [{
110 # Some of videos are geo restricted upon request copyright owner and returns 403
111 req_formats = self._download_json(
112 'https://puhutv.com/api/assets/%s/videos' % display_id,
113 video_id, 'Downloading video JSON')
116 for format in req_formats['data']['videos']:
117 media_url = url_or_none(format.get('url'))
120 ext = format.get('video_format') or determine_ext(media_url)
121 quality = format.get('quality')
122 if format.get('stream_type') == 'hls' and format.get('is_playlist') is True:
123 m3u8_id = remove_end(url_basename(media_url), '.m3u8')
124 formats.append(self._m3u8_meta_format(media_url, ext, m3u8_id=m3u8_id))
125 elif ext == 'mp4' and format.get('is_playlist', False) is False:
128 'format_id': 'http-%s' % quality,
132 self._sort_formats(formats)
136 'display_id': display_id,
138 'description': description,
139 'season_id': season_id,
140 'season_number': season_number,
141 'episode_number': episode_number,
142 'release_year': release_year,
143 'upload_date': upload_date,
144 'timestamp': timestamp,
145 'uploader': uploader,
146 'uploader_id': uploader_id,
147 'view_count': view_count,
148 'duration': duration,
150 'subtitles': subtitles,
151 'webpage_url': webpage_url,
152 'thumbnail': thumbnail,
153 'thumbnails': thumbnails,
158 class PuhuTVSerieIE(InfoExtractor):
159 _VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[a-z0-9-]+)-detay'
160 IE_NAME = 'puhutv:serie'
163 'url': 'https://puhutv.com/deniz-yildizi-detay',
165 'title': 'Deniz Yıldızı',
166 'id': 'deniz-yildizi',
167 'uploader': 'Focus Film',
170 'playlist_mincount': 234,
173 # a film detail page which is using same url with serie page
174 'url': 'https://puhutv.com/kaybedenler-kulubu-detay',
176 'title': 'Kaybedenler Kulübü',
177 'id': 'kaybedenler-kulubu',
178 'uploader': 'Tolga Örnek, Murat Dörtbudak, Neslihan Dörtbudak, Kemal Kaplanoğlu',
181 'playlist_mincount': 1,
185 def _extract_entries(self, playlist_id, seasons):
186 for season in seasons:
187 season_id = season['id']
188 season_number = season.get('position')
191 while has_more is True:
192 season_info = self._download_json(
193 'https://galadriel.puhutv.com/seasons/%s' % season_id,
194 playlist_id, 'Downloading season %s page %s' % (season_number, pagenum), query={
198 for episode in season_info.get('episodes'):
199 video_id = episode['slugPath'].replace('-izle', '')
200 yield self.url_result(
201 'https://puhutv.com/%s-izle' % video_id,
202 PuhuTVIE.ie_key(), video_id)
203 pagenum = pagenum + 1
204 has_more = season_info.get('hasMore', False)
206 def _real_extract(self, url):
207 playlist_id = self._match_id(url)
209 info = self._download_json(
210 'https://puhutv.com/api/slug/%s-detay' % playlist_id, playlist_id)['data']
212 title = info.get('name')
213 uploader = try_get(info, lambda x: x['producer']['name'], compat_str)
214 uploader_id = try_get(info, lambda x: x['producer']['id'])
215 seasons = info.get('seasons')
217 entries = self._extract_entries(playlist_id, seasons)
219 # For films, these are using same url with series
220 video_id = info['assets'][0]['slug']
221 return self.url_result(
222 'https://puhutv.com/%s-izle' % video_id,
223 PuhuTVIE.ie_key(), video_id)
229 'uploader': uploader,
230 'uploader_id': uploader_id,