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