1 from .common
import InfoExtractor
9 from ..utils
.traversal
import traverse_obj
12 class AsobiChannelBaseIE(InfoExtractor
):
13 _MICROCMS_HEADER
= {'X-MICROCMS-API-KEY': 'qRaKehul9AHU8KtL0dnq1OCLKnFec6yrbcz3'}
15 def _extract_info(self
, metadata
):
16 return traverse_obj(metadata
, {
18 'title': ('title', {str}
),
19 'description': ('body', {clean_html}
),
20 'thumbnail': ('contents', 'video_thumb', 'url', {url_or_none}
),
21 'timestamp': ('publishedAt', {parse_iso8601}
),
22 'modified_timestamp': ('updatedAt', {parse_iso8601}
),
23 'channel': ('channel', 'name', {str}
),
24 'channel_id': ('channel', 'id', {str}
),
28 class AsobiChannelIE(AsobiChannelBaseIE
):
29 IE_NAME
= 'asobichannel'
30 IE_DESC
= 'ASOBI CHANNEL'
32 _VALID_URL
= r
'https?://asobichannel\.asobistore\.jp/watch/(?P<id>[\w-]+)'
34 'url': 'https://asobichannel.asobistore.jp/watch/1ypp48qd32p',
35 'md5': '39df74e872afe032c4eb27b89144fc92',
39 'title': 'アイドルマスター ミリオンライブ! 765プロch 原っぱ通信 #1',
40 'description': 'md5:b930bd2199c9b2fd75951ce4aaa7efd2',
41 'thumbnail': 'https://images.microcms-assets.io/assets/d2420de4b9194e11beb164f99edb1f95/a8e6f84119f54eb9ab4ce16729239905/%E3%82%B5%E3%83%A0%E3%83%8D%20(1).png',
42 'timestamp': 1697098247,
43 'upload_date': '20231012',
44 'modified_timestamp': 1698381162,
45 'modified_date': '20231027',
46 'channel': 'アイドルマスター',
47 'channel_id': 'idolmaster',
50 'url': 'https://asobichannel.asobistore.jp/watch/redigiwnjzqj',
51 'md5': '229fa8fb5c591c75ce8c37a497f113f6',
55 'title': '【おまけ放送】アイドルマスター ミリオンライブ! 765プロch 原っぱ通信 #1',
56 'description': 'md5:7d9cd35fb54425a6967822bd564ea2d9',
57 'thumbnail': 'https://images.microcms-assets.io/assets/d2420de4b9194e11beb164f99edb1f95/20e5c1d6184242eebc2512a5dec59bf0/P1_%E5%8E%9F%E3%81%A3%E3%81%B1%E3%82%B5%E3%83%A0%E3%83%8D.png',
58 'modified_timestamp': 1697797125,
59 'modified_date': '20231020',
60 'timestamp': 1697261769,
61 'upload_date': '20231014',
62 'channel': 'アイドルマスター',
63 'channel_id': 'idolmaster',
67 _survapi_header
= None
69 def _real_initialize(self
):
70 token
= self
._download
_json
(
71 'https://asobichannel-api.asobistore.jp/api/v1/vspf/token', None,
72 note
='Retrieving API token')
73 self
._survapi
_header
= {'Authorization': f
'Bearer {token}'}
75 def _process_vod(self
, video_id
, metadata
):
76 content_id
= metadata
['contents']['video_id']
78 vod_data
= self
._download
_json
(
79 f
'https://survapi.channel.or.jp/proxy/v1/contents/{content_id}/get_by_cuid', video_id
,
80 headers
=self
._survapi
_header
, note
='Downloading vod data')
83 'formats': self
._extract
_m
3u8_formats
(vod_data
['ex_content']['streaming_url'], video_id
),
86 def _process_live(self
, video_id
, metadata
):
87 content_id
= metadata
['contents']['video_id']
88 event_data
= self
._download
_json
(
89 f
'https://survapi.channel.or.jp/ex/events/{content_id}?embed=channel', video_id
,
90 headers
=self
._survapi
_header
, note
='Downloading event data')
92 player_type
= traverse_obj(event_data
, ('data', 'Player_type', {str}
))
93 if player_type
== 'poster':
94 self
.raise_no_formats('Live event has not yet started', expected
=True)
95 live_status
= 'is_upcoming'
97 elif player_type
== 'player':
98 live_status
= 'is_live'
99 formats
= self
._extract
_m
3u8_formats
(
100 event_data
['data']['Channel']['Custom_live_url'], video_id
, live
=True)
102 raise ExtractorError('Unsupported player type {player_type!r}')
105 'release_timestamp': traverse_obj(metadata
, ('period', 'start', {parse_iso8601}
)),
106 'live_status': live_status
,
110 def _real_extract(self
, url
):
111 video_id
= self
._match
_id
(url
)
113 metadata
= self
._download
_json
(
114 f
'https://channel.microcms.io/api/v1/media/{video_id}', video_id
,
115 headers
=self
._MICROCMS
_HEADER
)
117 info
= self
._extract
_info
(metadata
)
119 video_type
= traverse_obj(metadata
, ('contents', 'video_type', 0, {str}
))
120 if video_type
== 'VOD':
121 return merge_dicts(info
, self
._process
_vod
(video_id
, metadata
))
122 if video_type
== 'LIVE':
123 return merge_dicts(info
, self
._process
_live
(video_id
, metadata
))
125 raise ExtractorError(f
'Unexpected video type {video_type!r}')
128 class AsobiChannelTagURLIE(AsobiChannelBaseIE
):
129 IE_NAME
= 'asobichannel:tag'
130 IE_DESC
= 'ASOBI CHANNEL'
132 _VALID_URL
= r
'https?://asobichannel\.asobistore\.jp/tag/(?P<id>[a-z0-9-_]+)'
134 'url': 'https://asobichannel.asobistore.jp/tag/bjhh-nbcja',
137 'title': 'アイドルマスター ミリオンライブ! 765プロch 原っぱ通信',
139 'playlist_mincount': 16,
141 'url': 'https://asobichannel.asobistore.jp/tag/hvm5qw3c6od',
144 'title': 'アイマスMOIW2023ラジオ',
146 'playlist_mincount': 13,
149 def _real_extract(self
, url
):
150 tag_id
= self
._match
_id
(url
)
151 webpage
= self
._download
_webpage
(url
, tag_id
)
152 title
= traverse_obj(self
._search
_nextjs
_data
(
153 webpage
, tag_id
, fatal
=False), ('props', 'pageProps', 'data', 'name', {str}
))
155 media
= self
._download
_json
(
156 f
'https://channel.microcms.io/api/v1/media?limit=999&filters=(tag[contains]{tag_id})',
157 tag_id
, headers
=self
._MICROCMS
_HEADER
)
160 for metadata
in traverse_obj(media
, ('contents', lambda _
, v
: v
['id'])):
163 'url': f
'https://asobichannel.asobistore.jp/watch/{metadata["id"]}',
164 'ie_key': AsobiChannelIE
.ie_key(),
165 **self
._extract
_info
(metadata
),
168 return self
.playlist_result(entries(), tag_id
, title
)