]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/fox.py
11d6c9c3251ff86c6ea26a27a83dec064963ac2c
2 from __future__
import unicode_literals
4 from .adobepass
import AdobePassIE
5 from .uplynk
import UplynkPreplayIE
6 from ..compat
import compat_str
18 class FOXIE(AdobePassIE
):
19 _VALID_URL
= r
'https?://(?:www\.)?fox\.com/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,
48 def _real_extract(self
, url
):
49 video_id
= self
._match
_id
(url
)
51 video
= self
._download
_json
(
52 'https://api.fox.com/fbc-content/v1_4/video/%s' % video_id
,
54 'apikey': 'abdcbed02c124d393b39e818a4312055',
55 'Content-Type': 'application/json',
60 release_url
= video
['videoRelease']['url']
62 description
= video
.get('description')
63 duration
= int_or_none(video
.get('durationInSeconds')) or int_or_none(
64 video
.get('duration')) or parse_duration(video
.get('duration'))
65 timestamp
= unified_timestamp(video
.get('datePublished'))
66 rating
= video
.get('contentRating')
67 age_limit
= parse_age_limit(rating
)
70 video
, lambda x
: x
['trackingData']['properties'], dict) or {}
72 creator
= data
.get('brand') or data
.get('network') or video
.get('network')
74 series
= video
.get('seriesName') or data
.get(
75 'seriesName') or data
.get('show')
76 season_number
= int_or_none(video
.get('seasonNumber'))
77 episode
= video
.get('name')
78 episode_number
= int_or_none(video
.get('episodeNumber'))
79 release_year
= int_or_none(video
.get('releaseYear'))
81 if data
.get('authRequired'):
82 resource
= self
._get
_mvpd
_resource
(
83 'fbc-fox', title
, video
.get('guid'), rating
)
84 release_url
= update_url_query(
86 'auth': self
._extract
_mvpd
_auth
(
87 url
, video_id
, 'fbc-fox', resource
)
91 for doc_rel
in video
.get('documentReleases', []):
92 rel_url
= doc_rel
.get('url')
93 if not url
or doc_rel
.get('format') != 'SCC':
104 'description': description
,
105 'duration': duration
,
106 'timestamp': timestamp
,
107 'age_limit': age_limit
,
110 'season_number': season_number
,
112 'episode_number': episode_number
,
113 'release_year': release_year
,
114 'subtitles': subtitles
,
117 urlh
= self
._request
_webpage
(HEADRequest(release_url
), video_id
)
118 video_url
= compat_str(urlh
.geturl())
120 if UplynkPreplayIE
.suitable(video_url
):
122 '_type': 'url_transparent',
124 'ie_key': UplynkPreplayIE
.ie_key(),
127 m3u8_url
= self
._download
_json
(release_url
, video_id
)['playURL']
128 formats
= self
._extract
_m
3u8_formats
(
129 m3u8_url
, video_id
, 'mp4',
130 entry_protocol
='m3u8_native', m3u8_id
='hls')
131 self
._sort
_formats
(formats
)
132 info
['formats'] = formats