diff --git a/yt_dlp/extractor/facebook.py b/yt_dlp/extractor/facebook.py index 24ecb0350..c73b66d5b 100644 --- a/yt_dlp/extractor/facebook.py +++ b/yt_dlp/extractor/facebook.py @@ -32,6 +32,7 @@ class FacebookIE(InfoExtractor): + _MAX_TITLE_LENGTH = 20 # Maximum title length for the video _VALID_URL = r'''(?x) (?: https?:// @@ -541,6 +542,9 @@ def extract_metadata(webpage): info_json_ld = self._search_json_ld(webpage, video_id, default={}) info_json_ld['title'] = (re.sub(r'\s*\|\s*Facebook$', '', title or info_json_ld.get('title') or page_title or '') or (description or '').replace('\n', ' ') or f'Facebook video #{video_id}') + if len(info_json_ld.get('title')) > FacebookIE._MAX_TITLE_LENGTH: + self.report_warning(f'Truncating title to {FacebookIE._MAX_TITLE_LENGTH} characters') + info_json_ld['title'] = info_json_ld.get('title')[: FacebookIE._MAX_TITLE_LENGTH - 3] + '...' return merge_dicts(info_json_ld, info_dict) video_data = None