2018-04-25 01:02:38 +09:00
|
|
|
|
# coding: utf-8
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2018-07-22 22:25:46 +09:00
|
|
|
|
from ..compat import (
|
|
|
|
|
compat_HTTPError,
|
|
|
|
|
compat_str,
|
|
|
|
|
)
|
2018-04-25 01:02:38 +09:00
|
|
|
|
from ..utils import (
|
2018-07-22 22:25:46 +09:00
|
|
|
|
ExtractorError,
|
2018-04-25 01:02:38 +09:00
|
|
|
|
int_or_none,
|
|
|
|
|
float_or_none,
|
2018-07-22 22:25:46 +09:00
|
|
|
|
parse_resolution,
|
2018-04-25 01:02:38 +09:00
|
|
|
|
str_or_none,
|
|
|
|
|
try_get,
|
2018-07-22 22:25:46 +09:00
|
|
|
|
unified_timestamp,
|
|
|
|
|
url_or_none,
|
|
|
|
|
urljoin,
|
2018-04-25 01:02:38 +09:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PuhuTVIE(InfoExtractor):
|
2018-07-22 22:25:46 +09:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-izle'
|
2018-04-25 01:02:38 +09:00
|
|
|
|
IE_NAME = 'puhutv'
|
2018-07-22 22:25:46 +09:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
# film
|
|
|
|
|
'url': 'https://puhutv.com/sut-kardesler-izle',
|
2019-10-24 20:53:33 +09:00
|
|
|
|
'md5': 'a347470371d56e1585d1b2c8dab01c96',
|
2018-07-22 22:25:46 +09:00
|
|
|
|
'info_dict': {
|
|
|
|
|
'id': '5085',
|
|
|
|
|
'display_id': 'sut-kardesler',
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Süt Kardeşler',
|
2019-10-24 20:53:33 +09:00
|
|
|
|
'description': 'md5:ca09da25b7e57cbb5a9280d6e48d17aa',
|
2018-07-22 22:25:46 +09:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
|
'duration': 4832.44,
|
|
|
|
|
'creator': 'Arzu Film',
|
2019-10-24 20:53:33 +09:00
|
|
|
|
'timestamp': 1561062602,
|
|
|
|
|
'upload_date': '20190620',
|
2018-07-22 22:25:46 +09:00
|
|
|
|
'release_year': 1976,
|
|
|
|
|
'view_count': int,
|
2019-10-24 20:53:33 +09:00
|
|
|
|
'tags': list,
|
2018-04-25 01:02:38 +09:00
|
|
|
|
},
|
2018-07-22 22:25:46 +09:00
|
|
|
|
}, {
|
|
|
|
|
# episode, geo restricted, bypassable with --geo-verification-proxy
|
|
|
|
|
'url': 'https://puhutv.com/jet-sosyete-1-bolum-izle',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}, {
|
|
|
|
|
# 4k, with subtitles
|
|
|
|
|
'url': 'https://puhutv.com/dip-1-bolum-izle',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}]
|
2018-04-25 01:02:38 +09:00
|
|
|
|
_SUBTITLE_LANGS = {
|
|
|
|
|
'English': 'en',
|
|
|
|
|
'Deutsch': 'de',
|
|
|
|
|
'عربى': 'ar'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2018-07-22 22:25:46 +09:00
|
|
|
|
display_id = self._match_id(url)
|
|
|
|
|
|
2018-04-25 01:02:38 +09:00
|
|
|
|
info = self._download_json(
|
2018-07-22 22:25:46 +09:00
|
|
|
|
urljoin(url, '/api/slug/%s-izle' % display_id),
|
|
|
|
|
display_id)['data']
|
2018-04-25 01:02:38 +09:00
|
|
|
|
|
2018-07-22 22:25:46 +09:00
|
|
|
|
video_id = compat_str(info['id'])
|
2019-10-24 20:53:33 +09:00
|
|
|
|
show = info.get('title') or {}
|
|
|
|
|
title = info.get('name') or show['name']
|
2018-04-25 01:02:38 +09:00
|
|
|
|
if info.get('display_name'):
|
2019-10-24 20:53:33 +09:00
|
|
|
|
title = '%s %s' % (title, info['display_name'])
|
2018-04-25 01:02:38 +09:00
|
|
|
|
|
2018-07-22 22:25:46 +09:00
|
|
|
|
try:
|
|
|
|
|
videos = self._download_json(
|
|
|
|
|
'https://puhutv.com/api/assets/%s/videos' % video_id,
|
|
|
|
|
display_id, 'Downloading video JSON',
|
|
|
|
|
headers=self.geo_verification_headers())
|
|
|
|
|
except ExtractorError as e:
|
|
|
|
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
|
|
|
|
|
self.raise_geo_restricted()
|
|
|
|
|
raise
|
|
|
|
|
|
2019-10-24 20:53:33 +09:00
|
|
|
|
urls = []
|
2018-07-22 22:25:46 +09:00
|
|
|
|
formats = []
|
2019-10-24 20:53:33 +09:00
|
|
|
|
|
2018-07-22 22:25:46 +09:00
|
|
|
|
for video in videos['data']['videos']:
|
|
|
|
|
media_url = url_or_none(video.get('url'))
|
2019-10-24 20:53:33 +09:00
|
|
|
|
if not media_url or media_url in urls:
|
2018-07-22 22:25:46 +09:00
|
|
|
|
continue
|
2019-10-24 20:53:33 +09:00
|
|
|
|
urls.append(media_url)
|
|
|
|
|
|
2018-07-22 22:25:46 +09:00
|
|
|
|
playlist = video.get('is_playlist')
|
2019-10-24 20:53:33 +09:00
|
|
|
|
if (video.get('stream_type') == 'hls' and playlist is True) or 'playlist.m3u8' in media_url:
|
2020-05-04 23:15:19 +09:00
|
|
|
|
formats.extend(self._extract_m3u8_formats(
|
2018-07-22 22:25:46 +09:00
|
|
|
|
media_url, video_id, 'mp4', entry_protocol='m3u8_native',
|
2020-05-04 23:15:19 +09:00
|
|
|
|
m3u8_id='hls', fatal=False))
|
2018-07-22 22:25:46 +09:00
|
|
|
|
continue
|
2019-10-24 20:53:33 +09:00
|
|
|
|
|
2018-07-22 22:25:46 +09:00
|
|
|
|
quality = int_or_none(video.get('quality'))
|
|
|
|
|
f = {
|
|
|
|
|
'url': media_url,
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'height': quality
|
|
|
|
|
}
|
|
|
|
|
video_format = video.get('video_format')
|
2019-10-24 20:53:33 +09:00
|
|
|
|
is_hls = (video_format == 'hls' or '/hls/' in media_url or '/chunklist.m3u8' in media_url) and playlist is False
|
|
|
|
|
if is_hls:
|
2018-07-22 22:25:46 +09:00
|
|
|
|
format_id = 'hls'
|
|
|
|
|
f['protocol'] = 'm3u8_native'
|
|
|
|
|
elif video_format == 'mp4':
|
|
|
|
|
format_id = 'http'
|
|
|
|
|
else:
|
|
|
|
|
continue
|
|
|
|
|
if quality:
|
|
|
|
|
format_id += '-%sp' % quality
|
|
|
|
|
f['format_id'] = format_id
|
|
|
|
|
formats.append(f)
|
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
|
|
creator = try_get(
|
2019-10-24 20:53:33 +09:00
|
|
|
|
show, lambda x: x['producer']['name'], compat_str)
|
2018-07-22 22:25:46 +09:00
|
|
|
|
|
2019-10-24 20:53:33 +09:00
|
|
|
|
content = info.get('content') or {}
|
2018-07-22 22:25:46 +09:00
|
|
|
|
|
|
|
|
|
images = try_get(
|
2019-10-24 20:53:33 +09:00
|
|
|
|
content, lambda x: x['images']['wide'], dict) or {}
|
2018-07-22 22:25:46 +09:00
|
|
|
|
thumbnails = []
|
|
|
|
|
for image_id, image_url in images.items():
|
|
|
|
|
if not isinstance(image_url, compat_str):
|
|
|
|
|
continue
|
|
|
|
|
if not image_url.startswith(('http', '//')):
|
|
|
|
|
image_url = 'https://%s' % image_url
|
|
|
|
|
t = parse_resolution(image_id)
|
|
|
|
|
t.update({
|
|
|
|
|
'id': image_id,
|
|
|
|
|
'url': image_url
|
|
|
|
|
})
|
|
|
|
|
thumbnails.append(t)
|
|
|
|
|
|
2018-04-25 01:02:38 +09:00
|
|
|
|
tags = []
|
2019-10-24 20:53:33 +09:00
|
|
|
|
for genre in show.get('genres') or []:
|
2018-07-22 22:25:46 +09:00
|
|
|
|
if not isinstance(genre, dict):
|
2018-04-25 01:02:38 +09:00
|
|
|
|
continue
|
2018-07-22 22:25:46 +09:00
|
|
|
|
genre_name = genre.get('name')
|
|
|
|
|
if genre_name and isinstance(genre_name, compat_str):
|
|
|
|
|
tags.append(genre_name)
|
2018-04-25 01:02:38 +09:00
|
|
|
|
|
|
|
|
|
subtitles = {}
|
2019-10-24 20:53:33 +09:00
|
|
|
|
for subtitle in content.get('subtitles') or []:
|
2018-04-25 01:02:38 +09:00
|
|
|
|
if not isinstance(subtitle, dict):
|
|
|
|
|
continue
|
|
|
|
|
lang = subtitle.get('language')
|
2019-10-24 20:53:33 +09:00
|
|
|
|
sub_url = url_or_none(subtitle.get('url') or subtitle.get('file'))
|
2018-04-25 01:02:38 +09:00
|
|
|
|
if not lang or not isinstance(lang, compat_str) or not sub_url:
|
|
|
|
|
continue
|
|
|
|
|
subtitles[self._SUBTITLE_LANGS.get(lang, lang)] = [{
|
|
|
|
|
'url': sub_url
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'id': video_id,
|
|
|
|
|
'display_id': display_id,
|
|
|
|
|
'title': title,
|
2019-10-24 20:53:33 +09:00
|
|
|
|
'description': info.get('description') or show.get('description'),
|
|
|
|
|
'season_id': str_or_none(info.get('season_id')),
|
|
|
|
|
'season_number': int_or_none(info.get('season_number')),
|
|
|
|
|
'episode_number': int_or_none(info.get('episode_number')),
|
|
|
|
|
'release_year': int_or_none(show.get('released_at')),
|
|
|
|
|
'timestamp': unified_timestamp(info.get('created_at')),
|
2018-07-22 22:25:46 +09:00
|
|
|
|
'creator': creator,
|
2019-10-24 20:53:33 +09:00
|
|
|
|
'view_count': int_or_none(content.get('watch_count')),
|
|
|
|
|
'duration': float_or_none(content.get('duration_in_ms'), 1000),
|
2018-04-25 01:02:38 +09:00
|
|
|
|
'tags': tags,
|
|
|
|
|
'subtitles': subtitles,
|
|
|
|
|
'thumbnails': thumbnails,
|
|
|
|
|
'formats': formats
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PuhuTVSerieIE(InfoExtractor):
|
2018-07-22 22:25:46 +09:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[^/?#&]+)-detay'
|
2018-04-25 01:02:38 +09:00
|
|
|
|
IE_NAME = 'puhutv:serie'
|
2018-07-22 22:25:46 +09:00
|
|
|
|
_TESTS = [{
|
|
|
|
|
'url': 'https://puhutv.com/deniz-yildizi-detay',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'title': 'Deniz Yıldızı',
|
|
|
|
|
'id': 'deniz-yildizi',
|
2018-04-25 01:02:38 +09:00
|
|
|
|
},
|
2018-07-22 22:25:46 +09:00
|
|
|
|
'playlist_mincount': 205,
|
|
|
|
|
}, {
|
|
|
|
|
# a film detail page which is using same url with serie page
|
|
|
|
|
'url': 'https://puhutv.com/kaybedenler-kulubu-detay',
|
|
|
|
|
'only_matching': True,
|
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
def _extract_entries(self, seasons):
|
2018-04-25 01:02:38 +09:00
|
|
|
|
for season in seasons:
|
2018-07-22 22:25:46 +09:00
|
|
|
|
season_id = season.get('id')
|
|
|
|
|
if not season_id:
|
|
|
|
|
continue
|
|
|
|
|
page = 1
|
2018-04-25 01:02:38 +09:00
|
|
|
|
has_more = True
|
|
|
|
|
while has_more is True:
|
2018-07-22 22:25:46 +09:00
|
|
|
|
season = self._download_json(
|
2018-04-25 01:02:38 +09:00
|
|
|
|
'https://galadriel.puhutv.com/seasons/%s' % season_id,
|
2018-07-22 22:25:46 +09:00
|
|
|
|
season_id, 'Downloading page %s' % page, query={
|
|
|
|
|
'page': page,
|
2018-04-25 01:02:38 +09:00
|
|
|
|
'per': 40,
|
|
|
|
|
})
|
2018-07-22 22:25:46 +09:00
|
|
|
|
episodes = season.get('episodes')
|
|
|
|
|
if isinstance(episodes, list):
|
|
|
|
|
for ep in episodes:
|
|
|
|
|
slug_path = str_or_none(ep.get('slugPath'))
|
|
|
|
|
if not slug_path:
|
|
|
|
|
continue
|
|
|
|
|
video_id = str_or_none(int_or_none(ep.get('id')))
|
|
|
|
|
yield self.url_result(
|
|
|
|
|
'https://puhutv.com/%s' % slug_path,
|
|
|
|
|
ie=PuhuTVIE.ie_key(), video_id=video_id,
|
|
|
|
|
video_title=ep.get('name') or ep.get('eventLabel'))
|
|
|
|
|
page += 1
|
|
|
|
|
has_more = season.get('hasMore')
|
2018-04-25 01:02:38 +09:00
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
playlist_id = self._match_id(url)
|
|
|
|
|
|
|
|
|
|
info = self._download_json(
|
2018-07-22 22:25:46 +09:00
|
|
|
|
urljoin(url, '/api/slug/%s-detay' % playlist_id),
|
|
|
|
|
playlist_id)['data']
|
2018-04-25 01:02:38 +09:00
|
|
|
|
|
|
|
|
|
seasons = info.get('seasons')
|
|
|
|
|
if seasons:
|
2018-07-22 22:25:46 +09:00
|
|
|
|
return self.playlist_result(
|
|
|
|
|
self._extract_entries(seasons), playlist_id, info.get('name'))
|
|
|
|
|
|
|
|
|
|
# For films, these are using same url with series
|
|
|
|
|
video_id = info.get('slug') or info['assets'][0]['slug']
|
|
|
|
|
return self.url_result(
|
|
|
|
|
'https://puhutv.com/%s-izle' % video_id,
|
|
|
|
|
PuhuTVIE.ie_key(), video_id)
|