aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBricio <216170+Bricio@users.noreply.github.com>2022-02-14 23:45:36 -0300
committerGitHub <noreply@github.com>2022-02-14 18:45:36 -0800
commit0a19532eadc2d10272a9115450c9da64e42a7e56 (patch)
treec982dc2c45f5c568bddd46922793a4e4bcb2cb0a
parent2d41e2ecebb62b572d8bb5b2e4e51ba12f3f0510 (diff)
downloadhypervideo-pre-0a19532eadc2d10272a9115450c9da64e42a7e56.tar.lz
hypervideo-pre-0a19532eadc2d10272a9115450c9da64e42a7e56.tar.xz
hypervideo-pre-0a19532eadc2d10272a9115450c9da64e42a7e56.zip
[Caltrans] Add extractor (#2781)
Closes #2775 Authored by: Bricio
-rw-r--r--yt_dlp/extractor/caltrans.py41
-rw-r--r--yt_dlp/extractor/extractors.py1
2 files changed, 42 insertions, 0 deletions
diff --git a/yt_dlp/extractor/caltrans.py b/yt_dlp/extractor/caltrans.py
new file mode 100644
index 000000000..9ac740f7e
--- /dev/null
+++ b/yt_dlp/extractor/caltrans.py
@@ -0,0 +1,41 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+
+class CaltransIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:[^/]+\.)?ca\.gov/vm/loc/[^/]+/(?P<id>[a-z0-9_]+)\.htm'
+ _TEST = {
+ 'url': 'https://cwwp2.dot.ca.gov/vm/loc/d3/hwy50at24th.htm',
+ 'info_dict': {
+ 'id': 'hwy50at24th',
+ 'ext': 'ts',
+ 'title': 'US-50 : Sacramento : Hwy 50 at 24th',
+ 'live_status': 'is_live',
+ 'thumbnail': 'https://cwwp2.dot.ca.gov/data/d3/cctv/image/hwy50at24th/hwy50at24th.jpg',
+ }
+ }
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+ webpage = self._download_webpage(url, video_id)
+
+ global_vars = self._search_regex(
+ r'<script[^<]+?([^<]+\.m3u8[^<]+)</script>',
+ webpage, 'Global Vars')
+ route_place = self._search_regex(r'routePlace\s*=\s*"([^"]+)"', global_vars, 'Route Place', fatal=False)
+ location_name = self._search_regex(r'locationName\s*=\s*"([^"]+)"', global_vars, 'Location Name', fatal=False)
+ poster_url = self._search_regex(r'posterURL\s*=\s*"([^"]+)"', global_vars, 'Poster Url', fatal=False)
+ video_stream = self._search_regex(r'videoStreamURL\s*=\s*"([^"]+)"', global_vars, 'Video Stream URL', fatal=False)
+
+ formats = self._extract_m3u8_formats(video_stream, video_id, 'ts', live=True)
+ self._sort_formats(formats)
+
+ return {
+ 'id': video_id,
+ 'title': f'{route_place} : {location_name}',
+ 'is_live': True,
+ 'formats': formats,
+ 'thumbnail': poster_url,
+ }
diff --git a/yt_dlp/extractor/extractors.py b/yt_dlp/extractor/extractors.py
index a9dc2289b..777d17788 100644
--- a/yt_dlp/extractor/extractors.py
+++ b/yt_dlp/extractor/extractors.py
@@ -195,6 +195,7 @@ from .byutv import BYUtvIE
from .c56 import C56IE
from .cableav import CableAVIE
from .callin import CallinIE
+from .caltrans import CaltransIE
from .cam4 import CAM4IE
from .camdemy import (
CamdemyIE,