mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-20 13:57:25 +01:00
Update fptplay.py
This commit is contained in:
parent
e2aafefd23
commit
44d1b925ae
@ -7,8 +7,7 @@
|
|||||||
ExtractorError,
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class FptplayIE(InfoExtractor):
|
class FptplayIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://fptplay\.vn/xem-video/[^/]+\-(?P<id>[a-f0-9]+)'
|
_VALID_URL = r'https?://fptplay\.vn/xem-video/[^/]+\-(?P<id>[a-f0-9]+)'
|
||||||
_GEO_COUNTRIES = ['VN']
|
_GEO_COUNTRIES = ['VN']
|
||||||
@ -39,66 +38,63 @@ class FptplayIE(InfoExtractor):
|
|||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
contentId = self._match_id(url)
|
contentId = self._match_id(url)
|
||||||
|
|
||||||
# Need valid cookie with Bearer token, else it won't work
|
# Need valid cookie with Bearer token, else it won't work
|
||||||
token = self._get_cookies(url).get('token')
|
token = self._get_cookies(url).get('token')
|
||||||
|
|
||||||
res = self._download_json(self.get_api_with_st_token(contentId), contentId, expected_status=406)
|
res = self._download_json(self.get_api_with_st_token(contentId), contentId, expected_status=406)
|
||||||
|
|
||||||
if res['result']['episode_type'] == 0:
|
if res['result']['episode_type'] == 0:
|
||||||
# movie or single video
|
# movie or single video
|
||||||
manifest = self._download_json(self.get_api_with_st_token(contentId, 0), contentId, headers={'authorization': f'Bearer {token.value}'}, expected_status=406)
|
manifest = self._download_json(self.get_api_with_st_token(contentId, 0), contentId, headers={'authorization': f'Bearer {token.value}'}, expected_status=406)
|
||||||
if manifest.get('msg') != 'success':
|
if manifest.get('msg') != 'success':
|
||||||
raise ExtractorError(f' - Got an error, response: {manifest.get("msg")}', expected=True)
|
raise ExtractorError(f" - Got an error, response: {manifest.get('msg')}", expected=True)
|
||||||
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(manifest['data']['url'], contentId)
|
||||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(manifest["data"]["url"], contentId)
|
|
||||||
return {
|
return {
|
||||||
'id': contentId,
|
'id': contentId,
|
||||||
'title': res["result"]["title_origin"] if res["result"]["title_origin"] else res["result"]["title_vie"],
|
'title': res['result']['title_origin'] if res['result']['title_origin'] else res['result']['title_vie'],
|
||||||
'description': res["result"]["description"],
|
'description': res['result']['description'],
|
||||||
'thumbnail': res["result"]["thumb"],
|
'thumbnail': res['result']['thumb'],
|
||||||
'release_year': int_or_none(res["result"]["movie_release_date"]),
|
'release_year': int_or_none(res['result']['movie_release_date']),
|
||||||
'duration': int_or_none(res["result"]["duration"]),
|
'duration': int_or_none(res['result']['duration']),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitles
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
# playlist
|
# playlist
|
||||||
entries = []
|
entries = []
|
||||||
for episode in res["result"]["episodes"]:
|
for episode in res['result']['episodes']:
|
||||||
|
|
||||||
if episode["is_trailer"] == 1:
|
if episode['is_trailer'] == 1:
|
||||||
continue
|
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)
|
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":
|
if manifest.get('msg') != 'success':
|
||||||
raise ExtractorError(f' - Got an error, response: {manifest.get("msg")}', expected=True)
|
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"])
|
formats, subtitles = self._extract_m3u8_formats_and_subtitles(manifest['data']['url'], episode['_id'])
|
||||||
|
|
||||||
entry = {
|
entry = {
|
||||||
'id': episode["ref_episode_id"],
|
'id': episode['ref_episode_id'],
|
||||||
'title': res["result"]["title_origin"] if res["result"]["title_origin"] else res["result"]["title_vie"],
|
'title': res['result']['title_origin'] if res['result']['title_origin'] else res['result']['title_vie'],
|
||||||
'description': episode["description"],
|
'description': episode['description'],
|
||||||
'thumbnail': episode["thumb"],
|
'thumbnail': episode['thumb'],
|
||||||
'release_year': int_or_none(res["result"]["movie_release_date"]),
|
'release_year': int_or_none(res['result']['movie_release_date']),
|
||||||
'season_number': 1, # Assuming season 1 for simplicity
|
'season_number': 1, # Assuming season 1 for simplicity
|
||||||
'episode': episode["title"],
|
'episode': episode['title'],
|
||||||
'episode_number': episode["_id"] + 1,
|
'episode_number': episode['_id'] + 1,
|
||||||
'duration': int_or_none(episode["duration"]),
|
'duration': int_or_none(episode['duration']),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitles
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
entries.append(entry)
|
entries.append(entry)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'_type': 'playlist',
|
'_type': 'playlist',
|
||||||
'id': contentId,
|
'id': contentId,
|
||||||
'title': res["result"]["title_origin"] if res["result"]["title_origin"] else res["result"]["title_vie"],
|
'title': res['result']['title_origin'] if res['result']['title_origin'] else res['result']['title_vie'],
|
||||||
'entries': entries
|
'entries': entries,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_api_with_st_token(self, video_id, episode=None):
|
def get_api_with_st_token(self, video_id, episode=None):
|
||||||
@ -147,4 +143,4 @@ def convert(e):
|
|||||||
return t
|
return t
|
||||||
|
|
||||||
st_token = convert(n).replace('+', '-').replace('/', '_').replace('=', '')
|
st_token = convert(n).replace('+', '-').replace('/', '_').replace('=', '')
|
||||||
return f'https://api.fptplay.net{path}?{urllib.parse.urlencode({"st": st_token, "e": timestamp})}'
|
return f'https://api.fptplay.net{path}?{urllib.parse.urlencode({'st': st_token, 'e': timestamp})}'
|
||||||
|
Loading…
Reference in New Issue
Block a user