From 007bbeacd78e0d158f684b5a8833d6425a0312f9 Mon Sep 17 00:00:00 2001 From: Bart Broere Date: Thu, 14 Mar 2024 13:41:01 +0100 Subject: [PATCH] Remove afspelen and trailing slashes with one regex Co-authored-by: dirkf --- youtube_dl/extractor/npo.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/youtube_dl/extractor/npo.py b/youtube_dl/extractor/npo.py index 4a70e251b..545e58509 100644 --- a/youtube_dl/extractor/npo.py +++ b/youtube_dl/extractor/npo.py @@ -44,14 +44,8 @@ class NPOIE(InfoExtractor): note='Downloading token')['token'] def _real_extract(self, url): - # You might want to use removesuffix here, - # but removesuffix is introduced in Python 3.9 - # and youtube-dl supports Python 3.2+ - if url.endswith('/afspelen'): - url = url[:-9] - elif url.endswith('/afspelen/'): - url = url[:-10] - url = url.rstrip('/') + # Remove /afspelen and/or any trailing `/`s + url = re.sub(r'/(?:afspelen)?/*$', '', url) slug = url.split('/')[-1] program_metadata = self._download_json('https://npo.nl/start/api/domain/program-detail',