mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-02-19 08:30:29 +00:00
[viu:ott] handle preview duration limit param
This commit is contained in:
parent
1e0f4c3460
commit
3253c8e877
@ -7,6 +7,7 @@ from .common import InfoExtractor
|
|||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_kwargs,
|
compat_kwargs,
|
||||||
compat_str,
|
compat_str,
|
||||||
|
compat_urlparse,
|
||||||
)
|
)
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
@ -227,21 +228,43 @@ class ViuOTTIE(InfoExtractor):
|
|||||||
if not video_data:
|
if not video_data:
|
||||||
raise ExtractorError('This video is not available in your region.', expected=True)
|
raise ExtractorError('This video is not available in your region.', expected=True)
|
||||||
|
|
||||||
stream_data = self._download_json(
|
duration_limit = False
|
||||||
'https://d1k2us671qcoau.cloudfront.net/distribute_web_%s.php' % country_code,
|
query = {
|
||||||
video_id, 'Downloading stream info', query={
|
'ccs_product_id': video_data['ccs_product_id'],
|
||||||
'ccs_product_id': video_data['ccs_product_id'],
|
'language_flag_id': self._LANGUAGE_FLAG.get(lang_code.lower()) or '3',
|
||||||
'language_flag_id': self._LANGUAGE_FLAG.get(lang_code.lower()) or '3',
|
}
|
||||||
}, headers={
|
headers = {
|
||||||
'Referer': url,
|
'Referer': re.search(r'https?://[^/]+', url).group(0),
|
||||||
'Origin': re.search(r'https?://[^/]+', url).group(0),
|
'Origin': re.search(r'https?://[^/]+', url).group(0),
|
||||||
})['data']['stream']
|
}
|
||||||
|
try:
|
||||||
|
stream_data = self._download_json(
|
||||||
|
'https://d1k2us671qcoau.cloudfront.net/distribute_web_%s.php' % country_code,
|
||||||
|
video_id, 'Downloading stream info', query=query, headers=headers)
|
||||||
|
stream_data = stream_data['data']['stream']
|
||||||
|
except KeyError:
|
||||||
|
# preview is limited to 3min for non-members
|
||||||
|
# retry with the duration limit set
|
||||||
|
duration_limit = True
|
||||||
|
query['duration'] = '180'
|
||||||
|
stream_data = self._download_json(
|
||||||
|
'https://d1k2us671qcoau.cloudfront.net/distribute_web_%s.php' % country_code,
|
||||||
|
video_id, 'Downloading stream info', query=query, headers=headers)
|
||||||
|
stream_data = stream_data['data']['stream']
|
||||||
|
|
||||||
stream_sizes = stream_data.get('size', {})
|
stream_sizes = stream_data.get('size', {})
|
||||||
formats = []
|
formats = []
|
||||||
for vid_format, stream_url in stream_data.get('url', {}).items():
|
for vid_format, stream_url in stream_data.get('url', {}).items():
|
||||||
height = int_or_none(self._search_regex(
|
height = int_or_none(self._search_regex(
|
||||||
r's(\d+)p', vid_format, 'height', default=None))
|
r's(\d+)p', vid_format, 'height', default=None))
|
||||||
|
|
||||||
|
# by pass preview duration limit
|
||||||
|
if duration_limit:
|
||||||
|
temp = compat_urlparse.urlparse(stream_url)
|
||||||
|
query = dict(compat_urlparse.parse_qsl(temp.query, keep_blank_values=True))
|
||||||
|
query.update({'duration': '9999999', 'duration_start': '0'})
|
||||||
|
stream_url = temp._replace(query=compat_urlparse.urlencode(query)).geturl()
|
||||||
|
|
||||||
formats.append({
|
formats.append({
|
||||||
'format_id': vid_format,
|
'format_id': vid_format,
|
||||||
'url': stream_url,
|
'url': stream_url,
|
||||||
|
Loading…
Reference in New Issue
Block a user