]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/theta.py
Allow extractors to specify section_start/end for clips
[yt-dlp.git] / yt_dlp / extractor / theta.py
index 34c0da81562248113967e13cb74d039b07c29865..3ec6b971181a0e4dada0a0c0fb563483978d3776 100644 (file)
@@ -1,12 +1,9 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 from .common import InfoExtractor
 from ..utils import try_get
 
 
-class ThetaIE(InfoExtractor):
-    _VALID_URL = r'https?://(?:www\.)?theta\.tv/(?P<id>[a-z0-9]+)'
+class ThetaStreamIE(InfoExtractor):
+    _VALID_URL = r'https?://(?:www\.)?theta\.tv/(?!video/)(?P<id>[a-z0-9-]+)'
     _TESTS = [{
         'url': 'https://www.theta.tv/davirus',
         'skip': 'The live may have ended',
@@ -25,6 +22,14 @@ class ThetaIE(InfoExtractor):
             'title': 'Mystery Science Theatre 3000 24/7 Powered by the THETA Network.',
             'thumbnail': r're:https://user-prod-theta-tv\.imgix\.net/.+\.jpg',
         }
+    }, {
+        'url': 'https://www.theta.tv/contv-anime',
+        'info_dict': {
+            'id': 'ConTVAnime',
+            'ext': 'mp4',
+            'title': 'CONTV ANIME 24/7. Powered by THETA Network.',
+            'thumbnail': r're:https://user-prod-theta-tv\.imgix\.net/.+\.jpg',
+        }
     }]
 
     def _real_extract(self, url):
@@ -49,3 +54,39 @@ def _real_extract(self, url):
             'formats': formats,
             'thumbnail': try_get(info, lambda x: x['live_stream']['thumbnail_url']),
         }
+
+
+class ThetaVideoIE(InfoExtractor):
+    _VALID_URL = r'https?://(?:www\.)?theta\.tv/video/(?P<id>vid[a-z0-9]+)'
+    _TEST = {
+        'url': 'https://www.theta.tv/video/vidiq6aaet3kzf799p0',
+        'md5': '633d8c29eb276bb38a111dbd591c677f',
+        'info_dict': {
+            'id': 'vidiq6aaet3kzf799p0',
+            'ext': 'mp4',
+            'title': 'Theta EdgeCast Tutorial',
+            'uploader': 'Pixiekittie',
+            'description': 'md5:e316253f5bdced8b5a46bb50ae60a09f',
+            'thumbnail': r're:https://user-prod-theta-tv\.imgix\.net/.+/vod_thumb/.+.jpg',
+        }
+    }
+
+    def _real_extract(self, url):
+        video_id = self._match_id(url)
+        info = self._download_json(f'https://api.theta.tv/v1/video/{video_id}/raw', video_id)['body']
+
+        m3u8_playlist = try_get(info, lambda x: x['video_urls'][0]['url'])
+
+        formats = self._extract_m3u8_formats(m3u8_playlist, video_id, 'mp4', m3u8_id='hls')
+        self._sort_formats(formats)
+
+        return {
+            'id': video_id,
+            'title': info.get('title'),
+            'uploader': try_get(info, lambda x: x['user']['username']),
+            'description': info.get('description'),
+            'view_count': info.get('view_count'),
+            'like_count': info.get('like_count'),
+            'formats': formats,
+            'thumbnail': info.get('thumbnail_url'),
+        }