2018-04-24 19:02:38 +03:00
|
|
|
|
# coding: utf-8
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2018-04-30 19:02:20 +03:00
|
|
|
|
from ..compat import compat_str
|
2018-04-24 21:27:51 +03:00
|
|
|
|
from ..utils import (
|
|
|
|
|
int_or_none,
|
2018-04-27 18:11:36 +03:00
|
|
|
|
float_or_none,
|
|
|
|
|
determine_ext
|
2018-04-24 21:27:51 +03:00
|
|
|
|
)
|
2018-04-24 19:02:38 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PuhuTVIE(InfoExtractor):
|
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[a-z0-9-]+)-izle'
|
|
|
|
|
_TESTS = [
|
2018-05-01 15:33:54 +03:00
|
|
|
|
{ # A Film
|
2018-04-24 19:02:38 +03:00
|
|
|
|
'url': 'https://puhutv.com/sut-kardesler-izle',
|
2018-04-29 19:58:10 +03:00
|
|
|
|
'md5': 'a347470371d56e1585d1b2c8dab01c96',
|
2018-04-24 19:02:38 +03:00
|
|
|
|
'info_dict': {
|
2018-04-29 20:14:53 +03:00
|
|
|
|
'id': 'sut-kardesler',
|
|
|
|
|
'display_id': '5085',
|
2018-04-24 19:02:38 +03:00
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Süt Kardeşler',
|
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
|
'uploader': 'Arzu Film',
|
|
|
|
|
'description': 'md5:405fd024df916ca16731114eb18e511a',
|
2018-04-24 21:27:51 +03:00
|
|
|
|
'uploader_id': '43',
|
|
|
|
|
'upload_date': '20160729',
|
2018-04-24 19:02:38 +03:00
|
|
|
|
},
|
|
|
|
|
},
|
2018-05-01 15:33:54 +03:00
|
|
|
|
{ # An Episode and geo restricted
|
2018-04-24 19:02:38 +03:00
|
|
|
|
'url': 'https://puhutv.com/jet-sosyete-1-bolum-izle',
|
2018-04-29 19:58:10 +03:00
|
|
|
|
'md5': '3cd1f4b931cff5e009dfa46a3b88a42a',
|
2018-04-24 21:27:51 +03:00
|
|
|
|
'info_dict': {
|
2018-04-29 20:14:53 +03:00
|
|
|
|
'id': 'jet-sosyete-1-bolum',
|
|
|
|
|
'display_id': '18501',
|
2018-04-24 21:27:51 +03:00
|
|
|
|
'ext': 'mp4',
|
2018-04-24 21:38:37 +03:00
|
|
|
|
'title': 'Jet Sosyete 1. Sezon 1. Bölüm',
|
2018-04-24 21:27:51 +03:00
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
2018-04-24 21:38:37 +03:00
|
|
|
|
'uploader': 'BKM',
|
2018-05-01 15:23:31 +03:00
|
|
|
|
'description': 'md5:18ba5abe6d19f8063a8348445c41e28f',
|
2018-04-24 21:38:37 +03:00
|
|
|
|
'uploader_id': '269',
|
|
|
|
|
'upload_date': '20180220',
|
2018-04-24 21:27:51 +03:00
|
|
|
|
},
|
2018-04-27 18:11:36 +03:00
|
|
|
|
},
|
2018-05-01 15:33:54 +03:00
|
|
|
|
{ # Has subtitle
|
2018-04-27 18:11:36 +03:00
|
|
|
|
'url': 'https://puhutv.com/dip-1-bolum-izle',
|
2018-04-29 19:58:10 +03:00
|
|
|
|
'md5': 'f27792b1169f42ab318c38887ad5b28e',
|
2018-04-27 18:11:36 +03:00
|
|
|
|
'info_dict': {
|
2018-04-29 20:14:53 +03:00
|
|
|
|
'id': 'dip-1-bolum',
|
|
|
|
|
'display_id': '18944',
|
2018-04-27 18:11:36 +03:00
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
'title': 'Dip 1. Sezon 1. Bölüm',
|
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
|
'uploader': 'TMC',
|
2018-05-01 15:23:31 +03:00
|
|
|
|
'description': 'md5:e8ddb56738b093b4eae0a536e2ea02c2',
|
2018-04-27 18:11:36 +03:00
|
|
|
|
'uploader_id': '25',
|
|
|
|
|
'upload_date': '20180330',
|
|
|
|
|
},
|
|
|
|
|
'params': {
|
|
|
|
|
'skip_download': True,
|
|
|
|
|
}
|
2018-04-24 19:02:38 +03:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
IE_NAME = 'puhutv'
|
2018-05-01 15:33:54 +03:00
|
|
|
|
_SUBTITLE_LANGS = { # currently supported for some series
|
|
|
|
|
'English': 'en',
|
|
|
|
|
'Deutsch': 'de',
|
|
|
|
|
'عربى': 'ar'
|
2018-04-27 18:11:36 +03:00
|
|
|
|
}
|
2018-04-24 19:02:38 +03:00
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
video_id = self._match_id(url)
|
2018-05-01 15:23:31 +03:00
|
|
|
|
# API call
|
2018-04-24 19:02:38 +03:00
|
|
|
|
info = self._download_json(
|
|
|
|
|
'https://puhutv.com/api/slug/%s-izle' % video_id,
|
2018-05-01 20:58:03 +03:00
|
|
|
|
video_id)
|
2018-04-24 19:02:38 +03:00
|
|
|
|
|
2018-05-01 15:23:31 +03:00
|
|
|
|
info = info.get('data')
|
2018-04-29 20:14:53 +03:00
|
|
|
|
display_id = compat_str(info.get('id'))
|
2018-05-01 15:23:31 +03:00
|
|
|
|
title = info.get('title', {}).get('name')
|
|
|
|
|
if(info.get('display_name') and title is not None):
|
2018-04-24 19:02:38 +03:00
|
|
|
|
title += ' ' + info.get('display_name')
|
2018-05-01 15:23:31 +03:00
|
|
|
|
description = info.get('title', {}).get('description')
|
|
|
|
|
|
|
|
|
|
upload_date = info.get('created_at', '').split('T')[0].replace('-', '')
|
|
|
|
|
if upload_date is '':
|
|
|
|
|
upload_date = None
|
|
|
|
|
uploader = info.get('title', {}).get('producer', {}).get('name')
|
|
|
|
|
uploader_id = info.get('title', {}).get('producer', {}).get('id')
|
|
|
|
|
if uploader_id is not None:
|
|
|
|
|
uploader_id = compat_str(uploader_id)
|
|
|
|
|
view_count = int_or_none(info.get('content', {}).get('watch_count'))
|
|
|
|
|
duration = float_or_none(info.get('content', {}).get('duration_in_ms'), scale=1000)
|
|
|
|
|
thumbnail = 'https://%s' % info.get('content', {}).get('images', {}).get('wide', {}).get('main')
|
|
|
|
|
release_year = int_or_none(info.get('title', {}).get('released_at'))
|
2018-04-24 21:27:51 +03:00
|
|
|
|
webpage_url = info.get('web_url')
|
2018-05-01 15:23:31 +03:00
|
|
|
|
tags_list = info.get('title', {}).get('genres', {})
|
|
|
|
|
thumbnails_list = info.get('content', {}).get('images', {}).get('wide', {})
|
|
|
|
|
subtitles_list = info.get('content', {}).get('subtitles', {})
|
2018-04-24 21:27:51 +03:00
|
|
|
|
|
|
|
|
|
# for series
|
|
|
|
|
season_number = int_or_none(info.get('season_number'))
|
|
|
|
|
season_id = int_or_none(info.get('season_id'))
|
|
|
|
|
episode_number = int_or_none(info.get('episode_number'))
|
|
|
|
|
|
|
|
|
|
tags = []
|
2018-05-01 15:23:31 +03:00
|
|
|
|
for tag in tags_list:
|
2018-05-09 17:27:14 +03:00
|
|
|
|
if tag.get('name'):
|
|
|
|
|
tags.append(tag.get('name'))
|
2018-04-24 19:02:38 +03:00
|
|
|
|
|
|
|
|
|
thumbnails = []
|
2018-05-01 15:33:54 +03:00
|
|
|
|
for id, url in thumbnails_list.items():
|
2018-04-24 19:02:38 +03:00
|
|
|
|
thumbnails.append({
|
2018-05-01 15:23:31 +03:00
|
|
|
|
'url': url,
|
|
|
|
|
'id': id
|
2018-04-24 19:02:38 +03:00
|
|
|
|
})
|
|
|
|
|
|
2018-04-27 18:11:36 +03:00
|
|
|
|
subtitles = {}
|
2018-05-01 15:23:31 +03:00
|
|
|
|
for subtitle in subtitles_list:
|
2018-04-27 18:11:36 +03:00
|
|
|
|
lang = subtitle.get('language')
|
|
|
|
|
sub_url = subtitle.get('url')
|
2018-05-09 17:27:14 +03:00
|
|
|
|
# If the keys were changed by api, continue
|
|
|
|
|
if not lang or not sub_url:
|
|
|
|
|
continue
|
2018-04-27 18:11:36 +03:00
|
|
|
|
subtitles[self._SUBTITLE_LANGS.get(lang, lang)] = [{
|
|
|
|
|
'url': sub_url,
|
|
|
|
|
'ext': determine_ext(sub_url)
|
|
|
|
|
}]
|
|
|
|
|
|
2018-05-09 17:27:14 +03:00
|
|
|
|
# Some of videos are geo restricted upon request copyright owner and returns 403
|
|
|
|
|
req_formats = self._download_json(
|
2018-04-29 20:14:53 +03:00
|
|
|
|
'https://puhutv.com/api/assets/%s/videos' % display_id,
|
2018-05-09 17:27:14 +03:00
|
|
|
|
video_id, 'Downloading video JSON')
|
|
|
|
|
if not req_formats:
|
2018-05-01 15:23:31 +03:00
|
|
|
|
self.raise_geo_restricted()
|
2018-05-09 17:27:14 +03:00
|
|
|
|
else:
|
|
|
|
|
format_dict = req_formats.get('data').get('videos')
|
2018-04-24 19:02:38 +03:00
|
|
|
|
|
|
|
|
|
formats = []
|
|
|
|
|
for format in format_dict:
|
|
|
|
|
media_url = format.get('url')
|
2018-05-09 17:27:14 +03:00
|
|
|
|
ext = format.get('video_format') or determine_ext(media_url)
|
2018-04-24 19:02:38 +03:00
|
|
|
|
quality = format.get('quality')
|
2018-05-01 15:33:54 +03:00
|
|
|
|
if ext == 'mp4' and format.get('is_playlist') is False:
|
2018-04-29 19:58:10 +03:00
|
|
|
|
formats.append({
|
|
|
|
|
'url': media_url,
|
|
|
|
|
'format_id': 'http-%s' % quality,
|
|
|
|
|
'ext': ext
|
|
|
|
|
})
|
2018-04-24 19:02:38 +03:00
|
|
|
|
|
|
|
|
|
return {
|
2018-04-29 20:14:53 +03:00
|
|
|
|
'id': video_id,
|
|
|
|
|
'display_id': display_id,
|
2018-04-24 19:02:38 +03:00
|
|
|
|
'title': title,
|
2018-04-24 21:27:51 +03:00
|
|
|
|
'description': description,
|
|
|
|
|
'season_id': season_id,
|
|
|
|
|
'season_number': season_number,
|
|
|
|
|
'episode_number': episode_number,
|
|
|
|
|
'release_year': release_year,
|
|
|
|
|
'upload_date': upload_date,
|
|
|
|
|
'uploader': uploader,
|
|
|
|
|
'uploader_id': uploader_id,
|
|
|
|
|
'view_count': view_count,
|
|
|
|
|
'duration': duration,
|
|
|
|
|
'tags': tags,
|
2018-04-27 18:11:36 +03:00
|
|
|
|
'subtitles': subtitles,
|
2018-04-24 21:27:51 +03:00
|
|
|
|
'webpage_url': webpage_url,
|
|
|
|
|
'thumbnail': thumbnail,
|
2018-04-24 19:02:38 +03:00
|
|
|
|
'thumbnails': thumbnails,
|
|
|
|
|
'formats': formats
|
|
|
|
|
}
|
2018-04-30 19:02:20 +03:00
|
|
|
|
|
|
|
|
|
|
2018-05-01 15:23:31 +03:00
|
|
|
|
class PuhuTVSerieIE(InfoExtractor):
|
2018-04-30 19:02:20 +03:00
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?puhutv\.com/(?P<id>[a-z0-9-]+)-detay'
|
2018-05-01 15:23:31 +03:00
|
|
|
|
IE_NAME = 'puhutv:serie'
|
|
|
|
|
_TESTS = [
|
|
|
|
|
{
|
|
|
|
|
'url': 'https://puhutv.com/deniz-yildizi-detay',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'title': 'Deniz Yıldızı',
|
|
|
|
|
'id': 'deniz-yildizi',
|
|
|
|
|
'uploader': 'Focus Film',
|
|
|
|
|
'uploader_id': 61,
|
|
|
|
|
},
|
|
|
|
|
'playlist_mincount': 10,
|
2018-04-30 19:02:20 +03:00
|
|
|
|
},
|
2018-05-01 15:33:54 +03:00
|
|
|
|
{ # a film detail page which is using same url with serie page
|
2018-05-01 15:23:31 +03:00
|
|
|
|
'url': 'https://puhutv.com/kaybedenler-kulubu-detay',
|
|
|
|
|
'info_dict': {
|
|
|
|
|
'title': 'Kaybedenler Kulübü',
|
|
|
|
|
'id': 'kaybedenler-kulubu',
|
|
|
|
|
'uploader': 'Tolga Örnek, Murat Dörtbudak, Neslihan Dörtbudak, Kemal Kaplanoğlu',
|
|
|
|
|
'uploader_id': 248,
|
|
|
|
|
},
|
|
|
|
|
'playlist_mincount': 1,
|
|
|
|
|
},
|
|
|
|
|
]
|
2018-04-30 19:02:20 +03:00
|
|
|
|
|
|
|
|
|
def _extract_entries(self, playlist_id, seasons):
|
|
|
|
|
for season in seasons:
|
|
|
|
|
season_id = season.get('id')
|
|
|
|
|
season_number = season.get('position')
|
|
|
|
|
pagenum = 1
|
|
|
|
|
has_more = True
|
2018-05-01 15:33:54 +03:00
|
|
|
|
while has_more is True:
|
2018-04-30 19:02:20 +03:00
|
|
|
|
query = {
|
|
|
|
|
'page': pagenum,
|
|
|
|
|
'per': 40,
|
|
|
|
|
}
|
|
|
|
|
season_info = self._download_json(
|
|
|
|
|
'https://galadriel.puhutv.com/seasons/%s' % season_id,
|
2018-05-01 15:33:54 +03:00
|
|
|
|
playlist_id, 'Downloading season %s page %s' % (season_number, pagenum), query=query)
|
2018-04-30 19:02:20 +03:00
|
|
|
|
for episode in season_info.get('episodes'):
|
|
|
|
|
video_id = episode.get('slugPath').replace('-izle', '')
|
|
|
|
|
yield self.url_result(
|
|
|
|
|
'https://puhutv.com/%s-izle' % video_id,
|
|
|
|
|
PuhuTVIE.ie_key(), video_id)
|
|
|
|
|
pagenum = pagenum + 1
|
2018-05-09 17:27:14 +03:00
|
|
|
|
has_more = season_info.get('hasMore', False)
|
2018-04-30 19:02:20 +03:00
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
|
playlist_id = self._match_id(url)
|
|
|
|
|
|
|
|
|
|
info = self._download_json(
|
|
|
|
|
'https://puhutv.com/api/slug/%s-detay' % playlist_id,
|
2018-05-01 15:33:54 +03:00
|
|
|
|
playlist_id).get('data')
|
2018-04-30 19:02:20 +03:00
|
|
|
|
|
|
|
|
|
title = info.get('name')
|
2018-05-01 15:23:31 +03:00
|
|
|
|
uploader = info.get('producer', {}).get('name')
|
|
|
|
|
uploader_id = info.get('producer', {}).get('id')
|
2018-04-30 19:02:20 +03:00
|
|
|
|
seasons = info.get('seasons')
|
2018-05-01 15:23:31 +03:00
|
|
|
|
if seasons:
|
|
|
|
|
entries = self._extract_entries(playlist_id, seasons)
|
|
|
|
|
else:
|
|
|
|
|
# For films, these are using same url with series
|
|
|
|
|
video_id = info.get('assets')[0].get('slug')
|
|
|
|
|
return self.url_result(
|
|
|
|
|
'https://puhutv.com/%s-izle' % video_id,
|
|
|
|
|
PuhuTVIE.ie_key(), video_id)
|
2018-04-30 19:02:20 +03:00
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'_type': 'playlist',
|
|
|
|
|
'id': playlist_id,
|
|
|
|
|
'title': title,
|
|
|
|
|
'uploader': uploader,
|
|
|
|
|
'uploader_id': uploader_id,
|
2018-05-01 15:23:31 +03:00
|
|
|
|
'entries': entries,
|
2018-04-30 19:02:20 +03:00
|
|
|
|
}
|