]>
Commit | Line | Data |
---|---|---|
2f9e0212 AG |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
3 | try_get, | |
4 | unified_strdate, | |
5 | ) | |
6 | ||
7 | ||
8 | class PlanetMarathiIE(InfoExtractor): | |
73f035e1 | 9 | _VALID_URL = r'https?://(?:www\.)?planetmarathi\.com/titles/(?P<id>[^/#&?$]+)' |
2f9e0212 AG |
10 | _TESTS = [{ |
11 | 'url': 'https://www.planetmarathi.com/titles/ek-unad-divas', | |
12 | 'playlist_mincount': 2, | |
13 | 'info_dict': { | |
14 | 'id': 'ek-unad-divas', | |
15 | }, | |
16 | 'playlist': [{ | |
17 | 'info_dict': { | |
18 | 'id': 'ASSETS-MOVIE-ASSET-01_ek-unad-divas', | |
19 | 'ext': 'mp4', | |
20 | 'title': 'ek unad divas', | |
21 | 'alt_title': 'चित्रपट', | |
22 | 'description': 'md5:41c7ed6b041c2fea9820a3f3125bd881', | |
2f9e0212 AG |
23 | 'episode_number': 1, |
24 | 'duration': 5539, | |
25 | 'upload_date': '20210829', | |
26 | }, | |
27 | }] # Trailer skipped | |
28 | }, { | |
29 | 'url': 'https://www.planetmarathi.com/titles/baap-beep-baap-season-1', | |
30 | 'playlist_mincount': 10, | |
31 | 'info_dict': { | |
32 | 'id': 'baap-beep-baap-season-1', | |
33 | }, | |
34 | 'playlist': [{ | |
35 | 'info_dict': { | |
36 | 'id': 'ASSETS-CHARACTER-PROFILE-SEASON-01-ASSET-01_baap-beep-baap-season-1', | |
37 | 'ext': 'mp4', | |
38 | 'title': 'Manohar Kanhere', | |
39 | 'alt_title': 'मनोहर कान्हेरे', | |
40 | 'description': 'md5:285ed45d5c0ab5522cac9a043354ebc6', | |
41 | 'season_number': 1, | |
42 | 'episode_number': 1, | |
43 | 'duration': 29, | |
44 | 'upload_date': '20210829', | |
45 | }, | |
46 | }] # Trailers, Episodes, other Character profiles skipped | |
47 | }] | |
48 | ||
49 | def _real_extract(self, url): | |
50 | id = self._match_id(url) | |
51 | entries = [] | |
52 | json_data = self._download_json(f'https://www.planetmarathi.com/api/v1/titles/{id}/assets', id)['assets'] | |
53 | for asset in json_data: | |
54 | asset_title = asset['mediaAssetName']['en'] | |
55 | if asset_title == 'Movie': | |
56 | asset_title = id.replace('-', ' ') | |
57 | asset_id = f'{asset["sk"]}_{id}'.replace('#', '-') | |
58 | formats, subtitles = self._extract_m3u8_formats_and_subtitles(asset['mediaAssetURL'], asset_id) | |
2f9e0212 AG |
59 | entries.append({ |
60 | 'id': asset_id, | |
61 | 'title': asset_title, | |
62 | 'alt_title': try_get(asset, lambda x: x['mediaAssetName']['mr']), | |
63 | 'description': try_get(asset, lambda x: x['mediaAssetDescription']['en']), | |
64 | 'season_number': asset.get('mediaAssetSeason'), | |
65 | 'episode_number': asset.get('mediaAssetIndexForAssetType'), | |
66 | 'duration': asset.get('mediaAssetDurationInSeconds'), | |
67 | 'upload_date': unified_strdate(asset.get('created')), | |
68 | 'formats': formats, | |
69 | 'subtitles': subtitles, | |
70 | }) | |
71 | return self.playlist_result(entries, playlist_id=id) |