diff --git a/yt_dlp/extractor/fptplay.py b/yt_dlp/extractor/fptplay.py index bf5d5ba4b..05bffcefa 100644 --- a/yt_dlp/extractor/fptplay.py +++ b/yt_dlp/extractor/fptplay.py @@ -1,13 +1,11 @@ import hashlib import time import urllib.parse - from .common import InfoExtractor from ..utils import ( ExtractorError, int_or_none, ) - class FptplayIE(InfoExtractor): _VALID_URL = r'https?://fptplay\.vn/xem-video/[^/]+\-(?P[a-f0-9]+)' _GEO_COUNTRIES = ['VN'] @@ -37,7 +35,6 @@ class FptplayIE(InfoExtractor): 'duration': '2665', }, }] - def _real_extract(self, url): contentId = self._match_id(url) # Need valid cookie with Bearer token, else it won't work @@ -62,17 +59,13 @@ def _real_extract(self, url): else: # playlist entries = [] - for episode in res['result']['episodes']: - + for episode in res['result']['episodes']: if episode['is_trailer'] == 1: continue - manifest = self._download_json(self.get_api_with_st_token(contentId, episode['_id']), episode['_id'], headers={'authorization': f'Bearer {token.value}'}, expected_status=406) if manifest.get('msg') != 'success': raise ExtractorError(f" - Got an error, response: {manifest.get('msg')}", expected=True) - formats, subtitles = self._extract_m3u8_formats_and_subtitles(manifest['data']['url'], episode['_id']) - entry = { 'id': episode['ref_episode_id'], 'title': res['result']['title_origin'] if res['result']['title_origin'] else res['result']['title_vie'], @@ -87,14 +80,12 @@ def _real_extract(self, url): 'subtitles': subtitles, } entries.append(entry) - return { '_type': 'playlist', 'id': contentId, 'title': res['result']['title_origin'] if res['result']['title_origin'] else res['result']['title_vie'], 'entries': entries, } - def get_api_with_st_token(self, video_id, episode=None): if episode is not None: path = f'/api/v7.1_w/stream/vod/{video_id}/{0 if episode is None else episode}/adaptive_bitrate' @@ -104,7 +95,6 @@ def get_api_with_st_token(self, video_id, episode=None): t = hashlib.md5(f'6ea6d2a4e2d3a4bd5e275401aa086d{timestamp}{path}'.encode()).hexdigest().upper() r = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' n = [int(f'0x{t[2 * o: 2 * o + 2]}', 16) for o in range(len(t) // 2)] - def convert(e): t = '' n = 0 @@ -139,6 +129,5 @@ def convert(e): t += '' n += 1 return t - st_token = convert(n).replace('+', '-').replace('/', '_').replace('=', '') return f"https://api.fptplay.net{path}?{urllib.parse.urlencode({'st': st_token, 'e': timestamp})}"