]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/nfl.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class NFLBaseIE(InfoExtractor
):
15 _VALID_URL_BASE
= r
'''(?x)
33 (?:titansonline|tennesseetitans)|
41 (?:redskins|washingtonfootball)|
59 _VIDEO_CONFIG_REGEX
= r
'<script[^>]+id="[^"]*video-config-[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}[^"]*"[^>]*>\s*({.+})'
62 def _parse_video_config(self
, video_config
, display_id
):
63 video_config
= self
._parse
_json
(video_config
, display_id
)
64 item
= video_config
['playlist'][0]
65 mcp_id
= item
.get('mcpID')
67 info
= self
.url_result(
68 'anvato:GXvEgwyJeWem8KCYXfeoHWknwP48Mboj:' + mcp_id
,
71 media_id
= item
.get('id') or item
['entityId']
73 item_url
= item
['url']
74 info
= {'id': media_id}
75 ext
= determine_ext(item_url
)
77 info
['formats'] = self
._extract
_m
3u8_formats
(item_url
, media_id
, 'mp4')
78 self
._sort
_formats
(info
['formats'])
80 info
['url'] = item_url
81 if item
.get('audio') is True:
82 info
['vcodec'] = 'none'
83 is_live
= video_config
.get('live') is True
85 image_url
= item
.get(item
.get('imageSrc')) or item
.get(item
.get('posterImage'))
89 'ext': determine_ext(image_url
, 'jpg'),
92 'title': self
._live
_title
(title
) if is_live
else title
,
94 'description': clean_html(item
.get('description')),
95 'thumbnails': thumbnails
,
100 class NFLIE(NFLBaseIE
):
102 _VALID_URL
= NFLBaseIE
._VALID
_URL
_BASE
+ r
'(?:videos?|listen|audio)/(?P<id>[^/#?&]+)'
104 'url': 'https://www.nfl.com/videos/baker-mayfield-s-game-changing-plays-from-3-td-game-week-14',
108 'title': "Baker Mayfield's game-changing plays from 3-TD game Week 14",
109 'description': 'md5:85e05a3cc163f8c344340f220521136d',
110 'upload_date': '20201215',
111 'timestamp': 1608009755,
112 'thumbnail': r
're:^https?://.*\.jpg$',
116 'url': 'https://www.chiefs.com/listen/patrick-mahomes-travis-kelce-react-to-win-over-dolphins-the-breakdown',
117 'md5': '6886b32c24b463038c760ceb55a34566',
119 'id': 'd87e8790-3e14-11eb-8ceb-ff05c2867f99',
121 'title': 'Patrick Mahomes, Travis Kelce React to Win Over Dolphins | The Breakdown',
122 'description': 'md5:12ada8ee70e6762658c30e223e095075',
125 'url': 'https://www.buffalobills.com/video/buffalo-bills-military-recognition-week-14',
126 'only_matching': True,
128 'url': 'https://www.raiders.com/audio/instant-reactions-raiders-week-14-loss-to-indianapolis-colts-espn-jason-fitz',
129 'only_matching': True,
132 def _real_extract(self
, url
):
133 display_id
= self
._match
_id
(url
)
134 webpage
= self
._download
_webpage
(url
, display_id
)
135 return self
._parse
_video
_config
(self
._search
_regex
(
136 self
._VIDEO
_CONFIG
_REGEX
, webpage
, 'video config'), display_id
)
139 class NFLArticleIE(NFLBaseIE
):
140 IE_NAME
= 'nfl.com:article'
141 _VALID_URL
= NFLBaseIE
._VALID
_URL
_BASE
+ r
'news/(?P<id>[^/#?&]+)'
143 'url': 'https://www.buffalobills.com/news/the-only-thing-we-ve-earned-is-the-noise-bills-coaches-discuss-handling-rising-e',
145 'id': 'the-only-thing-we-ve-earned-is-the-noise-bills-coaches-discuss-handling-rising-e',
146 'title': "'The only thing we've earned is the noise' | Bills coaches discuss handling rising expectations",
151 def _real_extract(self
, url
):
152 display_id
= self
._match
_id
(url
)
153 webpage
= self
._download
_webpage
(url
, display_id
)
155 for video_config
in re
.findall(self
._VIDEO
_CONFIG
_REGEX
, webpage
):
156 entries
.append(self
._parse
_video
_config
(video_config
, display_id
))
157 title
= clean_html(get_element_by_class(
158 'nfl-c-article__title', webpage
)) or self
._html
_search
_meta
(
159 ['og:title', 'twitter:title'], webpage
)
160 return self
.playlist_result(entries
, display_id
, title
)