From d788a30e6894c92a31bf01bbd7dfea6cc967f3a4 Mon Sep 17 00:00:00 2001
From: Ocha <1356318+ochachacha@users.noreply.github.com>
Date: Fri, 30 Nov 2018 07:48:18 +0000
Subject: [PATCH 1/2] [niconico] Fixing swf support
---
youtube_dl/extractor/niconico.py | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/youtube_dl/extractor/niconico.py b/youtube_dl/extractor/niconico.py
index 76b412ff1..9fe904756 100644
--- a/youtube_dl/extractor/niconico.py
+++ b/youtube_dl/extractor/niconico.py
@@ -8,6 +8,7 @@ from .common import InfoExtractor
from ..compat import (
compat_parse_qs,
compat_urlparse,
+ compat_urllib_parse,
)
from ..utils import (
determine_ext,
@@ -284,14 +285,22 @@ class NiconicoIE(InfoExtractor):
def _format_id_from_url(video_url):
return 'economy' if video_real_url.endswith('low') else 'normal'
+ watch_api_data_string = self._html_search_regex(
+ r'
]+id="watchAPIDataContainer"[^>]+>([^<]+)
',
+ webpage, 'watch api data', default=None)
+ watch_api_data = self._parse_json(watch_api_data_string, video_id) if watch_api_data_string else {}
+ video_detail = watch_api_data.get('videoDetail', {})
+
try:
video_real_url = api_data['video']['smileInfo']['url']
except KeyError: # Flash videos
# Get flv info
- flv_info_webpage = self._download_webpage(
- 'http://flapi.nicovideo.jp/api/getflv/' + video_id + '?as3=1',
- video_id, 'Downloading flv info')
-
+ # flv_info_webpage = self._download_webpage(
+ # 'http://flapi.nicovideo.jp/api/getflv/' + video_id + '?as3=1',
+ # video_id, 'Downloading flv info')
+ # Nov 2018: the method above no longer returns the correct swf address; use below instead
+ flv_info_webpage = watch_api_data.get('flashvars', {}).get(u'flvInfo')
+ flv_info_webpage = compat_urllib_parse.unquote(flv_info_webpage)
flv_info = compat_urlparse.parse_qs(flv_info_webpage)
if 'url' not in flv_info:
if 'deleted' in flv_info:
@@ -362,12 +371,6 @@ class NiconicoIE(InfoExtractor):
r']+class="videoHeaderTitle"[^>]*>([^<]+)',
webpage, 'video title')
- watch_api_data_string = self._html_search_regex(
- r']+id="watchAPIDataContainer"[^>]+>([^<]+)
',
- webpage, 'watch api data', default=None)
- watch_api_data = self._parse_json(watch_api_data_string, video_id) if watch_api_data_string else {}
- video_detail = watch_api_data.get('videoDetail', {})
-
thumbnail = (
get_video_info(['thumbnail_url', 'thumbnailURL']) or
self._html_search_meta('image', webpage, 'thumbnail', default=None) or
From b117475a8084934101ad2ba1d322f2f74f8e1417 Mon Sep 17 00:00:00 2001
From: Ocha <1356318+ochachacha@users.noreply.github.com>
Date: Fri, 30 Nov 2018 08:15:08 +0000
Subject: [PATCH 2/2] fix for python32
---
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 9fe904756..e7e54ca49 100644
--- a/youtube_dl/extractor/niconico.py
+++ b/youtube_dl/extractor/niconico.py
@@ -299,7 +299,7 @@ class NiconicoIE(InfoExtractor):
# 'http://flapi.nicovideo.jp/api/getflv/' + video_id + '?as3=1',
# video_id, 'Downloading flv info')
# Nov 2018: the method above no longer returns the correct swf address; use below instead
- flv_info_webpage = watch_api_data.get('flashvars', {}).get(u'flvInfo')
+ flv_info_webpage = watch_api_data.get('flashvars', {}).get('flvInfo')
flv_info_webpage = compat_urllib_parse.unquote(flv_info_webpage)
flv_info = compat_urlparse.parse_qs(flv_info_webpage)
if 'url' not in flv_info: