From 78331973ab288f2da2349b44b3b4a6538046a2ec Mon Sep 17 00:00:00 2001
From: Pawit Pornkitprasan
Date: Sun, 15 Oct 2017 09:36:42 +0700
Subject: [PATCH 1/3] [niconico] Fix downloading videos with null owner
Niconico may return JSON where owner is set to null. In that case, api_data.get
will return None even though a default is provided. Fix the check so that we
always change None into an empty dict.
---
youtube_dl/extractor/niconico.py | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/youtube_dl/extractor/niconico.py b/youtube_dl/extractor/niconico.py
index 026329d3e..d3de18320 100644
--- a/youtube_dl/extractor/niconico.py
+++ b/youtube_dl/extractor/niconico.py
@@ -40,7 +40,7 @@ class NiconicoIE(InfoExtractor):
'uploader': 'takuya0301',
'uploader_id': '2698420',
'upload_date': '20131123',
- 'timestamp': 1385182762,
+ 'timestamp': 1385215162,
'description': '(c) copyright 2008, Blender Foundation / www.bigbuckbunny.org',
'duration': 33,
'view_count': int,
@@ -116,7 +116,7 @@ class NiconicoIE(InfoExtractor):
}, {
# "New" HTML5 video
'url': 'http://www.nicovideo.jp/watch/sm31464864',
- 'md5': '351647b4917660986dc0fa8864085135',
+ 'md5': '8b1d60d94c570858f98bfa47cc742400',
'info_dict': {
'id': 'sm31464864',
'ext': 'mp4',
@@ -124,7 +124,7 @@ class NiconicoIE(InfoExtractor):
'description': 'md5:e52974af9a96e739196b2c1ca72b5feb',
'timestamp': 1498514060,
'upload_date': '20170626',
- 'uploader': 'ゲス',
+ 'uploader': 'ゲスト',
'uploader_id': '40826363',
'thumbnail': r're:https?://.*',
'duration': 198,
@@ -132,6 +132,25 @@ class NiconicoIE(InfoExtractor):
'comment_count': int,
},
'skip': 'Requires an account',
+ }, {
+ # Video without owner
+ 'url': 'http://www.nicovideo.jp/watch/sm18238488',
+ 'md5': 'd265680a1f92bdcbbd2a507fc9e78a9e',
+ 'info_dict': {
+ 'id': 'sm18238488',
+ 'ext': 'mp4',
+ 'title': '【実写版】ミュータントタートルズ',
+ 'description': 'md5:15df8988e47a86f9e978af2064bf6d8e',
+ 'timestamp': 1341160408,
+ 'upload_date': '20120701',
+ 'uploader': None,
+ 'uploader_id': None,
+ 'thumbnail': r're:https?://.*',
+ 'duration': 5271,
+ 'view_count': int,
+ 'comment_count': int,
+ },
+ 'skip': 'Requires an account',
}, {
'url': 'http://sp.nicovideo.jp/watch/sm28964488?ss_pos=1&cp_in=wt_tg',
'only_matching': True,
@@ -395,7 +414,9 @@ class NiconicoIE(InfoExtractor):
webpage_url = get_video_info('watch_url') or url
- owner = api_data.get('owner', {})
+ # Note: cannot use api_data.get('owner', {}) because owner may be set to "null"
+ # in the JSON, which will cause None to be returned instead of {}.
+ owner = api_data.get('owner') or {}
uploader_id = get_video_info(['ch_id', 'user_id']) or owner.get('id')
uploader = get_video_info(['ch_name', 'user_nickname']) or owner.get('nickname')
From 772f15dc8a1857c32dea507a62cd54a9275ab126 Mon Sep 17 00:00:00 2001
From: Pawit Pornkitprasan
Date: Sun, 15 Oct 2017 10:16:28 +0700
Subject: [PATCH 2/3] [niconico] handle theoretical case where owner is
True-ish non-dict
---
youtube_dl/extractor/niconico.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/youtube_dl/extractor/niconico.py b/youtube_dl/extractor/niconico.py
index d3de18320..707c6bef9 100644
--- a/youtube_dl/extractor/niconico.py
+++ b/youtube_dl/extractor/niconico.py
@@ -40,7 +40,7 @@ class NiconicoIE(InfoExtractor):
'uploader': 'takuya0301',
'uploader_id': '2698420',
'upload_date': '20131123',
- 'timestamp': 1385215162,
+ 'timestamp': int, # timestamp is unstable
'description': '(c) copyright 2008, Blender Foundation / www.bigbuckbunny.org',
'duration': 33,
'view_count': int,
@@ -115,8 +115,8 @@ class NiconicoIE(InfoExtractor):
'skip': 'Requires an account',
}, {
# "New" HTML5 video
+ # md5 is unstable
'url': 'http://www.nicovideo.jp/watch/sm31464864',
- 'md5': '8b1d60d94c570858f98bfa47cc742400',
'info_dict': {
'id': 'sm31464864',
'ext': 'mp4',
@@ -416,7 +416,7 @@ class NiconicoIE(InfoExtractor):
# Note: cannot use api_data.get('owner', {}) because owner may be set to "null"
# in the JSON, which will cause None to be returned instead of {}.
- owner = api_data.get('owner') or {}
+ owner = try_get(api_data, lambda x: x.get('owner'), dict) or {}
uploader_id = get_video_info(['ch_id', 'user_id']) or owner.get('id')
uploader = get_video_info(['ch_name', 'user_nickname']) or owner.get('nickname')
From 11a69eccdad08f44568173f7aca10cf0126fd836 Mon Sep 17 00:00:00 2001
From: Pawit Pornkitprasan
Date: Sun, 15 Oct 2017 10:34:33 +0700
Subject: [PATCH 3/3] [niconico] fix formatting issue
---
youtube_dl/extractor/niconico.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/youtube_dl/extractor/niconico.py b/youtube_dl/extractor/niconico.py
index 707c6bef9..df7f528be 100644
--- a/youtube_dl/extractor/niconico.py
+++ b/youtube_dl/extractor/niconico.py
@@ -40,7 +40,7 @@ class NiconicoIE(InfoExtractor):
'uploader': 'takuya0301',
'uploader_id': '2698420',
'upload_date': '20131123',
- 'timestamp': int, # timestamp is unstable
+ 'timestamp': int, # timestamp is unstable
'description': '(c) copyright 2008, Blender Foundation / www.bigbuckbunny.org',
'duration': 33,
'view_count': int,