]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/planetmarathi.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / planetmarathi.py
index d1d9911f7d51751f7d09b1b9672d2873361e27fd..94861836a3b0b7a66a3003a8f6992868d04b567c 100644 (file)
@@ -1,6 +1,3 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 from .common import InfoExtractor
 from ..utils import (
     try_get,
@@ -9,7 +6,7 @@
 
 
 class PlanetMarathiIE(InfoExtractor):
-    _VALID_URL = r'(?:https?://)(?:www\.)?planetmarathi\.com/titles/(?P<id>[^/#&?$]+)'
+    _VALID_URL = r'https?://(?:www\.)?planetmarathi\.com/titles/(?P<id>[^/#&?$]+)'
     _TESTS = [{
         'url': 'https://www.planetmarathi.com/titles/ek-unad-divas',
         'playlist_mincount': 2,
@@ -23,12 +20,11 @@ class PlanetMarathiIE(InfoExtractor):
                 'title': 'ek unad divas',
                 'alt_title': 'चित्रपट',
                 'description': 'md5:41c7ed6b041c2fea9820a3f3125bd881',
-                'season_number': None,
                 'episode_number': 1,
                 'duration': 5539,
                 'upload_date': '20210829',
             },
-        }]  # Trailer skipped
+        }],  # Trailer skipped
     }, {
         'url': 'https://www.planetmarathi.com/titles/baap-beep-baap-season-1',
         'playlist_mincount': 10,
@@ -47,20 +43,20 @@ class PlanetMarathiIE(InfoExtractor):
                 'duration': 29,
                 'upload_date': '20210829',
             },
-        }]  # Trailers, Episodes, other Character profiles skipped
+        }],  # Trailers, Episodes, other Character profiles skipped
     }]
 
     def _real_extract(self, url):
-        id = self._match_id(url)
+        playlist_id = self._match_id(url)
         entries = []
-        json_data = self._download_json(f'https://www.planetmarathi.com/api/v1/titles/{id}/assets', id)['assets']
+        json_data = self._download_json(
+            f'https://www.planetmarathi.com/api/v1/titles/{playlist_id}/assets', playlist_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('#', '-')
+                asset_title = playlist_id.replace('-', ' ')
+            asset_id = f'{asset["sk"]}_{playlist_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,
@@ -73,4 +69,4 @@ def _real_extract(self, url):
                 'formats': formats,
                 'subtitles': subtitles,
             })
-        return self.playlist_result(entries, playlist_id=id)
+        return self.playlist_result(entries, playlist_id=playlist_id)