[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / caltrans.py
blob5513bb2dfa686e6a060bbebcb20d09def6f7ce56
1 from .common import InfoExtractor
4 class CaltransIE(InfoExtractor):
5 _VALID_URL = r'https?://(?:[^/]+\.)?ca\.gov/vm/loc/[^/]+/(?P<id>[a-z0-9_]+)\.htm'
6 _TEST = {
7 'url': 'https://cwwp2.dot.ca.gov/vm/loc/d3/hwy50at24th.htm',
8 'info_dict': {
9 'id': 'hwy50at24th',
10 'ext': 'ts',
11 'title': 'US-50 : Sacramento : Hwy 50 at 24th',
12 'live_status': 'is_live',
13 'thumbnail': 'https://cwwp2.dot.ca.gov/data/d3/cctv/image/hwy50at24th/hwy50at24th.jpg',
17 def _real_extract(self, url):
18 video_id = self._match_id(url)
19 webpage = self._download_webpage(url, video_id)
21 global_vars = self._search_regex(
22 r'<script[^<]+?([^<]+\.m3u8[^<]+)</script>',
23 webpage, 'Global Vars')
24 route_place = self._search_regex(r'routePlace\s*=\s*"([^"]+)"', global_vars, 'Route Place', fatal=False)
25 location_name = self._search_regex(r'locationName\s*=\s*"([^"]+)"', global_vars, 'Location Name', fatal=False)
26 poster_url = self._search_regex(r'posterURL\s*=\s*"([^"]+)"', global_vars, 'Poster Url', fatal=False)
27 video_stream = self._search_regex(r'videoStreamURL\s*=\s*"([^"]+)"', global_vars, 'Video Stream URL', fatal=False)
29 formats = self._extract_m3u8_formats(video_stream, video_id, 'ts', live=True)
31 return {
32 'id': video_id,
33 'title': f'{route_place} : {location_name}',
34 'is_live': True,
35 'formats': formats,
36 'thumbnail': poster_url,