aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Nelson <25140503+trevnels@users.noreply.github.com>2020-12-17 11:21:36 -0500
committerGitHub <noreply@github.com>2020-12-17 23:21:36 +0700
commit76fe4ba3b22a689ba7b5c6ea9064796ce1f4af55 (patch)
tree8eae064fdb477535a689afbd711d2e2bd72c7b29
parent164a4a5756f5a29b928dc1351522c094c0026266 (diff)
downloadyoutube-dl-76fe4ba3b22a689ba7b5c6ea9064796ce1f4af55.tar.xz
[redditr] Extract duration (#27426)
-rw-r--r--youtube_dl/extractor/reddit.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/youtube_dl/extractor/reddit.py b/youtube_dl/extractor/reddit.py
index 663f622b3..3b2abb262 100644
--- a/youtube_dl/extractor/reddit.py
+++ b/youtube_dl/extractor/reddit.py
@@ -7,6 +7,7 @@ from ..utils import (
ExtractorError,
int_or_none,
float_or_none,
+ try_get,
url_or_none,
)
@@ -59,6 +60,7 @@ class RedditRIE(InfoExtractor):
'timestamp': 1501941939,
'upload_date': '20170805',
'uploader': 'Antw87',
+ 'duration': 12,
'like_count': int,
'dislike_count': int,
'comment_count': int,
@@ -123,6 +125,10 @@ class RedditRIE(InfoExtractor):
'thumbnail': url_or_none(data.get('thumbnail')),
'timestamp': float_or_none(data.get('created_utc')),
'uploader': data.get('author'),
+ 'duration': int_or_none(try_get(
+ data,
+ (lambda x: x['media']['reddit_video']['duration'],
+ lambda x: x['secure_media']['reddit_video']['duration']))),
'like_count': int_or_none(data.get('ups')),
'dislike_count': int_or_none(data.get('downs')),
'comment_count': int_or_none(data.get('num_comments')),