1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-06-26 05:39:34 +00:00
youtube-dl/youtube_dl/extractor/videocdn.py

64 lines
2 KiB
Python
Raw Normal View History

2023-01-21 00:10:22 +00:00
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
2023-01-21 19:27:41 +00:00
from ..compat import compat_urlparse
2023-01-21 00:10:22 +00:00
from ..utils import (
determine_ext,
2023-01-21 19:27:41 +00:00
urljoin,
)
2023-01-21 00:10:22 +00:00
class VideoCdnIE(InfoExtractor):
_VALID_URL = r'https?://e\.video-cdn\.net/video?.*video-id=(?P<id>[a-zA-Z0-9-_]+).*'
_TESTS = [
{
'url': 'https://e.video-cdn.net/video?video-id=8eBUrWaMJFS38A5X-j2CgY&player-id=53Tun3ZZpZpVuvaTvsm3jU',
'info_dict': {
'id': '8eBUrWaMJFS38A5X-j2CgY',
'ext': 'mp4',
'title': 'RiskBuster FireFighter VI - Adventskranz',
'thumbnail': r're:(?i)https://.*\.jpeg',
},
},
{
'url': 'https://e.video-cdn.net/video?video-id=91imQ_wKjkTFghe-3mmBAA&player-id=7nCLZ_ESM8rT9YUw6qUGA9',
'info_dict': {
'id': '91imQ_wKjkTFghe-3mmBAA',
'ext': 'mp4',
'title': 'SCC2019_Talk_Tychsen_TXL.mp4',
'thumbnail': r're:(?i)https://.*\.jpeg',
},
},
]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
thumbnail = self._search_regex(
r'\"thumbnailUrl\":\"(?P<thumbnail>[^\"]+)',
webpage, 'thumbnail', group='thumbnail',
default=None)
2023-01-21 00:10:22 +00:00
2023-01-21 19:27:41 +00:00
title = self._search_regex(r'"name"\s*:\s*"((?:\\"|[^"])+)', webpage, 'title')
2023-01-21 00:10:22 +00:00
2023-01-21 19:27:41 +00:00
manifest_url = self._search_regex(r'"contentUrl"\s*:\s*"((?:\\"|[^"])+)', webpage, 'manifest_url')
manifest_url = urljoin(url, manifest_url)
2023-01-21 00:10:22 +00:00
2023-01-21 19:27:41 +00:00
formats = []
if manifest_url and determine_ext(manifest_url) == 'm3u8':
2023-01-21 00:10:22 +00:00
formats.extend(self._extract_m3u8_formats(
compat_urlparse.urljoin(url, manifest_url),
video_id, 'mp4',
entry_protocol='m3u8_native', m3u8_id='m3u8'))
return {
'id': video_id,
'title': title,
'thumbnail': thumbnail,
'formats': formats,
}