ppbbww

Pillar Point boats, birds, and waves watcher
git clone git@abtrout.com:ppbbww.git
Log | Files | Refs | README | LICENSE

commit 908ff405673361c98cfe92b494a9f71d2ec2a21a
parent 7529d63636057827e811c4551cbb2b68c9752d6a
Author: david cochran <about.trout@gmail.com>
Date:   Wed, 11 Sep 2024 19:22:06 -0700

fix for latest Surfline breakages

now we download the final chunk in each playlist, rather than the first.

Diffstat:
Mppboatwatch/stream_sampler.py | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ppboatwatch/stream_sampler.py b/ppboatwatch/stream_sampler.py @@ -15,8 +15,11 @@ DEFAULT_HEADERS = { "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate, br, zstd", "Origin": "https://www.surfline.com", + "Host": "cams.cdn-surfline.com", "DNT": "1", "Referer": "https://www.surfline.com/", + "Pragma": "no-cache", + "Cache-Control": "no-cache", "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "cross-site", @@ -26,7 +29,7 @@ DEFAULT_HEADERS = { class StreamSampler: def __init__(self, cam_name, data_dir="./data"): - self.base_url = f"https://hls.cdn-surfline.com/oregon/wc-{cam_name}" + self.base_url = f"https://cams.cdn-surfline.com/cdn-wc/wc-{cam_name}" self.cam_name = cam_name self.data_dir = data_dir @@ -41,10 +44,11 @@ class StreamSampler: return self.__extract_frames(chunk_file) async def __get_recent_chunk_url(self, session): - url = f"{self.base_url}/playlist.m3u8" + url = f"{self.base_url}/chunklist.m3u8" async with session.get(url) as res: chunklist = await res.text() - chunk = next(l for l in chunklist.splitlines() if not l.startswith("#")) + # Only check last/final chunk from chunklist. + *_, chunk = [l for l in chunklist.splitlines() if not l.startswith("#")] return f"{self.base_url}/{chunk}" async def __get_recent_chunk(self, session, chunk_url):