]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/plutotv.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / plutotv.py
index 0cf82466a6987253b7f24355c6076101feb57caf..234ee987b69b6d224aae0aef6ae558119143fc7d 100644 (file)
@@ -1,14 +1,8 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 import re
+import urllib.parse
 import uuid
 
 from .common import InfoExtractor
-from ..compat import (
-    compat_str,
-    compat_urlparse,
-)
 from ..utils import (
     ExtractorError,
     float_or_none,
 
 
 class PlutoTVIE(InfoExtractor):
+    _WORKING = False
     _VALID_URL = r'''(?x)
-        https?://(?:www\.)?pluto\.tv(?:/en)?/on-demand
+        https?://(?:www\.)?pluto\.tv(?:/[^/]+)?/on-demand
         /(?P<video_type>movies|series)
         /(?P<series_or_movie_slug>[^/]+)
         (?:
-            /seasons?/(?P<season_no>\d+)
+            (?:/seasons?/(?P<season_no>\d+))?
             (?:/episode/(?P<episode_slug>[^/]+))?
         )?
         /?(?:$|[#?])'''
@@ -33,14 +28,14 @@ class PlutoTVIE(InfoExtractor):
     _INFO_QUERY_PARAMS = {
         'appName': 'web',
         'appVersion': 'na',
-        'clientID': compat_str(uuid.uuid1()),
+        'clientID': str(uuid.uuid1()),
         'clientModelNumber': 'na',
         'serverSideAds': 'false',
         'deviceMake': 'unknown',
         'deviceModel': 'web',
         'deviceType': 'web',
         'deviceVersion': 'unknown',
-        'sid': compat_str(uuid.uuid1()),
+        'sid': str(uuid.uuid1()),
     }
     _TESTS = [
         {
@@ -56,21 +51,21 @@ class PlutoTVIE(InfoExtractor):
                 'season_number': 2,
                 'episode_number': 3,
                 'duration': 3600,
-            }
+            },
         }, {
             'url': 'https://pluto.tv/on-demand/series/i-love-money/season/1/',
             'playlist_count': 11,
             'info_dict': {
                 'id': '5de6c582e9379ae4912dedbd',
                 'title': 'I Love Money - Season 1',
-            }
+            },
         }, {
             'url': 'https://pluto.tv/on-demand/series/i-love-money/',
             'playlist_count': 26,
             'info_dict': {
                 'id': '5de6c582e9379ae4912dedbd',
                 'title': 'I Love Money',
-            }
+            },
         }, {
             'url': 'https://pluto.tv/on-demand/movies/arrival-2015-1-1',
             'md5': '3cead001d317a018bf856a896dee1762',
@@ -80,11 +75,25 @@ class PlutoTVIE(InfoExtractor):
                 'title': 'Arrival',
                 'description': 'When mysterious spacecraft touch down across the globe, an elite team - led by expert translator Louise Banks (Academy Award® nominee Amy Adams) – races against time to decipher their intent.',
                 'duration': 9000,
-            }
+            },
         }, {
             'url': 'https://pluto.tv/en/on-demand/series/manhunters-fugitive-task-force/seasons/1/episode/third-times-the-charm-1-1',
             'only_matching': True,
-        }
+        }, {
+            'url': 'https://pluto.tv/it/on-demand/series/csi-vegas/episode/legacy-2021-1-1',
+            'only_matching': True,
+        },
+        {
+            'url': 'https://pluto.tv/en/on-demand/movies/attack-of-the-killer-tomatoes-1977-1-1-ptv1',
+            'md5': '7db56369c0da626a32d505ec6eb3f89f',
+            'info_dict': {
+                'id': '5b190c7bb0875c36c90c29c4',
+                'ext': 'mp4',
+                'title': 'Attack of the Killer Tomatoes',
+                'description': 'A group of scientists band together to save the world from mutated tomatoes that KILL! (1978)',
+                'duration': 5700,
+            },
+        },
     ]
 
     def _to_ad_free_formats(self, video_id, formats, subtitles):
@@ -100,14 +109,14 @@ def _to_ad_free_formats(self, video_id, formats, subtitles):
                 re.MULTILINE)
             if first_segment_url:
                 m3u8_urls.add(
-                    compat_urlparse.urljoin(first_segment_url.group(1), '0-end/master.m3u8'))
+                    urllib.parse.urljoin(first_segment_url.group(1), '0-end/master.m3u8'))
                 continue
             first_segment_url = re.search(
-                r'^(https?://.*/).+\-0+\.ts$', res,
+                r'^(https?://.*/).+\-0+[0-1]0\.ts$', res,
                 re.MULTILINE)
             if first_segment_url:
                 m3u8_urls.add(
-                    compat_urlparse.urljoin(first_segment_url.group(1), 'master.m3u8'))
+                    urllib.parse.urljoin(first_segment_url.group(1), 'master.m3u8'))
                 continue
 
         for m3u8_url in m3u8_urls:
@@ -135,7 +144,6 @@ def _get_video_info(self, video_json, slug, series_name=None):
             subtitles = self._merge_subtitles(subtitles, subs)
 
         formats, subtitles = self._to_ad_free_formats(video_id, formats, subtitles)
-        self._sort_formats(formats)
 
         info = {
             'id': video_id,