2023-03-23 12:00:44 +00:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import unified_timestamp, parse_duration
|
|
|
|
|
|
|
|
|
|
|
|
class ChelseafcIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?chelseafc\.com(?:/[a-z]+)?/video/(?P<id>[a-z0-9]+(?:-[a-z0-9]+)*)'
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'https://www.chelseafc.com/en/video/full-match-chelsea-2-2-everton',
|
2023-04-02 10:28:44 +00:00
|
|
|
'md5': '16c0df4e6909ad5ae96eab68fc584d75',
|
2023-03-23 12:00:44 +00:00
|
|
|
'info_dict': {
|
|
|
|
'id': 'full-match-chelsea-2-2-everton',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Full Match: Chelsea 2-2 Everton',
|
2023-04-02 10:28:44 +00:00
|
|
|
'description': 'Full match highlights from Chelsea\'s 2-2 Premier League draw with Everton at Stamford Bridge.',
|
2023-03-23 12:00:44 +00:00
|
|
|
'duration': 2842.0,
|
|
|
|
'timestamp': 1679184000,
|
2023-04-02 10:28:44 +00:00
|
|
|
'tags': ['Premier League', 'Everton', 'Video and article choice'],
|
2023-03-23 12:00:44 +00:00
|
|
|
'upload_date': '20230319',
|
|
|
|
'thumbnail': r're:https?://.*\.png'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'url': 'https://www.chelseafc.com/en/video/manchester-city-vs-chelsea-2-0-or-highlights-or-efl-cup',
|
2023-04-02 10:28:44 +00:00
|
|
|
'md5': 'c20c52f3954d938bc5da4d6fe358c81d',
|
2023-03-23 12:00:44 +00:00
|
|
|
'info_dict': {
|
|
|
|
'id': 'manchester-city-vs-chelsea-2-0-or-highlights-or-efl-cup',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Manchester City 2-0 Chelsea | Highlights | EFL Cup',
|
|
|
|
'description': 'Highlights from our EFL Cup match against Man City.',
|
|
|
|
'duration': 120.0,
|
|
|
|
'timestamp': 1668042000,
|
|
|
|
'upload_date': '20221110',
|
2023-04-02 10:28:44 +00:00
|
|
|
'tags': ['Highlights', 'League Cup', 'Manchester City'],
|
2023-03-23 12:00:44 +00:00
|
|
|
'thumbnail': r're:https?://.*\.jpg'
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
2023-03-24 08:22:13 +00:00
|
|
|
video_details_div = self._search_regex(
|
|
|
|
r'(<div[^>]*\sdata-component\s*=\s*(?:"|\')\s*VideoDetails\s*(?:"|\')[^>]*>)',
|
2023-03-23 12:00:44 +00:00
|
|
|
webpage,
|
2023-03-24 08:22:13 +00:00
|
|
|
'div'
|
|
|
|
)
|
|
|
|
raw_data = self._html_search_regex(
|
|
|
|
r'<div[^>]*\sdata-props\s*=\s*(?:"|\')\s*([^"\']*)\s*(?:"|\')[^>]*>',
|
|
|
|
video_details_div,
|
2023-03-23 12:00:44 +00:00
|
|
|
'data'
|
|
|
|
)
|
2023-03-24 08:22:13 +00:00
|
|
|
|
2023-03-23 12:00:44 +00:00
|
|
|
data = json.loads(raw_data)['videoDetail']
|
|
|
|
|
|
|
|
manifest_url = data['signedUrl']
|
|
|
|
formats = self._extract_m3u8_formats(manifest_url, video_id, 'mp4')
|
|
|
|
|
|
|
|
title = data['title']
|
|
|
|
descripiton = data['description']
|
|
|
|
timestamp = unified_timestamp(data['releaseDate'])
|
|
|
|
duration = parse_duration(data['duration'])
|
|
|
|
tags = [tag['title'] for tag in data['tags']]
|
|
|
|
thumbnail = data['image']['file']['url']
|
|
|
|
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'description': descripiton,
|
|
|
|
'formats': formats,
|
|
|
|
'duration': duration,
|
|
|
|
'timestamp': timestamp,
|
|
|
|
'tags': tags,
|
|
|
|
'thumbnail': thumbnail
|
|
|
|
}
|