mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.8 KiB
Python
76 lines
2.8 KiB
Python
10 years ago
|
from .common import InfoExtractor
|
||
|
from ..utils import (
|
||
|
int_or_none,
|
||
|
unified_strdate,
|
||
|
)
|
||
|
|
||
|
|
||
|
class ExpoTVIE(InfoExtractor):
|
||
8 years ago
|
_VALID_URL = r'https?://(?:www\.)?expotv\.com/videos/[^?#]*/(?P<id>[0-9]+)($|[?#])'
|
||
10 years ago
|
_TEST = {
|
||
8 years ago
|
'url': 'http://www.expotv.com/videos/reviews/3/40/NYX-Butter-lipstick/667916',
|
||
|
'md5': 'fe1d728c3a813ff78f595bc8b7a707a8',
|
||
10 years ago
|
'info_dict': {
|
||
8 years ago
|
'id': '667916',
|
||
10 years ago
|
'ext': 'mp4',
|
||
8 years ago
|
'title': 'NYX Butter Lipstick Little Susie',
|
||
|
'description': 'Goes on like butter, but looks better!',
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||
8 years ago
|
'uploader': 'Stephanie S.',
|
||
|
'upload_date': '20150520',
|
||
|
'view_count': int,
|
||
10 years ago
|
}
|
||
|
}
|
||
|
|
||
|
def _real_extract(self, url):
|
||
8 years ago
|
video_id = self._match_id(url)
|
||
10 years ago
|
|
||
|
webpage = self._download_webpage(url, video_id)
|
||
|
player_key = self._search_regex(
|
||
|
r'<param name="playerKey" value="([^"]+)"', webpage, 'player key')
|
||
|
config = self._download_json(
|
||
9 years ago
|
'http://client.expotv.com/video/config/%s/%s' % (video_id, player_key),
|
||
|
video_id, 'Downloading video configuration')
|
||
10 years ago
|
|
||
9 years ago
|
formats = []
|
||
|
for fcfg in config['sources']:
|
||
9 years ago
|
media_url = fcfg.get('file')
|
||
|
if not media_url:
|
||
|
continue
|
||
|
if fcfg.get('type') == 'm3u8':
|
||
|
formats.extend(self._extract_m3u8_formats(
|
||
|
media_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls'))
|
||
9 years ago
|
else:
|
||
|
formats.append({
|
||
9 years ago
|
'url': media_url,
|
||
9 years ago
|
'height': int_or_none(fcfg.get('height')),
|
||
|
'format_id': fcfg.get('label'),
|
||
|
'ext': self._search_regex(
|
||
9 years ago
|
r'filename=.*\.([a-z0-9_A-Z]+)&', media_url,
|
||
|
'file extension', default=None) or fcfg.get('type'),
|
||
9 years ago
|
})
|
||
10 years ago
|
self._sort_formats(formats)
|
||
|
|
||
|
title = self._og_search_title(webpage)
|
||
|
description = self._og_search_description(webpage)
|
||
|
thumbnail = config.get('image')
|
||
|
view_count = int_or_none(self._search_regex(
|
||
|
r'<h5>Plays: ([0-9]+)</h5>', webpage, 'view counts'))
|
||
|
uploader = self._search_regex(
|
||
|
r'<div class="reviewer">\s*<img alt="([^"]+)"', webpage, 'uploader',
|
||
|
fatal=False)
|
||
|
upload_date = unified_strdate(self._search_regex(
|
||
|
r'<h5>Reviewed on ([0-9/.]+)</h5>', webpage, 'upload date',
|
||
8 years ago
|
fatal=False), day_first=False)
|
||
10 years ago
|
|
||
|
return {
|
||
|
'id': video_id,
|
||
|
'formats': formats,
|
||
|
'title': title,
|
||
|
'description': description,
|
||
|
'view_count': view_count,
|
||
|
'thumbnail': thumbnail,
|
||
|
'uploader': uploader,
|
||
|
'upload_date': upload_date,
|
||
|
}
|