[Theta] Add video extractor (#1137)

Authored by: alerikaisattera
pull/1158/head
Aleri Kaisattera 2021-10-02 00:45:15 +06:00 zatwierdzone przez GitHub
rodzic ad095c4283
commit 0eaec13ba6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 42 dodań i 3 usunięć

Wyświetl plik

@ -1433,7 +1433,10 @@ from .theplatform import (
from .thescene import TheSceneIE from .thescene import TheSceneIE
from .thestar import TheStarIE from .thestar import TheStarIE
from .thesun import TheSunIE from .thesun import TheSunIE
from .theta import ThetaIE from .theta import (
ThetaVideoIE,
ThetaStreamIE,
)
from .theweatherchannel import TheWeatherChannelIE from .theweatherchannel import TheWeatherChannelIE
from .thisamericanlife import ThisAmericanLifeIE from .thisamericanlife import ThisAmericanLifeIE
from .thisav import ThisAVIE from .thisav import ThisAVIE

Wyświetl plik

@ -5,8 +5,8 @@ from .common import InfoExtractor
from ..utils import try_get from ..utils import try_get
class ThetaIE(InfoExtractor): class ThetaStreamIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?theta\.tv/(?P<id>[a-z0-9]+)' _VALID_URL = r'https?://(?:www\.)?theta\.tv/(?!video/)(?P<id>[a-z0-9]+)'
_TESTS = [{ _TESTS = [{
'url': 'https://www.theta.tv/davirus', 'url': 'https://www.theta.tv/davirus',
'skip': 'The live may have ended', 'skip': 'The live may have ended',
@ -49,3 +49,39 @@ class ThetaIE(InfoExtractor):
'formats': formats, 'formats': formats,
'thumbnail': try_get(info, lambda x: x['live_stream']['thumbnail_url']), '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'),
}