From cfc297d8f56c9f36be82f2dca8553e711bebfaca Mon Sep 17 00:00:00 2001 From: playma Date: Fri, 27 Sep 2019 08:28:19 +0800 Subject: [PATCH 1/6] [fc2] Fix video download --- youtube_dl/extractor/fc2.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/youtube_dl/extractor/fc2.py b/youtube_dl/extractor/fc2.py index 435561147..9538439e1 100644 --- a/youtube_dl/extractor/fc2.py +++ b/youtube_dl/extractor/fc2.py @@ -86,8 +86,8 @@ class FC2IE(InfoExtractor): title = 'FC2 video %s' % video_id thumbnail = None if webpage is not None: - title = self._og_search_title(webpage) thumbnail = self._og_search_thumbnail(webpage) + refer = url.replace('/content/', '/a/content/') if '/a/content/' not in url else url mimi = hashlib.md5((video_id + '_gGddgPfeaf_gzyr').encode('utf-8')).hexdigest() @@ -100,24 +100,25 @@ class FC2IE(InfoExtractor): info_url, video_id, note='Downloading info page') info = compat_urlparse.parse_qs(info_webpage) - if 'err_code' in info: - # most of the time we can still download wideo even if err_code is 403 or 602 - self.report_warning( - 'Error code was: %s... but still trying' % info['err_code'][0]) - - if 'filepath' not in info: - raise ExtractorError('Cannot download file. Are you logged in?') - - video_url = info['filepath'][0] + '?mid=' + info['mid'][0] + video_info_url = 'https://video.fc2.com/api/v3/videoplaylist/{}?sh=1&fs=0'.format(video_id) + info_webpage = self._download_webpage( + info_url, video_id, note='Downloading info page') + info = compat_urlparse.parse_qs(info_webpage) title_info = info.get('title') if title_info: title = title_info[0] + response = self._download_json( + video_info_url, + video_id, + ) + video_url = 'https://video.fc2.com' + response['playlist']['nq'] + return { 'id': video_id, 'title': title, 'url': video_url, - 'ext': 'flv', + 'ext': 'mp4', 'thumbnail': thumbnail, } From 252eb13277cfb2a6dd40d5ff6d16624a6f8e86aa Mon Sep 17 00:00:00 2001 From: playma Date: Fri, 27 Sep 2019 08:32:26 +0800 Subject: [PATCH 2/6] Remove useless import --- youtube_dl/extractor/fc2.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/fc2.py b/youtube_dl/extractor/fc2.py index 9538439e1..0547e1681 100644 --- a/youtube_dl/extractor/fc2.py +++ b/youtube_dl/extractor/fc2.py @@ -11,7 +11,6 @@ from ..compat import ( compat_urlparse, ) from ..utils import ( - ExtractorError, sanitized_Request, urlencode_postdata, ) From 7164b24ca67bd39ca70ab646266d10d86970a48f Mon Sep 17 00:00:00 2001 From: playma Date: Fri, 27 Sep 2019 08:55:48 +0800 Subject: [PATCH 3/6] Comply with coding conventions --- youtube_dl/extractor/fc2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/fc2.py b/youtube_dl/extractor/fc2.py index 0547e1681..ab1b10f49 100644 --- a/youtube_dl/extractor/fc2.py +++ b/youtube_dl/extractor/fc2.py @@ -107,11 +107,11 @@ class FC2IE(InfoExtractor): if title_info: title = title_info[0] - response = self._download_json( + meta = self._download_json( video_info_url, video_id, ) - video_url = 'https://video.fc2.com' + response['playlist']['nq'] + video_url = 'https://video.fc2.com' + meta.get('playlist').get('nq') return { 'id': video_id, From 9f3eefd342a88e22c7e66c8d8dab7bd62b008193 Mon Sep 17 00:00:00 2001 From: playma Date: Fri, 27 Sep 2019 08:59:04 +0800 Subject: [PATCH 4/6] Revmove duplicate code --- youtube_dl/extractor/fc2.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/youtube_dl/extractor/fc2.py b/youtube_dl/extractor/fc2.py index ab1b10f49..692ca76b8 100644 --- a/youtube_dl/extractor/fc2.py +++ b/youtube_dl/extractor/fc2.py @@ -98,15 +98,11 @@ class FC2IE(InfoExtractor): info_webpage = self._download_webpage( info_url, video_id, note='Downloading info page') info = compat_urlparse.parse_qs(info_webpage) - - video_info_url = 'https://video.fc2.com/api/v3/videoplaylist/{}?sh=1&fs=0'.format(video_id) - info_webpage = self._download_webpage( - info_url, video_id, note='Downloading info page') - info = compat_urlparse.parse_qs(info_webpage) title_info = info.get('title') if title_info: title = title_info[0] + video_info_url = 'https://video.fc2.com/api/v3/videoplaylist/{}?sh=1&fs=0'.format(video_id) meta = self._download_json( video_info_url, video_id, From 43e9d3df63d24d16cba9b963ad51baeca77d27f1 Mon Sep 17 00:00:00 2001 From: playma Date: Thu, 3 Oct 2019 11:59:51 +0800 Subject: [PATCH 5/6] Revise coding styles --- youtube_dl/extractor/fc2.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/fc2.py b/youtube_dl/extractor/fc2.py index 692ca76b8..a8a025871 100644 --- a/youtube_dl/extractor/fc2.py +++ b/youtube_dl/extractor/fc2.py @@ -7,11 +7,13 @@ import re from .common import InfoExtractor from ..compat import ( compat_parse_qs, + compat_str, compat_urllib_request, compat_urlparse, ) from ..utils import ( sanitized_Request, + try_get, urlencode_postdata, ) @@ -86,7 +88,6 @@ class FC2IE(InfoExtractor): thumbnail = None if webpage is not None: thumbnail = self._og_search_thumbnail(webpage) - refer = url.replace('/content/', '/a/content/') if '/a/content/' not in url else url mimi = hashlib.md5((video_id + '_gGddgPfeaf_gzyr').encode('utf-8')).hexdigest() @@ -102,12 +103,8 @@ class FC2IE(InfoExtractor): if title_info: title = title_info[0] - video_info_url = 'https://video.fc2.com/api/v3/videoplaylist/{}?sh=1&fs=0'.format(video_id) - meta = self._download_json( - video_info_url, - video_id, - ) - video_url = 'https://video.fc2.com' + meta.get('playlist').get('nq') + meta = self._download_json('https://video.fc2.com/api/v3/videoplaylist/%s?sh=1&fs=0' % video_id, video_id) + video_url = 'https://video.fc2.com' + try_get(meta, lambda x: x['playlist']['nq'], compat_str) return { 'id': video_id, From 391f1ac4b49d06cf09f7223f72714661231d7aa1 Mon Sep 17 00:00:00 2001 From: playma Date: Mon, 7 Oct 2019 11:15:53 +0800 Subject: [PATCH 6/6] Use query in _download_json --- youtube_dl/extractor/fc2.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/fc2.py b/youtube_dl/extractor/fc2.py index a8a025871..300906a9f 100644 --- a/youtube_dl/extractor/fc2.py +++ b/youtube_dl/extractor/fc2.py @@ -27,7 +27,7 @@ class FC2IE(InfoExtractor): 'md5': 'a6ebe8ebe0396518689d963774a54eb7', 'info_dict': { 'id': '20121103kUan1KHs', - 'ext': 'flv', + 'ext': 'mp4', 'title': 'Boxing again with Puff', }, }, { @@ -103,7 +103,13 @@ class FC2IE(InfoExtractor): if title_info: title = title_info[0] - meta = self._download_json('https://video.fc2.com/api/v3/videoplaylist/%s?sh=1&fs=0' % video_id, video_id) + meta = self._download_json( + 'https://video.fc2.com/api/v3/videoplaylist/%s' % video_id, + video_id, + query={ + 'sh': 1, + 'fs': 0, + }) video_url = 'https://video.fc2.com' + try_get(meta, lambda x: x['playlist']['nq'], compat_str) return {