aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/planetmarathi.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2021-11-27 13:25:01 -0500
committerJesús <heckyel@hyperbola.info>2021-11-27 13:25:01 -0500
commitc6df1db4745c9d399204876bbe04e8a311c01df1 (patch)
treea9f4ffa1db45e367aba1de858ac536b761f192fb /yt_dlp/extractor/planetmarathi.py
parent5bb25093eb718346ab8a723d2c04f0066fc3958a (diff)
parent93e597ba287539643851f0ad5c5ff04760380268 (diff)
downloadhypervideo-pre-c6df1db4745c9d399204876bbe04e8a311c01df1.tar.lz
hypervideo-pre-c6df1db4745c9d399204876bbe04e8a311c01df1.tar.xz
hypervideo-pre-c6df1db4745c9d399204876bbe04e8a311c01df1.zip
updated from upstream | 27/11/2021 at 13:25
Diffstat (limited to 'yt_dlp/extractor/planetmarathi.py')
-rw-r--r--yt_dlp/extractor/planetmarathi.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/yt_dlp/extractor/planetmarathi.py b/yt_dlp/extractor/planetmarathi.py
new file mode 100644
index 000000000..d1d9911f7
--- /dev/null
+++ b/yt_dlp/extractor/planetmarathi.py
@@ -0,0 +1,76 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+from ..utils import (
+ try_get,
+ unified_strdate,
+)
+
+
+class PlanetMarathiIE(InfoExtractor):
+ _VALID_URL = r'(?:https?://)(?:www\.)?planetmarathi\.com/titles/(?P<id>[^/#&?$]+)'
+ _TESTS = [{
+ 'url': 'https://www.planetmarathi.com/titles/ek-unad-divas',
+ 'playlist_mincount': 2,
+ 'info_dict': {
+ 'id': 'ek-unad-divas',
+ },
+ 'playlist': [{
+ 'info_dict': {
+ 'id': 'ASSETS-MOVIE-ASSET-01_ek-unad-divas',
+ 'ext': 'mp4',
+ 'title': 'ek unad divas',
+ 'alt_title': 'चित्रपट',
+ 'description': 'md5:41c7ed6b041c2fea9820a3f3125bd881',
+ 'season_number': None,
+ 'episode_number': 1,
+ 'duration': 5539,
+ 'upload_date': '20210829',
+ },
+ }] # Trailer skipped
+ }, {
+ 'url': 'https://www.planetmarathi.com/titles/baap-beep-baap-season-1',
+ 'playlist_mincount': 10,
+ 'info_dict': {
+ 'id': 'baap-beep-baap-season-1',
+ },
+ 'playlist': [{
+ 'info_dict': {
+ 'id': 'ASSETS-CHARACTER-PROFILE-SEASON-01-ASSET-01_baap-beep-baap-season-1',
+ 'ext': 'mp4',
+ 'title': 'Manohar Kanhere',
+ 'alt_title': 'मनोहर कान्हेरे',
+ 'description': 'md5:285ed45d5c0ab5522cac9a043354ebc6',
+ 'season_number': 1,
+ 'episode_number': 1,
+ 'duration': 29,
+ 'upload_date': '20210829',
+ },
+ }] # Trailers, Episodes, other Character profiles skipped
+ }]
+
+ def _real_extract(self, url):
+ id = self._match_id(url)
+ entries = []
+ json_data = self._download_json(f'https://www.planetmarathi.com/api/v1/titles/{id}/assets', id)['assets']
+ for asset in json_data:
+ asset_title = asset['mediaAssetName']['en']
+ if asset_title == 'Movie':
+ asset_title = id.replace('-', ' ')
+ asset_id = f'{asset["sk"]}_{id}'.replace('#', '-')
+ formats, subtitles = self._extract_m3u8_formats_and_subtitles(asset['mediaAssetURL'], asset_id)
+ self._sort_formats(formats)
+ entries.append({
+ 'id': asset_id,
+ 'title': asset_title,
+ 'alt_title': try_get(asset, lambda x: x['mediaAssetName']['mr']),
+ 'description': try_get(asset, lambda x: x['mediaAssetDescription']['en']),
+ 'season_number': asset.get('mediaAssetSeason'),
+ 'episode_number': asset.get('mediaAssetIndexForAssetType'),
+ 'duration': asset.get('mediaAssetDurationInSeconds'),
+ 'upload_date': unified_strdate(asset.get('created')),
+ 'formats': formats,
+ 'subtitles': subtitles,
+ })
+ return self.playlist_result(entries, playlist_id=id)