From 5225df50cf96d2f462dc3df3c22f8d1e2028872d Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 13 Oct 2022 04:23:39 +0530 Subject: [PATCH] [extractor/youtube:tab] Let `approximate_date` return timestamp --- README.md | 2 +- yt_dlp/extractor/common.py | 4 ++-- yt_dlp/extractor/youtube.py | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9b59e096a..7374e0e94 100644 --- a/README.md +++ b/README.md @@ -1724,7 +1724,7 @@ The following extractors use this feature: #### youtubetab (YouTube playlists, channels, feeds, etc.) * `skip`: One or more of `webpage` (skip initial webpage download), `authcheck` (allow the download of playlists requiring authentication when no initial webpage is downloaded. This may cause unwanted behavior, see [#1122](https://github.com/yt-dlp/yt-dlp/pull/1122) for more details) -* `approximate_date`: Extract approximate `upload_date` in flat-playlist. This may cause date-based filters to be slightly off +* `approximate_date`: Extract approximate `upload_date` and `timestamp` in flat-playlist. This may cause date-based filters to be slightly off #### funimation * `language`: Audio languages to extract, e.g. `funimation:language=english,japanese` diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 10d44d95a..ab8def57d 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -3843,8 +3843,8 @@ class InfoExtractor: @param default The default value to return when the key is not present (default: []) @param casesense When false, the values are converted to lower case ''' - val = traverse_obj( - self._downloader.params, ('extractor_args', (ie_key or self.ie_key()).lower(), key)) + ie_key = ie_key if isinstance(ie_key, str) else (ie_key or self).ie_key() + val = traverse_obj(self._downloader.params, ('extractor_args', ie_key.lower(), key)) if val is None: return [] if default is NO_DEFAULT else default return list(val) if casesense else [x.lower() for x in val] diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 35e41753a..73c37ac90 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -948,9 +948,9 @@ class YoutubeBaseInfoExtractor(InfoExtractor): 'uploader': uploader, 'channel_id': channel_id, 'thumbnails': thumbnails, - 'upload_date': (strftime_or_none(self._parse_time_text(time_text), '%Y%m%d') - if self._configuration_arg('approximate_date', ie_key='youtubetab') - else None), + 'timestamp': (self._parse_time_text(time_text) + if self._configuration_arg('approximate_date', ie_key=YoutubeTabIE) + else None), 'release_timestamp': scheduled_timestamp, 'availability': 'public' if self._has_badge(badges, BadgeType.AVAILABILITY_PUBLIC) @@ -6105,9 +6105,9 @@ class YoutubeNotificationsIE(YoutubeTabBaseInfoExtractor): title = self._search_regex( rf'{re.escape(channel or "")}[^:]+: (.+)', notification_title, 'video title', default=None) - upload_date = (strftime_or_none(self._parse_time_text(self._get_text(notification, 'sentTimeText')), '%Y%m%d') - if self._configuration_arg('approximate_date', ie_key=YoutubeTabIE.ie_key()) - else None) + timestamp = (self._parse_time_text(self._get_text(notification, 'sentTimeText')) + if self._configuration_arg('approximate_date', ie_key=YoutubeTabIE) + else None) return { '_type': 'url', 'url': url, @@ -6117,7 +6117,7 @@ class YoutubeNotificationsIE(YoutubeTabBaseInfoExtractor): 'channel_id': channel_id, 'channel': channel, 'thumbnails': self._extract_thumbnails(notification, 'videoThumbnail'), - 'upload_date': upload_date, + 'timestamp': timestamp, } def _notification_menu_entries(self, ytcfg):