]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/nfhsnetwork.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
14 class NFHSNetworkIE(InfoExtractor
):
15 IE_NAME
= 'NFHSNetwork'
16 _VALID_URL
= r
'https?://(?:www\.)?nfhsnetwork\.com/events/[\w-]+/(?P<id>(?:gam|evt|dd|)?[\w\d]{0,10})'
18 # Auto-generated two-team sport (pixellot)
19 'url': 'https://www.nfhsnetwork.com/events/rockford-high-school-rockford-mi/gamcf7e54cfbc',
21 'id': 'gamcf7e54cfbc',
23 'title': 'Rockford vs Spring Lake - Girls Varsity Lacrosse 03/27/2021',
24 'uploader': 'MHSAA - Michigan: Rockford High School, Rockford, MI',
25 'uploader_id': 'cd2622cf76',
26 'uploader_url': 'https://www.nfhsnetwork.com/schools/rockford-high-school-rockford-mi',
27 'location': 'Rockford, Michigan',
28 'timestamp': 1616859000,
29 'upload_date': '20210327'
33 'skip_download': True,
36 # Non-sport activity with description
37 'url': 'https://www.nfhsnetwork.com/events/limon-high-school-limon-co/evt4a30e3726c',
39 'id': 'evt4a30e3726c',
41 'title': 'Drama Performance Limon High School vs. Limon High School - 12/13/2020',
42 'description': 'Join the broadcast of the Limon High School Musical Performance at 2 PM.',
43 'uploader': 'CHSAA: Limon High School, Limon, CO',
44 'uploader_id': '7d2d121332',
45 'uploader_url': 'https://www.nfhsnetwork.com/schools/limon-high-school-limon-co',
46 'location': 'Limon, Colorado',
47 'timestamp': 1607893200,
48 'upload_date': '20201213'
52 'skip_download': True,
56 'url': 'https://www.nfhsnetwork.com/events/nfhs-network-special-events/dd8de71d45',
60 'title': '2015 UA Holiday Classic Tournament: National Division - 12/26/2015',
61 'uploader': 'SoCal Sports Productions',
62 'uploader_id': '063dba0150',
63 'uploader_url': 'https://www.nfhsnetwork.com/affiliates/socal-sports-productions',
64 'location': 'San Diego, California',
65 'timestamp': 1451187000,
66 'upload_date': '20151226'
70 'skip_download': True,
73 # Video with no broadcasts object
74 'url': 'https://www.nfhsnetwork.com/events/wiaa-wi/9aa2f92f82',
78 'title': 'Competitive Equity - 01/21/2015',
79 'description': 'Committee members discuss points of their research regarding a competitive equity plan',
80 'uploader': 'WIAA - Wisconsin: Wisconsin Interscholastic Athletic Association',
81 'uploader_id': 'a49f7d1002',
82 'uploader_url': 'https://www.nfhsnetwork.com/associations/wiaa-wi',
83 'location': 'Stevens Point, Wisconsin',
84 'timestamp': 1421856000,
85 'upload_date': '20150121'
89 'skip_download': True,
94 def _real_extract(self
, url
):
95 video_id
= self
._match
_id
(url
)
96 webpage
= self
._download
_webpage
(url
, video_id
)
97 data
= self
._download
_json
(
98 'https://cfunity.nfhsnetwork.com/v2/game_or_event/' + video_id
,
100 publisher
= data
.get('publishers')[0] # always exists
101 broadcast
= (publisher
.get('broadcasts') or publisher
.get('vods'))[0] # some (older) videos don't have a broadcasts object
102 uploader
= publisher
.get('formatted_name') or publisher
.get('name')
103 uploaderID
= publisher
.get('publisher_key')
104 pubType
= publisher
.get('type')
106 "schools" if pubType
== "school"
107 else "associations" if "association" in pubType
108 else "affiliates" if (pubType
== "publisher" or pubType
== "affiliate")
110 uploaderPage
= 'https://www.nfhsnetwork.com/%s/%s' % (uploaderPrefix
, publisher
.get('slug'))
111 location
= '%s, %s' % (data
.get('city'), data
.get('state_name'))
112 description
= broadcast
.get('description')
113 isLive
= broadcast
.get('on_air') or broadcast
.get('status') == 'on_air' or False
115 timestamp
= unified_timestamp(data
.get('local_start_time'))
116 upload_date
= unified_strdate(data
.get('local_start_time'))
119 self
._og
_search
_title
(webpage
)
120 or self
._html
_search
_regex
(r
'<h1 class="sr-hidden">(.*?)</h1>', webpage
, 'title'))
121 title
= title
.split('|')[0].strip()
123 video_type
= 'broadcasts' if isLive
else 'vods'
124 key
= broadcast
.get('key') if isLive
else try_get(publisher
, lambda x
: x
['vods'][0]['key'])
125 m3u8_url
= self
._download
_json
(
126 'https://cfunity.nfhsnetwork.com/v2/%s/%s/url' % (video_type
, key
),
127 video_id
).get('video_url')
129 formats
= self
._extract
_m
3u8_formats
(m3u8_url
, video_id
, 'mp4', live
=isLive
)
130 self
._sort
_formats
(formats
, ['res', 'tbr'])
136 'description': description
,
137 'timestamp': timestamp
,
138 'uploader': uploader
,
139 'uploader_id': uploaderID
,
140 'uploader_url': uploaderPage
,
141 'location': location
,
142 'upload_date': upload_date
,