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.
93 lines
3.2 KiB
Python
93 lines
3.2 KiB
Python
10 years ago
|
# coding: utf-8
|
||
|
from __future__ import unicode_literals
|
||
|
|
||
|
import re
|
||
|
|
||
|
from .common import InfoExtractor
|
||
10 years ago
|
from ..utils import ExtractorError
|
||
10 years ago
|
|
||
|
|
||
|
class Sport5IE(InfoExtractor):
|
||
9 years ago
|
_VALID_URL = r'https?://(?:www|vod)?\.sport5\.co\.il/.*\b(?:Vi|docID)=(?P<id>\d+)'
|
||
10 years ago
|
_TESTS = [
|
||
|
{
|
||
10 years ago
|
'url': 'http://vod.sport5.co.il/?Vc=147&Vi=176331&Page=1',
|
||
|
'info_dict': {
|
||
|
'id': 's5-Y59xx1-GUh2',
|
||
|
'ext': 'mp4',
|
||
10 years ago
|
'title': 'ולנסיה-קורדובה 0:3',
|
||
|
'description': 'אלקאסר, גאייה ופגולי סידרו לקבוצה של נונו ניצחון על קורדובה ואת המקום הראשון בליגה',
|
||
|
'duration': 228,
|
||
|
'categories': list,
|
||
|
},
|
||
|
'skip': 'Blocked outside of Israel',
|
||
10 years ago
|
}, {
|
||
|
'url': 'http://www.sport5.co.il/articles.aspx?FolderID=3075&docID=176372&lang=HE',
|
||
|
'info_dict': {
|
||
|
'id': 's5-SiXxx1-hKh2',
|
||
|
'ext': 'mp4',
|
||
10 years ago
|
'title': 'GOALS_CELTIC_270914.mp4',
|
||
|
'description': '',
|
||
|
'duration': 87,
|
||
|
'categories': list,
|
||
|
},
|
||
|
'skip': 'Blocked outside of Israel',
|
||
10 years ago
|
}
|
||
|
]
|
||
|
|
||
|
def _real_extract(self, url):
|
||
|
mobj = re.match(self._VALID_URL, url)
|
||
10 years ago
|
media_id = mobj.group('id')
|
||
10 years ago
|
|
||
10 years ago
|
webpage = self._download_webpage(url, media_id)
|
||
10 years ago
|
|
||
8 years ago
|
video_id = self._html_search_regex(r'clipId=([\w-]+)', webpage, 'video id')
|
||
10 years ago
|
|
||
10 years ago
|
metadata = self._download_xml(
|
||
|
'http://sport5-metadata-rr-d.nsacdn.com/vod/vod/%s/HDS/metadata.xml' % video_id,
|
||
|
video_id)
|
||
10 years ago
|
|
||
10 years ago
|
error = metadata.find('./Error')
|
||
|
if error is not None:
|
||
|
raise ExtractorError(
|
||
|
'%s returned error: %s - %s' % (
|
||
|
self.IE_NAME,
|
||
|
error.find('./Name').text,
|
||
|
error.find('./Description').text),
|
||
|
expected=True)
|
||
10 years ago
|
|
||
10 years ago
|
title = metadata.find('./Title').text
|
||
|
description = metadata.find('./Description').text
|
||
|
duration = int(metadata.find('./Duration').text)
|
||
10 years ago
|
|
||
10 years ago
|
posters_el = metadata.find('./PosterLinks')
|
||
|
thumbnails = [{
|
||
|
'url': thumbnail.text,
|
||
|
'width': int(thumbnail.get('width')),
|
||
|
'height': int(thumbnail.get('height')),
|
||
|
} for thumbnail in posters_el.findall('./PosterIMG')] if posters_el is not None else []
|
||
|
|
||
|
categories_el = metadata.find('./Categories')
|
||
|
categories = [
|
||
|
cat.get('name') for cat in categories_el.findall('./Category')
|
||
|
] if categories_el is not None else []
|
||
10 years ago
|
|
||
10 years ago
|
formats = [{
|
||
|
'url': fmt.text,
|
||
|
'ext': 'mp4',
|
||
|
'vbr': int(fmt.get('bitrate')),
|
||
|
'width': int(fmt.get('width')),
|
||
|
'height': int(fmt.get('height')),
|
||
|
} for fmt in metadata.findall('./PlaybackLinks/FileURL')]
|
||
10 years ago
|
self._sort_formats(formats)
|
||
|
|
||
|
return {
|
||
10 years ago
|
'id': video_id,
|
||
10 years ago
|
'title': title,
|
||
10 years ago
|
'description': description,
|
||
|
'thumbnails': thumbnails,
|
||
10 years ago
|
'duration': duration,
|
||
10 years ago
|
'categories': categories,
|
||
10 years ago
|
'formats': formats,
|
||
10 years ago
|
}
|