aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/youtube.py
diff options
context:
space:
mode:
authorcoletdev <coletdjnz@protonmail.com>2022-03-28 13:49:42 +1300
committerGitHub <noreply@github.com>2022-03-28 00:49:42 +0000
commit1c1b2f96ae9696ef16b1b27d1a007bf89c683a0c (patch)
treed6aa656d3213ccacb278fa1d6b50c05c43f70a6a /yt_dlp/extractor/youtube.py
parent47b8bf207b1206466f1aeaaf0c8ffec91be2fed0 (diff)
downloadhypervideo-pre-1c1b2f96ae9696ef16b1b27d1a007bf89c683a0c.tar.lz
hypervideo-pre-1c1b2f96ae9696ef16b1b27d1a007bf89c683a0c.tar.xz
hypervideo-pre-1c1b2f96ae9696ef16b1b27d1a007bf89c683a0c.zip
[youtube:tab] Fix duration extraction for shorts (#3171)
Related: https://github.com/TeamNewPipe/NewPipe/issues/8034 Authored-by: coletdjnz
Diffstat (limited to 'yt_dlp/extractor/youtube.py')
-rw-r--r--yt_dlp/extractor/youtube.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index 4d7e79fbf..e5097c264 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -807,6 +807,12 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
description = self._get_text(renderer, 'descriptionSnippet')
duration = parse_duration(self._get_text(
renderer, 'lengthText', ('thumbnailOverlays', ..., 'thumbnailOverlayTimeStatusRenderer', 'text')))
+ if duration is None:
+ duration = parse_duration(self._search_regex(
+ r'(?i)(ago)(?!.*\1)\s+(?P<duration>[a-z0-9 ,]+?)(?:\s+[\d,]+\s+views)?(?:\s+-\s+play\s+short)?$',
+ traverse_obj(renderer, ('title', 'accessibility', 'accessibilityData', 'label'), default='', expected_type=str),
+ video_id, default=None, group='duration'))
+
view_count = self._get_count(renderer, 'viewCountText')
uploader = self._get_text(renderer, 'ownerText', 'shortBylineText')