]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/viu.py
Allow extractors to specify section_start/end for clips
[yt-dlp.git] / yt_dlp / extractor / viu.py
index b0a1fca6824c13a06fc54c220645a9a796c4a205..63b6fd3a1295e8ea8b4469f67203a8f7838d6ce3 100644 (file)
@@ -1,6 +1,3 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 import re
 import json
 import uuid
@@ -329,7 +326,8 @@ def download_playback():
             if token is not None:
                 query['identity'] = token
             else:
-                # preview is limited to 3min for non-members. But we can try to bypass it
+                # The content is Preview or for VIP only.
+                # We can try to bypass the duration which is limited to 3mins only
                 duration_limit, query['duration'] = True, '180'
             try:
                 stream_data = download_playback()
@@ -346,13 +344,13 @@ def download_playback():
 
             # bypass preview duration limit
             if duration_limit:
-                stream_url = urllib.parse.urlparse(stream_url)
+                old_stream_url = urllib.parse.urlparse(stream_url)
+                query = dict(urllib.parse.parse_qsl(old_stream_url.query, keep_blank_values=True))
                 query.update({
                     'duration': video_data.get('time_duration') or '9999999',
                     'duration_start': '0',
                 })
-                stream_url = stream_url._replace(query=urllib.parse.urlencode(dict(
-                    urllib.parse.parse_qsl(stream_url.query, keep_blank_values=True)))).geturl()
+                stream_url = old_stream_url._replace(query=urllib.parse.urlencode(query)).geturl()
 
             formats.append({
                 'format_id': vid_format,