aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcoletdev <coletdjnz@protonmail.com>2022-06-03 19:04:39 +1200
committerGitHub <noreply@github.com>2022-06-03 07:04:39 +0000
commitc7a7baaa130099aa283dae1f8e583d14ec540ad3 (patch)
treee1761ab27eb21485e6fb0fcb08d4d2e3d57b0a96
parente50c3500b43d80e4492569c4b4523c4379c6fbb2 (diff)
downloadhypervideo-pre-c7a7baaa130099aa283dae1f8e583d14ec540ad3.tar.lz
hypervideo-pre-c7a7baaa130099aa283dae1f8e583d14ec540ad3.tar.xz
hypervideo-pre-c7a7baaa130099aa283dae1f8e583d14ec540ad3.zip
[extractor/youtube] Fix `:ytnotifications` extractor (#3775)
Still some issues, see https://github.com/yt-dlp/yt-dlp/pull/3775 Authored by: coletdjnz
-rw-r--r--yt_dlp/extractor/youtube.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index 0f046d87f..c9bdd309d 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -5673,11 +5673,13 @@ class YoutubeNotificationsIE(YoutubeTabBaseInfoExtractor):
channel = traverse_obj(
notification, ('contextualMenu', 'menuRenderer', 'items', 1, 'menuServiceItemRenderer', 'text', 'runs', 1, 'text'),
expected_type=str)
+ notification_title = self._get_text(notification, 'shortMessage')
+ if notification_title:
+ notification_title = notification_title.replace('\xad', '') # remove soft hyphens
+ # TODO: handle recommended videos
title = self._search_regex(
- rf'{re.escape(channel)} [^:]+: (.+)', self._get_text(notification, 'shortMessage'),
+ rf'{re.escape(channel or "")}[^:]+: (.+)', notification_title,
'video title', default=None)
- if title:
- title = title.replace('\xad', '') # remove soft hyphens
upload_date = (strftime_or_none(self._extract_time_text(notification, 'sentTimeText')[0], '%Y%m%d')
if self._configuration_arg('approximate_date', ie_key=YoutubeTabIE.ie_key())
else None)