]>
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 | }, | |
add96eb9 | 27 | }], # Trailer skipped |
2f9e0212 AG |
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 | }, | |
add96eb9 | 46 | }], # Trailers, Episodes, other Character profiles skipped |
2f9e0212 AG |
47 | }] |
48 | ||
49 | def _real_extract(self, url): | |
add96eb9 | 50 | playlist_id = self._match_id(url) |
2f9e0212 | 51 | entries = [] |
add96eb9 | 52 | json_data = self._download_json( |
53 | f'https://www.planetmarathi.com/api/v1/titles/{playlist_id}/assets', playlist_id)['assets'] | |
2f9e0212 AG |
54 | for asset in json_data: |
55 | asset_title = asset['mediaAssetName']['en'] | |
56 | if asset_title == 'Movie': | |
add96eb9 | 57 | asset_title = playlist_id.replace('-', ' ') |
58 | asset_id = f'{asset["sk"]}_{playlist_id}'.replace('#', '-') | |
2f9e0212 | 59 | formats, subtitles = self._extract_m3u8_formats_and_subtitles(asset['mediaAssetURL'], asset_id) |
2f9e0212 AG |
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 | }) | |
add96eb9 | 72 | return self.playlist_result(entries, playlist_id=playlist_id) |