[puhutv] fixed as requested
This commit is contained in:
parent
b521306bb5
commit
09fa98fa4c
@ -7,10 +7,10 @@ from ..utils import (
|
|||||||
int_or_none,
|
int_or_none,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
parse_iso8601,
|
|
||||||
str_or_none,
|
str_or_none,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
urljoin,
|
unified_timestamp,
|
||||||
|
try_get,
|
||||||
url_basename,
|
url_basename,
|
||||||
remove_end
|
remove_end
|
||||||
)
|
)
|
||||||
@ -61,44 +61,41 @@ class PuhuTVIE(InfoExtractor):
|
|||||||
|
|
||||||
display_id = compat_str(info['id'])
|
display_id = compat_str(info['id'])
|
||||||
title = info['title']['name']
|
title = info['title']['name']
|
||||||
if(info.get('display_name') and title is not None):
|
if isinstance(info.get('display_name'), compat_str):
|
||||||
title += ' ' + info.get('display_name')
|
title = '%s %s' % (title, info.get('display_name'))
|
||||||
|
|
||||||
description = info.get('title', {}).get('description') or info.get('description')
|
description = try_get(info, lambda x: x['title']['description'], compat_str) or info.get('description')
|
||||||
timestamp = parse_iso8601(info.get('created_at'))
|
timestamp = unified_timestamp(info.get('created_at'))
|
||||||
upload_date = unified_strdate(info.get('created_at'))
|
upload_date = unified_strdate(info.get('created_at'))
|
||||||
uploader = info.get('title', {}).get('producer', {}).get('name')
|
uploader = try_get(info, lambda x: x['title']['producer']['name'], compat_str)
|
||||||
uploader_id = str_or_none(info.get('title', {}).get('producer', {}).get('id'))
|
uploader_id = str_or_none(try_get(info, lambda x: x['title']['producer']['id']))
|
||||||
view_count = int_or_none(info.get('content', {}).get('watch_count'))
|
view_count = int_or_none(try_get(info, lambda x: x['content']['watch_count']))
|
||||||
duration = float_or_none(info.get('content', {}).get('duration_in_ms'), scale=1000)
|
duration = float_or_none(try_get(info, lambda x: x['content']['duration_in_ms']), scale=1000)
|
||||||
thumbnail = urljoin('https://', info.get('content', {}).get('images', {}).get('wide', {}).get('main'))
|
thumbnail = try_get(info, lambda x: x['content']['images']['wide']['main'], compat_str)
|
||||||
release_year = int_or_none(info.get('title', {}).get('released_at'))
|
release_year = int_or_none(try_get(info, lambda x: x['title']['released_at']))
|
||||||
webpage_url = info.get('web_url')
|
webpage_url = info.get('web_url')
|
||||||
|
|
||||||
# for series
|
|
||||||
season_number = int_or_none(info.get('season_number'))
|
season_number = int_or_none(info.get('season_number'))
|
||||||
season_id = int_or_none(info.get('season_id'))
|
season_id = int_or_none(info.get('season_id'))
|
||||||
episode_number = int_or_none(info.get('episode_number'))
|
episode_number = int_or_none(info.get('episode_number'))
|
||||||
|
|
||||||
tags = []
|
tags = []
|
||||||
for tag in info.get('title', {}).get('genres', {}):
|
for tag in try_get(info, lambda x: x['title']['genres'], list) or []:
|
||||||
if isinstance(tag.get('name'), compat_str):
|
if isinstance(tag.get('name'), compat_str):
|
||||||
tags.append(tag.get('name'))
|
tags.append(tag.get('name'))
|
||||||
|
|
||||||
thumbnails = []
|
thumbnails = []
|
||||||
thumbs_dict = info.get('content', {}).get('images', {}).get('wide', {})
|
thumbs_dict = try_get(info, lambda x: x['content']['images']['wide'], dict) or {}
|
||||||
if isinstance(thumbs_dict, dict):
|
for id, url in thumbs_dict.items():
|
||||||
for id, url in thumbs_dict.items():
|
if not url or not isinstance(url, compat_str):
|
||||||
if not url or not isinstance(url, compat_str):
|
continue
|
||||||
continue
|
thumbnails.append({
|
||||||
url = urljoin('https://', url)
|
'url': 'https://%s' % url,
|
||||||
thumbnails.append({
|
'id': id
|
||||||
'url': url,
|
})
|
||||||
'id': id
|
|
||||||
})
|
|
||||||
|
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
for subtitle in info.get('content', {}).get('subtitles', {}):
|
for subtitle in try_get(info, lambda x: x['content']['subtitles'], list) or []:
|
||||||
if not isinstance(subtitle, dict):
|
if not isinstance(subtitle, dict):
|
||||||
continue
|
continue
|
||||||
lang = subtitle.get('language')
|
lang = subtitle.get('language')
|
||||||
@ -106,16 +103,13 @@ class PuhuTVIE(InfoExtractor):
|
|||||||
if not lang or not isinstance(lang, compat_str) or not sub_url or not isinstance(sub_url, compat_str):
|
if not lang or not isinstance(lang, compat_str) or not sub_url or not isinstance(sub_url, compat_str):
|
||||||
continue
|
continue
|
||||||
subtitles[self._SUBTITLE_LANGS.get(lang, lang)] = [{
|
subtitles[self._SUBTITLE_LANGS.get(lang, lang)] = [{
|
||||||
'url': sub_url,
|
'url': sub_url
|
||||||
'ext': determine_ext(sub_url)
|
|
||||||
}]
|
}]
|
||||||
|
|
||||||
# Some of videos are geo restricted upon request copyright owner and returns 403
|
# Some of videos are geo restricted upon request copyright owner and returns 403
|
||||||
req_formats = self._download_json(
|
req_formats = self._download_json(
|
||||||
'https://puhutv.com/api/assets/%s/videos' % display_id,
|
'https://puhutv.com/api/assets/%s/videos' % display_id,
|
||||||
video_id, 'Downloading video JSON', fatal=False)
|
video_id, 'Downloading video JSON')
|
||||||
if not req_formats:
|
|
||||||
self.raise_geo_restricted()
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for format in req_formats['data']['videos']:
|
for format in req_formats['data']['videos']:
|
||||||
@ -194,13 +188,12 @@ class PuhuTVSerieIE(InfoExtractor):
|
|||||||
pagenum = 1
|
pagenum = 1
|
||||||
has_more = True
|
has_more = True
|
||||||
while has_more is True:
|
while has_more is True:
|
||||||
query = {
|
|
||||||
'page': pagenum,
|
|
||||||
'per': 40,
|
|
||||||
}
|
|
||||||
season_info = self._download_json(
|
season_info = self._download_json(
|
||||||
'https://galadriel.puhutv.com/seasons/%s' % season_id,
|
'https://galadriel.puhutv.com/seasons/%s' % season_id,
|
||||||
playlist_id, 'Downloading season %s page %s' % (season_number, pagenum), query=query)
|
playlist_id, 'Downloading season %s page %s' % (season_number, pagenum), query={
|
||||||
|
'page': pagenum,
|
||||||
|
'per': 40,
|
||||||
|
})
|
||||||
for episode in season_info.get('episodes'):
|
for episode in season_info.get('episodes'):
|
||||||
video_id = episode['slugPath'].replace('-izle', '')
|
video_id = episode['slugPath'].replace('-izle', '')
|
||||||
yield self.url_result(
|
yield self.url_result(
|
||||||
@ -216,8 +209,8 @@ class PuhuTVSerieIE(InfoExtractor):
|
|||||||
'https://puhutv.com/api/slug/%s-detay' % playlist_id, playlist_id)['data']
|
'https://puhutv.com/api/slug/%s-detay' % playlist_id, playlist_id)['data']
|
||||||
|
|
||||||
title = info.get('name')
|
title = info.get('name')
|
||||||
uploader = info.get('producer', {}).get('name')
|
uploader = try_get(info, lambda x: x['producer']['name'], compat_str)
|
||||||
uploader_id = info.get('producer', {}).get('id')
|
uploader_id = try_get(info, lambda x: x['producer']['id'])
|
||||||
seasons = info.get('seasons')
|
seasons = info.get('seasons')
|
||||||
if seasons:
|
if seasons:
|
||||||
entries = self._extract_entries(playlist_id, seasons)
|
entries = self._extract_entries(playlist_id, seasons)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user