From 93b5b15131f869f703872c4b85d98eaeaa196e94 Mon Sep 17 00:00:00 2001 From: Igor Cescon de Moura Date: Wed, 10 Aug 2022 21:21:51 -0300 Subject: [PATCH 1/4] [hololivefc] Add new extractor for hololive fanclub --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/hololivefc.py | 51 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 youtube_dl/extractor/hololivefc.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 751fc38b6..79a02b6ef 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -471,6 +471,7 @@ from .hidive import HiDiveIE from .historicfilms import HistoricFilmsIE from .hitbox import HitboxIE, HitboxLiveIE from .hitrecord import HitRecordIE +from .hololivefc import HololiveFCIE from .hornbunny import HornBunnyIE from .hotnewhiphop import HotNewHipHopIE from .hotstar import ( diff --git a/youtube_dl/extractor/hololivefc.py b/youtube_dl/extractor/hololivefc.py new file mode 100644 index 000000000..c84f333b3 --- /dev/null +++ b/youtube_dl/extractor/hololivefc.py @@ -0,0 +1,51 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from youtube_dl.utils import try_get, unified_timestamp + +from .common import InfoExtractor + + +class HololiveFCIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?hololive-fc\.com/video/(?P[a-zA-Z0-9]+)' + _TEST = { + 'url': 'https://hololive-fc.com/video/smikfVmVrbNwJpiZ6KNzHHNT', + 'md5': 'e4c26ea3bc17557873cc7bbc72de2165', + 'info_dict': { + 'id': 'smikfVmVrbNwJpiZ6KNzHHNT', + 'ext': 'mp4', + 'title': '【ホロライブ・サマー2022】これが本当のホロライブサマー!? #1', + 'thumbnail': r're:^https?://', + 'description': 'md5:24f1c21b051de003cd81ed6ed11278ce', + 'release_timestamp': 1660042200, + 'view_count': int, + 'comment_count': int, + 'tags': ['ロボ子さん', 'アキ・ローゼンタール', '赤井はあと', '癒月ちょこ', '宝鐘マリン', '白銀ノエル', '尾丸ポルカ', 'ラプラス・ダークネス'], + } + } + _API_BASE_URL = 'https://nfc-api.hololive-fc.com/fc/video_pages/' + + def _real_extract(self, url): + video_id = self._match_id(url) + + video_info_url = self._API_BASE_URL + video_id + video_info = self._download_json(video_info_url, video_id)['data']['video_page'] + + session_id_url = self._API_BASE_URL + video_id + '/session_ids' + session_id = self._download_json(session_id_url, video_id, data={})['data']['session_id'] + + m3u8_url = video_info['video_stream']['authenticated_url'].format(session_id=session_id) + formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4') + self._sort_formats(formats) + + return { + 'id': video_id, + 'title': video_info['title'], + 'formats': formats, + 'thumbnail': video_info.get('thumbnail_url'), + 'description': video_info.get('description'), + 'release_timestamp': unified_timestamp(video_info.get('released_at')), + 'view_count': try_get(video_info, lambda x: x['video_aggregate_info']['total_views'], int), + 'comment_count': try_get(video_info, lambda x: x['video_aggregate_info']['number_of_comments'], int), + 'tags': try_get(video_info, lambda x: [tag['tag'] for tag in x['video_tags']], list), + } From e7ad2be1fad2d9081ba6cbe560933f19d8bcb39e Mon Sep 17 00:00:00 2001 From: Igor Cescon de Moura Date: Wed, 10 Aug 2022 22:20:59 -0300 Subject: [PATCH 2/4] Use relative imports --- youtube_dl/extractor/hololivefc.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/youtube_dl/extractor/hololivefc.py b/youtube_dl/extractor/hololivefc.py index c84f333b3..16c41ec5f 100644 --- a/youtube_dl/extractor/hololivefc.py +++ b/youtube_dl/extractor/hololivefc.py @@ -1,9 +1,8 @@ # coding: utf-8 from __future__ import unicode_literals -from youtube_dl.utils import try_get, unified_timestamp - from .common import InfoExtractor +from ..utils import try_get, unified_timestamp class HololiveFCIE(InfoExtractor): From 8d6a489c77fb4b0d8dfcc06f7909450a5e89fa0d Mon Sep 17 00:00:00 2001 From: dirkf Date: Fri, 6 Jan 2023 15:15:16 +0000 Subject: [PATCH 3/4] Force CI test Re-format imports --- youtube_dl/extractor/hololivefc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/hololivefc.py b/youtube_dl/extractor/hololivefc.py index 16c41ec5f..776fc0ea8 100644 --- a/youtube_dl/extractor/hololivefc.py +++ b/youtube_dl/extractor/hololivefc.py @@ -2,7 +2,10 @@ from __future__ import unicode_literals from .common import InfoExtractor -from ..utils import try_get, unified_timestamp +from ..utils import + try_get, + unified_timestamp, +) class HololiveFCIE(InfoExtractor): From f69fafb8191663200c78d4032d8827f9429d314d Mon Sep 17 00:00:00 2001 From: dirkf Date: Fri, 6 Jan 2023 17:36:17 +0000 Subject: [PATCH 4/4] Force CI test --- youtube_dl/extractor/hololivefc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/hololivefc.py b/youtube_dl/extractor/hololivefc.py index 776fc0ea8..1d2612c4e 100644 --- a/youtube_dl/extractor/hololivefc.py +++ b/youtube_dl/extractor/hololivefc.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from .common import InfoExtractor -from ..utils import +from ..utils import ( try_get, unified_timestamp, )