]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/fox.py
b1c91f0950986df6f7d25c674e3b05da3dfe3975
2 from __future__
import unicode_literals
7 from .adobepass
import AdobePassIE
18 class FOXIE(AdobePassIE
):
19 _VALID_URL
= r
'https?://(?:www\.)?(?:fox\.com|nationalgeographic\.com/tv)/watch/(?P<id>[\da-fA-F]+)'
22 'url': 'https://www.fox.com/watch/4b765a60490325103ea69888fb2bd4e8/',
23 'md5': 'ebd296fcc41dd4b19f8115d8461a3165',
25 'id': '4b765a60490325103ea69888fb2bd4e8',
27 'title': 'Aftermath: Bruce Wayne Develops Into The Dark Knight',
28 'description': 'md5:549cd9c70d413adb32ce2a779b53b486',
30 'timestamp': 1504291893,
31 'upload_date': '20170901',
36 'skip_download': True,
39 # episode, geo-restricted
40 'url': 'https://www.fox.com/watch/087036ca7f33c8eb79b08152b4dd75c1/',
41 'only_matching': True,
43 # episode, geo-restricted, tv provided required
44 'url': 'https://www.fox.com/watch/30056b295fb57f7452aeeb4920bc3024/',
45 'only_matching': True,
47 'url': 'https://www.nationalgeographic.com/tv/watch/f690e05ebbe23ab79747becd0cc223d1/',
48 'only_matching': True,
50 # _access_token = None
52 # def _call_api(self, path, video_id, data=None):
54 # 'X-Api-Key': '238bb0a0c2aba67922c48709ce0c06fd',
56 # if self._access_token:
57 # headers['Authorization'] = 'Bearer ' + self._access_token
58 # return self._download_json(
59 # 'https://api2.fox.com/v2.0/' + path, video_id, data=data, headers=headers)
61 # def _real_initialize(self):
62 # self._access_token = self._call_api(
63 # 'login', None, json.dumps({
64 # 'deviceId': compat_str(uuid.uuid4()),
65 # }).encode())['accessToken']
67 def _real_extract(self
, url
):
68 video_id
= self
._match
_id
(url
)
70 video
= self
._download
_json
(
71 'https://api.fox.com/fbc-content/v1_5/video/%s' % video_id
,
73 'apikey': 'abdcbed02c124d393b39e818a4312055',
74 'Content-Type': 'application/json',
77 # video = self._call_api('vodplayer/' + video_id, video_id)
80 release_url
= video
['videoRelease']['url']
81 # release_url = video['url']
84 video
, lambda x
: x
['trackingData']['properties'], dict) or {}
86 rating
= video
.get('contentRating')
87 if data
.get('authRequired'):
88 resource
= self
._get
_mvpd
_resource
(
89 'fbc-fox', title
, video
.get('guid'), rating
)
90 release_url
= update_url_query(
92 'auth': self
._extract
_mvpd
_auth
(
93 url
, video_id
, 'fbc-fox', resource
)
95 m3u8_url
= self
._download
_json
(release_url
, video_id
)['playURL']
96 formats
= self
._extract
_m
3u8_formats
(
97 m3u8_url
, video_id
, 'mp4',
98 entry_protocol
='m3u8_native', m3u8_id
='hls')
99 self
._sort
_formats
(formats
)
101 duration
= int_or_none(video
.get('durationInSeconds')) or int_or_none(
102 video
.get('duration')) or parse_duration(video
.get('duration'))
103 timestamp
= unified_timestamp(video
.get('datePublished'))
104 creator
= data
.get('brand') or data
.get('network') or video
.get('network')
105 series
= video
.get('seriesName') or data
.get(
106 'seriesName') or data
.get('show')
109 for doc_rel
in video
.get('documentReleases', []):
110 rel_url
= doc_rel
.get('url')
111 if not url
or doc_rel
.get('format') != 'SCC':
123 'description': video
.get('description'),
124 'duration': duration
,
125 'timestamp': timestamp
,
126 'age_limit': parse_age_limit(rating
),
129 'season_number': int_or_none(video
.get('seasonNumber')),
130 'episode': video
.get('name'),
131 'episode_number': int_or_none(video
.get('episodeNumber')),
132 'release_year': int_or_none(video
.get('releaseYear')),
133 'subtitles': subtitles
,