]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from .dailymotion import DailymotionIE | |
3 | from ..utils import smuggle_url, traverse_obj | |
4 | ||
5 | ||
6 | class NetverseBaseIE(InfoExtractor): | |
7 | _ENDPOINTS = { | |
8 | 'watch': 'watchvideo', | |
9 | 'video': 'watchvideo', | |
10 | 'webseries': 'webseries', | |
11 | 'season': 'webseason_videos', | |
12 | } | |
13 | ||
14 | def _call_api(self, slug, endpoint, query={}, season_id='', display_id=None): | |
15 | return self._download_json( | |
16 | f'https://api.netverse.id/medias/api/v2/{self._ENDPOINTS[endpoint]}/{slug}/{season_id}', | |
17 | display_id or slug, query=query) | |
18 | ||
19 | ||
20 | class NetverseIE(NetverseBaseIE): | |
21 | _VALID_URL = r'https?://(?:\w+\.)?netverse\.id/(?P<type>watch|video)/(?P<display_id>[^/?#&]+)' | |
22 | _TESTS = [{ | |
23 | # Watch video | |
24 | 'url': 'https://www.netverse.id/watch/waktu-indonesia-bercanda-edisi-spesial-lebaran-2016', | |
25 | 'info_dict': { | |
26 | 'id': 'k4yhqUwINAGtmHx3NkL', | |
27 | 'title': 'Waktu Indonesia Bercanda - Edisi Spesial Lebaran 2016', | |
28 | 'ext': 'mp4', | |
29 | 'season': 'Season 2016', | |
30 | 'description': 'md5:d41d8cd98f00b204e9800998ecf8427e', | |
31 | 'thumbnail': r're:https?://s\d+\.dmcdn\.net/v/T7aV31Y0eGRWBbwkK/x1080', | |
32 | 'episode_number': 22, | |
33 | 'episode': 'Episode 22', | |
34 | 'uploader_id': 'x2ir3vq', | |
35 | 'age_limit': 0, | |
36 | 'tags': [], | |
37 | 'view_count': int, | |
38 | 'display_id': 'waktu-indonesia-bercanda-edisi-spesial-lebaran-2016', | |
39 | 'duration': 2990, | |
40 | 'upload_date': '20210722', | |
41 | 'timestamp': 1626919804, | |
42 | 'like_count': int, | |
43 | 'uploader': 'Net Prime', | |
44 | } | |
45 | }, { | |
46 | # series | |
47 | 'url': 'https://www.netverse.id/watch/jadoo-seorang-model', | |
48 | 'info_dict': { | |
49 | 'id': 'x88izwc', | |
50 | 'title': 'Jadoo Seorang Model', | |
51 | 'ext': 'mp4', | |
52 | 'season': 'Season 2', | |
53 | 'description': 'md5:8a74f70812cca267e19ee0635f0af835', | |
54 | 'thumbnail': r're:https?://s\d+\.dmcdn\.net/v/Thwuy1YURicFmGu0v/x1080', | |
55 | 'episode_number': 2, | |
56 | 'episode': 'Episode 2', | |
57 | 'view_count': int, | |
58 | 'like_count': int, | |
59 | 'display_id': 'jadoo-seorang-model', | |
60 | 'uploader_id': 'x2ir3vq', | |
61 | 'duration': 635, | |
62 | 'timestamp': 1646372927, | |
63 | 'tags': ['PG069497-hellojadooseason2eps2'], | |
64 | 'upload_date': '20220304', | |
65 | 'uploader': 'Net Prime', | |
66 | 'age_limit': 0, | |
67 | }, | |
68 | 'skip': 'video get Geo-blocked for some country' | |
69 | }, { | |
70 | # non www host | |
71 | 'url': 'https://netverse.id/watch/tetangga-baru', | |
72 | 'info_dict': { | |
73 | 'id': 'k4CNGz7V0HJ7vfwZbXy', | |
74 | 'ext': 'mp4', | |
75 | 'title': 'Tetangga Baru', | |
76 | 'season': 'Season 1', | |
77 | 'description': 'md5:23fcf70e97d461d3029d25d59b2ccfb9', | |
78 | 'thumbnail': r're:https?://s\d+\.dmcdn\.net/v/T3Ogm1YEnnyjVKAFF/x1080', | |
79 | 'episode_number': 1, | |
80 | 'episode': 'Episode 1', | |
81 | 'timestamp': 1624538169, | |
82 | 'view_count': int, | |
83 | 'upload_date': '20210624', | |
84 | 'age_limit': 0, | |
85 | 'uploader_id': 'x2ir3vq', | |
86 | 'like_count': int, | |
87 | 'uploader': 'Net Prime', | |
88 | 'tags': ['PG008534', 'tetangga', 'Baru'], | |
89 | 'display_id': 'tetangga-baru', | |
90 | 'duration': 1406, | |
91 | }, | |
92 | }, { | |
93 | # /video url | |
94 | 'url': 'https://www.netverse.id/video/pg067482-hellojadoo-season1', | |
95 | 'title': 'Namaku Choi Jadoo', | |
96 | 'info_dict': { | |
97 | 'id': 'x887jzz', | |
98 | 'ext': 'mp4', | |
99 | 'thumbnail': r're:https?://s\d+\.dmcdn\.net/v/TfuZ_1Y6PboJ5An_s/x1080', | |
100 | 'season': 'Season 1', | |
101 | 'episode_number': 1, | |
102 | 'description': 'md5:d4f627b3e7a3f9acdc55f6cdd5ea41d5', | |
103 | 'title': 'Namaku Choi Jadoo', | |
104 | 'episode': 'Episode 1', | |
105 | 'age_limit': 0, | |
106 | 'like_count': int, | |
107 | 'view_count': int, | |
108 | 'tags': ['PG067482', 'PG067482-HelloJadoo-season1'], | |
109 | 'duration': 780, | |
110 | 'display_id': 'pg067482-hellojadoo-season1', | |
111 | 'uploader_id': 'x2ir3vq', | |
112 | 'uploader': 'Net Prime', | |
113 | 'timestamp': 1645764984, | |
114 | 'upload_date': '20220225', | |
115 | }, | |
116 | 'skip': 'This video get Geo-blocked for some country' | |
117 | }] | |
118 | ||
119 | def _real_extract(self, url): | |
120 | display_id, sites_type = self._match_valid_url(url).group('display_id', 'type') | |
121 | program_json = self._call_api(display_id, sites_type) | |
122 | videos = program_json['response']['videos'] | |
123 | ||
124 | return { | |
125 | '_type': 'url_transparent', | |
126 | 'ie_key': DailymotionIE.ie_key(), | |
127 | 'url': smuggle_url(videos['dailymotion_url'], {'query': {'embedder': 'https://www.netverse.id'}}), | |
128 | 'display_id': display_id, | |
129 | 'title': videos.get('title'), | |
130 | 'season': videos.get('season_name'), | |
131 | 'thumbnail': traverse_obj(videos, ('program_detail', 'thumbnail_image')), | |
132 | 'description': traverse_obj(videos, ('program_detail', 'description')), | |
133 | 'episode_number': videos.get('episode_order'), | |
134 | } | |
135 | ||
136 | ||
137 | class NetversePlaylistIE(NetverseBaseIE): | |
138 | _VALID_URL = r'https?://(?:\w+\.)?netverse\.id/(?P<type>webseries)/(?P<display_id>[^/?#&]+)' | |
139 | _TESTS = [{ | |
140 | # multiple season | |
141 | 'url': 'https://netverse.id/webseries/tetangga-masa-gitu', | |
142 | 'info_dict': { | |
143 | 'id': 'tetangga-masa-gitu', | |
144 | 'title': 'Tetangga Masa Gitu', | |
145 | }, | |
146 | 'playlist_count': 519, | |
147 | }, { | |
148 | # single season | |
149 | 'url': 'https://netverse.id/webseries/kelas-internasional', | |
150 | 'info_dict': { | |
151 | 'id': 'kelas-internasional', | |
152 | 'title': 'Kelas Internasional', | |
153 | }, | |
154 | 'playlist_count': 203, | |
155 | }] | |
156 | ||
157 | def parse_playlist(self, json_data, playlist_id): | |
158 | slug_sample = traverse_obj(json_data, ('related', 'data', ..., 'slug'))[0] | |
159 | for season in traverse_obj(json_data, ('seasons', ..., 'id')): | |
160 | playlist_json = self._call_api( | |
161 | slug_sample, 'season', display_id=playlist_id, season_id=season) | |
162 | ||
163 | for current_page in range(playlist_json['response']['season_list']['last_page']): | |
164 | playlist_json = self._call_api(slug_sample, 'season', query={'page': current_page + 1}, | |
165 | season_id=season, display_id=playlist_id) | |
166 | for slug in traverse_obj(playlist_json, ('response', ..., 'data', ..., 'slug')): | |
167 | yield self.url_result(f'https://www.netverse.id/video/{slug}', NetverseIE) | |
168 | ||
169 | def _real_extract(self, url): | |
170 | playlist_id, sites_type = self._match_valid_url(url).group('display_id', 'type') | |
171 | playlist_data = self._call_api(playlist_id, sites_type) | |
172 | ||
173 | return self.playlist_result( | |
174 | self.parse_playlist(playlist_data['response'], playlist_id), | |
175 | traverse_obj(playlist_data, ('response', 'webseries_info', 'slug')), | |
176 | traverse_obj(playlist_data, ('response', 'webseries_info', 'title'))) |