Skip to content

Commit ec440d2

Browse files
committed
Refactor _extract_psch_and_pkey function to handle multiple PSCH lines and return the last one found
1 parent 90224ab commit ec440d2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

proxy_module.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,15 +288,21 @@ def _decode_m3u8_mouflon_files(m3u8_text: str) -> str:
288288

289289
def _extract_psch_and_pkey(m3u8_text):
290290
"""Return (psch_version, pkey) from #EXT-X-MOUFLON:PSCH line if present."""
291+
psch_lines = []
291292
for line in m3u8_text.splitlines():
292293
l = line.strip()
293294
if not l:
294295
continue
295296
if l.upper().startswith('#EXT-X-MOUFLON:PSCH'):
296-
parts = l.split(':', 3)
297-
version = parts[2].lower() if len(parts) > 2 else ''
298-
pkey = parts[3] if len(parts) > 3 else ''
299-
return version, pkey
297+
psch_lines.append(l)
298+
if psch_lines:
299+
# Use the last (second) PSCH line if multiple are found
300+
last_line = psch_lines[-1]
301+
parts = last_line.split(':', 3)
302+
version = parts[2].lower() if len(parts) > 2 else ''
303+
pkey = parts[3] if len(parts) > 3 else ''
304+
return version, pkey
305+
300306
return '', ''
301307

302308
def _make_absolute(base, ref):

0 commit comments

Comments
 (0)