From 8e977a039ec3b0c9f7971e828b04276a733cfbc6 Mon Sep 17 00:00:00 2001
From: red-acid <161967284+red-acid@users.noreply.github.com>
Date: Sat, 2 Mar 2024 22:46:47 +0000
Subject: [PATCH] Update rtp.py based on some comments in youtube-dl#29824
---
yt_dlp/extractor/rtp.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/yt_dlp/extractor/rtp.py b/yt_dlp/extractor/rtp.py
index c6be45c8d..233f1ba71 100644
--- a/yt_dlp/extractor/rtp.py
+++ b/yt_dlp/extractor/rtp.py
@@ -3,6 +3,7 @@
ExtractorError,
RegexNotFoundError,
determine_ext,
+ join_nonempty,
js_to_json,
)
import re
@@ -102,7 +103,7 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)
- title = self._html_search_regex(r'
(.+?)', webpage, 'title')
+ title = self._html_search_regex(r'(.+?)', webpage, 'title', default='')
# Raise error if episode is unavailable
if 'Este episódio não se encontra disponível' in title:
@@ -111,10 +112,11 @@ def _real_extract(self, url):
# Replace irrelevant string in title
title = re.sub(r' - ?RTP Play - RTP', '', title)
- # Check if it's a program split in parts, if so add part number to title
+ # Check if it's a program split in parts
part = self._html_search_regex(r'section\-parts.*(.+?).*', webpage, 'part', default=None)
- if part is not None:
- title = '{title} {part}'.format(title=title, part=part)
+
+ # Add program part identification to title if it exists
+ title = join_nonempty(title, part, delim=' ')
try:
# Extract f and config from page