aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/youtube.py
diff options
context:
space:
mode:
authorcoletdjnz <coletdjnz@protonmail.com>2022-09-01 10:02:28 +0000
committerGitHub <noreply@github.com>2022-09-01 10:02:28 +0000
commit1ff88b7aec76bc8396c58f4757e2c08b20e5533e (patch)
tree46379cd1b1e28e34b31c98d30c926162709eac26 /yt_dlp/extractor/youtube.py
parent825d3ce386e66ac0c73e41e352d84053f9f0e624 (diff)
downloadhypervideo-pre-1ff88b7aec76bc8396c58f4757e2c08b20e5533e.tar.lz
hypervideo-pre-1ff88b7aec76bc8396c58f4757e2c08b20e5533e.tar.xz
hypervideo-pre-1ff88b7aec76bc8396c58f4757e2c08b20e5533e.zip
[extractor/youtube] Add `no-youtube-prefer-utc-upload-date` compat option (#4771)
This option reverts https://github.com/yt-dlp/yt-dlp/commit/992f9a730b49fd36fc422be8d802f98ebcdce418 and https://github.com/yt-dlp/yt-dlp/commit/17322130a954577bb03b833d5c435638e51e19f2 to prefer the non-UTC upload date in microformats. Authored by: coletdjnz, pukkandan
Diffstat (limited to 'yt_dlp/extractor/youtube.py')
-rw-r--r--yt_dlp/extractor/youtube.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index ee9cce16e..b1eda0d07 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -2160,6 +2160,35 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
'channel_follower_count': int
}
}, {
+ # Same video as above, but with --compat-opt no-youtube-prefer-utc-upload-date
+ 'url': 'https://www.youtube.com/watch?v=2NUZ8W2llS4',
+ 'info_dict': {
+ 'id': '2NUZ8W2llS4',
+ 'ext': 'mp4',
+ 'title': 'The NP that test your phone performance 🙂',
+ 'description': 'md5:144494b24d4f9dfacb97c1bbef5de84d',
+ 'uploader': 'Leon Nguyen',
+ 'uploader_id': 'VNSXIII',
+ 'uploader_url': 'http://www.youtube.com/user/VNSXIII',
+ 'channel_id': 'UCRqNBSOHgilHfAczlUmlWHA',
+ 'channel_url': 'https://www.youtube.com/channel/UCRqNBSOHgilHfAczlUmlWHA',
+ 'duration': 21,
+ 'view_count': int,
+ 'age_limit': 0,
+ 'categories': ['Gaming'],
+ 'tags': 'count:23',
+ 'playable_in_embed': True,
+ 'live_status': 'not_live',
+ 'upload_date': '20220102',
+ 'like_count': int,
+ 'availability': 'public',
+ 'channel': 'Leon Nguyen',
+ 'thumbnail': 'https://i.ytimg.com/vi_webp/2NUZ8W2llS4/maxresdefault.webp',
+ 'comment_count': int,
+ 'channel_follower_count': int
+ },
+ 'params': {'compat_opts': ['no-youtube-prefer-utc-upload-date']}
+ }, {
# date text is premiered video, ensure upload date in UTC (published 1641172509)
'url': 'https://www.youtube.com/watch?v=mzZzzBU6lrM',
'info_dict': {
@@ -3920,7 +3949,12 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
upload_date = (
unified_strdate(get_first(microformats, 'uploadDate'))
or unified_strdate(search_meta('uploadDate')))
- if not upload_date or (not info.get('is_live') and not info.get('was_live') and info.get('live_status') != 'is_upcoming'):
+ if not upload_date or (
+ not info.get('is_live')
+ and not info.get('was_live')
+ and info.get('live_status') != 'is_upcoming'
+ and 'no-youtube-prefer-utc-upload-date' not in self.get_param('compat_opts', [])
+ ):
upload_date = strftime_or_none(self._extract_time_text(vpir, 'dateText')[0], '%Y%m%d') or upload_date
info['upload_date'] = upload_date