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