From 4918522735149b880586fc6b8cea31fa6a28e136 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 3 Feb 2022 19:45:57 +0530 Subject: [PATCH] [utils] Strip double spaces in `clean_html` Closes #2497 Authored by: dirkf --- yt_dlp/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index 13ad5fd48..fd3912d18 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -639,10 +639,9 @@ def clean_html(html): if html is None: # Convenience for sanitizing descriptions etc. return html - # Newline vs
- html = html.replace('\n', ' ') - html = re.sub(r'(?u)\s*<\s*br\s*/?\s*>\s*', '\n', html) - html = re.sub(r'(?u)<\s*/\s*p\s*>\s*<\s*p[^>]*>', '\n', html) + html = re.sub(r'\s+', ' ', html) + html = re.sub(r'(?u)\s?<\s?br\s?/?\s?>\s?', '\n', html) + html = re.sub(r'(?u)<\s?/\s?p\s?>\s?<\s?p[^>]*>', '\n', html) # Strip html tags html = re.sub('<.*?>', '', html) # Replace html entities