]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from .youtube import YoutubeIE | |
3 | from ..utils import traverse_obj | |
4 | ||
5 | ||
6 | class HolodexIE(InfoExtractor): | |
7 | _VALID_URL = r'''(?x)https?://(?:www\.|staging\.)?holodex\.net/(?: | |
8 | api/v2/playlist/(?P<playlist>\d+)| | |
9 | watch/(?P<id>\w+)(?:\?(?:[^#]+&)?playlist=(?P<playlist2>\d+))? | |
10 | )''' | |
11 | _TESTS = [{ | |
12 | 'url': 'https://holodex.net/watch/9kQ2GtvDV3s', | |
13 | 'md5': 'be5ffce2f0feae8ba4c01553abc0f175', | |
14 | 'info_dict': { | |
15 | 'ext': 'mp4', | |
16 | 'id': '9kQ2GtvDV3s', | |
17 | 'title': '【おちゃめ機能】ホロライブが吹っ切れた【24人で歌ってみた】', | |
18 | 'channel_id': 'UCJFZiqLMntJufDCHc6bQixg', | |
19 | 'playable_in_embed': True, | |
20 | 'tags': 'count:43', | |
21 | 'age_limit': 0, | |
22 | 'live_status': 'not_live', | |
23 | 'description': 'md5:040e866c09dc4ab899b36479f4b7c7a2', | |
24 | 'channel_url': 'https://www.youtube.com/channel/UCJFZiqLMntJufDCHc6bQixg', | |
25 | 'upload_date': '20200406', | |
26 | 'uploader_url': 'http://www.youtube.com/channel/UCJFZiqLMntJufDCHc6bQixg', | |
27 | 'view_count': int, | |
28 | 'channel': 'hololive ホロライブ - VTuber Group', | |
29 | 'categories': ['Music'], | |
30 | 'uploader': 'hololive ホロライブ - VTuber Group', | |
31 | 'channel_follower_count': int, | |
32 | 'uploader_id': 'UCJFZiqLMntJufDCHc6bQixg', | |
33 | 'availability': 'public', | |
34 | 'thumbnail': 'https://i.ytimg.com/vi_webp/9kQ2GtvDV3s/maxresdefault.webp', | |
35 | 'duration': 263, | |
36 | 'like_count': int, | |
37 | }, | |
38 | }, { | |
39 | 'url': 'https://holodex.net/api/v2/playlist/239', | |
40 | 'info_dict': { | |
41 | 'id': '239', | |
42 | 'title': 'Songs/Videos that made fall into the rabbit hole (from my google activity history)', | |
43 | }, | |
44 | 'playlist_count': 14, | |
45 | }, { | |
46 | 'url': 'https://holodex.net/watch/_m2mQyaofjI?foo=bar&playlist=69', | |
47 | 'info_dict': { | |
48 | 'id': '69', | |
49 | 'title': '拿著金斧頭的藍髮大姊姊' | |
50 | }, | |
51 | 'playlist_count': 3, | |
52 | }, { | |
53 | 'url': 'https://holodex.net/watch/_m2mQyaofjI?playlist=69', | |
54 | 'info_dict': { | |
55 | 'id': '_m2mQyaofjI', | |
56 | 'ext': 'mp4', | |
57 | 'playable_in_embed': True, | |
58 | 'like_count': int, | |
59 | 'uploader': 'Ernst / エンスト', | |
60 | 'duration': 11, | |
61 | 'uploader_url': 'http://www.youtube.com/channel/UCqSX4PPZY0cyetqKVY_wRVA', | |
62 | 'categories': ['Entertainment'], | |
63 | 'title': '【星街すいせい】星街向你獻上晚安', | |
64 | 'upload_date': '20210705', | |
65 | 'description': 'md5:8b8ffb157bae77f2d109021a0b577d4a', | |
66 | 'channel': 'Ernst / エンスト', | |
67 | 'channel_id': 'UCqSX4PPZY0cyetqKVY_wRVA', | |
68 | 'channel_follower_count': int, | |
69 | 'view_count': int, | |
70 | 'tags': [], | |
71 | 'live_status': 'not_live', | |
72 | 'channel_url': 'https://www.youtube.com/channel/UCqSX4PPZY0cyetqKVY_wRVA', | |
73 | 'availability': 'public', | |
74 | 'thumbnail': 'https://i.ytimg.com/vi_webp/_m2mQyaofjI/maxresdefault.webp', | |
75 | 'age_limit': 0, | |
76 | 'uploader_id': 'UCqSX4PPZY0cyetqKVY_wRVA', | |
77 | 'comment_count': int, | |
78 | }, | |
79 | 'params': {'noplaylist': True}, | |
80 | }, { | |
81 | 'url': 'https://staging.holodex.net/api/v2/playlist/125', | |
82 | 'only_matching': True, | |
83 | }, { | |
84 | 'url': 'https://staging.holodex.net/watch/rJJTJA_T_b0?playlist=25', | |
85 | 'only_matching': True, | |
86 | }, { | |
87 | 'url': 'https://staging.holodex.net/watch/s1ifBeukThg', | |
88 | 'only_matching': True, | |
89 | }] | |
90 | ||
91 | def _real_extract(self, url): | |
92 | video_id, playlist_id, pl_id2 = self._match_valid_url(url).group('id', 'playlist', 'playlist2') | |
93 | playlist_id = playlist_id or pl_id2 | |
94 | ||
95 | if not self._yes_playlist(playlist_id, video_id): | |
96 | return self.url_result(f'https://www.youtube.com/watch?v={video_id}', YoutubeIE) | |
97 | ||
98 | data = self._download_json(f'https://holodex.net/api/v2/playlist/{playlist_id}', playlist_id) | |
99 | return self.playlist_from_matches( | |
100 | traverse_obj(data, ('videos', ..., 'id')), playlist_id, data.get('name'), ie=YoutubeIE) |