mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-11 14:18:18 +01:00
parent
768145d48a
commit
443f8de820
@ -4,7 +4,7 @@
|
|||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from .adobepass import AdobePassIE
|
from .common import InfoExtractor
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_HTTPError,
|
compat_HTTPError,
|
||||||
compat_str,
|
compat_str,
|
||||||
@ -20,7 +20,7 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class FOXIE(AdobePassIE):
|
class FOXIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?fox\.com/watch/(?P<id>[\da-fA-F]+)'
|
_VALID_URL = r'https?://(?:www\.)?fox\.com/watch/(?P<id>[\da-fA-F]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
# clip
|
# clip
|
||||||
@ -37,6 +37,7 @@ class FOXIE(AdobePassIE):
|
|||||||
'creator': 'FOX',
|
'creator': 'FOX',
|
||||||
'series': 'Gotham',
|
'series': 'Gotham',
|
||||||
'age_limit': 14,
|
'age_limit': 14,
|
||||||
|
'episode': 'Aftermath: Bruce Wayne Develops Into The Dark Knight'
|
||||||
},
|
},
|
||||||
'params': {
|
'params': {
|
||||||
'skip_download': True,
|
'skip_download': True,
|
||||||
@ -46,14 +47,15 @@ class FOXIE(AdobePassIE):
|
|||||||
'url': 'https://www.fox.com/watch/087036ca7f33c8eb79b08152b4dd75c1/',
|
'url': 'https://www.fox.com/watch/087036ca7f33c8eb79b08152b4dd75c1/',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}, {
|
}, {
|
||||||
# episode, geo-restricted, tv provided required
|
# sports event, geo-restricted
|
||||||
'url': 'https://www.fox.com/watch/30056b295fb57f7452aeeb4920bc3024/',
|
'url': 'https://www.fox.com/watch/b057484dade738d1f373b3e46216fa2c/',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
_GEO_BYPASS = False
|
_GEO_BYPASS = False
|
||||||
_HOME_PAGE_URL = 'https://www.fox.com/'
|
_HOME_PAGE_URL = 'https://www.fox.com/'
|
||||||
_API_KEY = 'abdcbed02c124d393b39e818a4312055'
|
_API_KEY = '6E9S4bmcoNnZwVLOHywOv8PJEdu76cM9'
|
||||||
_access_token = None
|
_access_token = None
|
||||||
|
_device_id = compat_str(uuid.uuid4())
|
||||||
|
|
||||||
def _call_api(self, path, video_id, data=None):
|
def _call_api(self, path, video_id, data=None):
|
||||||
headers = {
|
headers = {
|
||||||
@ -63,7 +65,7 @@ def _call_api(self, path, video_id, data=None):
|
|||||||
headers['Authorization'] = 'Bearer ' + self._access_token
|
headers['Authorization'] = 'Bearer ' + self._access_token
|
||||||
try:
|
try:
|
||||||
return self._download_json(
|
return self._download_json(
|
||||||
'https://api2.fox.com/v2.0/' + path,
|
'https://api3.fox.com/v2.0/' + path,
|
||||||
video_id, data=data, headers=headers)
|
video_id, data=data, headers=headers)
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
|
||||||
@ -87,16 +89,37 @@ def _real_initialize(self):
|
|||||||
if not self._access_token:
|
if not self._access_token:
|
||||||
self._access_token = self._call_api(
|
self._access_token = self._call_api(
|
||||||
'login', None, json.dumps({
|
'login', None, json.dumps({
|
||||||
'deviceId': compat_str(uuid.uuid4()),
|
'deviceId': self._device_id,
|
||||||
}).encode())['accessToken']
|
}).encode())['accessToken']
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
video = self._call_api('vodplayer/' + video_id, video_id)
|
self._access_token = self._call_api(
|
||||||
|
'previewpassmvpd?device_id=%s&mvpd_id=TempPass_fbcfox_60min' % self._device_id,
|
||||||
|
video_id)['accessToken']
|
||||||
|
|
||||||
|
video = self._call_api('watch', video_id, data=json.dumps({
|
||||||
|
'capabilities': ['drm/widevine', 'fsdk/yo'],
|
||||||
|
'deviceWidth': 1280,
|
||||||
|
'deviceHeight': 720,
|
||||||
|
'maxRes': '720p',
|
||||||
|
'os': 'macos',
|
||||||
|
'osv': '',
|
||||||
|
'provider': {
|
||||||
|
'freewheel': {'did': self._device_id},
|
||||||
|
'vdms': {'rays': ''},
|
||||||
|
'dmp': {'kuid': '', 'seg': ''}
|
||||||
|
},
|
||||||
|
'playlist': '',
|
||||||
|
'privacy': {'us': '1---'},
|
||||||
|
'siteSection': '',
|
||||||
|
'streamType': 'vod',
|
||||||
|
'streamId': video_id}).encode('utf-8'))
|
||||||
|
|
||||||
title = video['name']
|
title = video['name']
|
||||||
release_url = video['url']
|
release_url = video['url']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
m3u8_url = self._download_json(release_url, video_id)['playURL']
|
m3u8_url = self._download_json(release_url, video_id)['playURL']
|
||||||
except ExtractorError as e:
|
except ExtractorError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user