aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkurumigi <83115+kurumigi@users.noreply.github.com>2021-02-16 19:49:37 +0900
committerGitHub <noreply@github.com>2021-02-16 16:19:37 +0530
commit78b9a616cc9a02a7eddaa096b9d7c4fecb575e60 (patch)
treeda1d909fa0bbda86c487b897dbe75f449d65153d
parent55b53b338b2c6b094443e4bf163a385986b8b74f (diff)
downloadhypervideo-pre-78b9a616cc9a02a7eddaa096b9d7c4fecb575e60.tar.lz
hypervideo-pre-78b9a616cc9a02a7eddaa096b9d7c4fecb575e60.tar.xz
hypervideo-pre-78b9a616cc9a02a7eddaa096b9d7c4fecb575e60.zip
#90 [niconico] Extract `channel` and `channel_id` (Closes #77)
Authored by kurumigi
-rw-r--r--youtube_dlc/extractor/niconico.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/youtube_dlc/extractor/niconico.py b/youtube_dlc/extractor/niconico.py
index 632b9efcc..38370b346 100644
--- a/youtube_dlc/extractor/niconico.py
+++ b/youtube_dlc/extractor/niconico.py
@@ -546,11 +546,29 @@ class NiconicoIE(InfoExtractor):
webpage_url = get_video_info_web('watch_url') or url
+ # for channel movie and community movie
+ channel_id = try_get(
+ api_data,
+ (lambda x: x['channel']['globalId'],
+ lambda x: x['community']['globalId']))
+ channel = try_get(
+ api_data,
+ (lambda x: x['channel']['name'],
+ lambda x: x['community']['name']))
+
# 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 = try_get(api_data, lambda x: x.get('owner'), dict) or {}
- uploader_id = get_video_info_web(['ch_id', 'user_id']) or owner.get('id')
- uploader = get_video_info_web(['ch_name', 'user_nickname']) or owner.get('nickname')
+ uploader_id = (
+ get_video_info_web(['ch_id', 'user_id'])
+ or owner.get('id')
+ or channel_id
+ )
+ uploader = (
+ get_video_info_web(['ch_name', 'user_nickname'])
+ or owner.get('nickname')
+ or channel
+ )
return {
'id': video_id,
@@ -561,6 +579,8 @@ class NiconicoIE(InfoExtractor):
'uploader': uploader,
'timestamp': timestamp,
'uploader_id': uploader_id,
+ 'channel': channel,
+ 'channel_id': channel_id,
'view_count': view_count,
'comment_count': comment_count,
'duration': duration,