aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcoletdev <coletdjnz@protonmail.com>2022-03-27 18:20:25 +1300
committerGitHub <noreply@github.com>2022-03-27 05:20:25 +0000
commitfd2ad7cb245423e49db1be9d9654c7dd3103619a (patch)
tree12ac088b6c17b5c4e4a394b108a53663eb3c07d5
parent4a3175fc4cff22343bd23c6cb7d40dbd7d0ccbf5 (diff)
downloadhypervideo-pre-fd2ad7cb245423e49db1be9d9654c7dd3103619a.tar.lz
hypervideo-pre-fd2ad7cb245423e49db1be9d9654c7dd3103619a.tar.xz
hypervideo-pre-fd2ad7cb245423e49db1be9d9654c7dd3103619a.zip
[youtube:tab] Return shorts url if video is a short (#3168)
Allows filtering out shorts from feeds with `--match-filter` Closes #3165 Authored-by: coletdjnz
-rw-r--r--yt_dlp/extractor/youtube.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index 8ee688798..0726e27b4 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -818,12 +818,17 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
renderer, ('thumbnailOverlays', ..., 'thumbnailOverlayTimeStatusRenderer', 'style'), get_all=False, expected_type=str)
badges = self._extract_badges(renderer)
thumbnails = self._extract_thumbnails(renderer, 'thumbnail')
+ navigation_url = urljoin('https://www.youtube.com/', traverse_obj(
+ renderer, ('navigationEndpoint', 'commandMetadata', 'webCommandMetadata', 'url'), expected_type=str))
+ url = f'https://www.youtube.com/watch?v={video_id}'
+ if overlay_style == 'SHORTS' or (navigation_url and '/shorts/' in navigation_url):
+ url = f'https://www.youtube.com/shorts/{video_id}'
return {
'_type': 'url',
'ie_key': YoutubeIE.ie_key(),
'id': video_id,
- 'url': f'https://www.youtube.com/watch?v={video_id}',
+ 'url': url,
'title': title,
'description': description,
'duration': duration,