mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-23 16:36:48 +00:00
Merge branch 'lenaten-sport5'
This commit is contained in:
commit
b3ac3a51ac
@ -1250,12 +1250,13 @@ class YoutubeDL(object):
|
|||||||
# urllib chokes on URLs with non-ASCII characters (see http://bugs.python.org/issue3991)
|
# urllib chokes on URLs with non-ASCII characters (see http://bugs.python.org/issue3991)
|
||||||
# To work around aforementioned issue we will replace request's original URL with
|
# To work around aforementioned issue we will replace request's original URL with
|
||||||
# percent-encoded one
|
# percent-encoded one
|
||||||
url = req if isinstance(req, compat_str) else req.get_full_url()
|
req_is_string = isinstance(req, basestring)
|
||||||
|
url = req if req_is_string else req.get_full_url()
|
||||||
url_escaped = escape_url(url)
|
url_escaped = escape_url(url)
|
||||||
|
|
||||||
# Substitute URL if any change after escaping
|
# Substitute URL if any change after escaping
|
||||||
if url != url_escaped:
|
if url != url_escaped:
|
||||||
if isinstance(req, compat_str):
|
if req_is_string:
|
||||||
req = url_escaped
|
req = url_escaped
|
||||||
else:
|
else:
|
||||||
req = compat_urllib_request.Request(
|
req = compat_urllib_request.Request(
|
||||||
|
@ -340,6 +340,7 @@ from .spiegel import SpiegelIE, SpiegelArticleIE
|
|||||||
from .spiegeltv import SpiegeltvIE
|
from .spiegeltv import SpiegeltvIE
|
||||||
from .spike import SpikeIE
|
from .spike import SpikeIE
|
||||||
from .sportdeutschland import SportDeutschlandIE
|
from .sportdeutschland import SportDeutschlandIE
|
||||||
|
from .sport5 import Sport5IE
|
||||||
from .stanfordoc import StanfordOpenClassroomIE
|
from .stanfordoc import StanfordOpenClassroomIE
|
||||||
from .steam import SteamIE
|
from .steam import SteamIE
|
||||||
from .streamcloud import StreamcloudIE
|
from .streamcloud import StreamcloudIE
|
||||||
|
92
youtube_dl/extractor/sport5.py
Normal file
92
youtube_dl/extractor/sport5.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
from .common import InfoExtractor
|
||||||
|
from ..utils import ExtractorError
|
||||||
|
|
||||||
|
|
||||||
|
class Sport5IE(InfoExtractor):
|
||||||
|
_VALID_URL = r'http://(?:www|vod)?\.sport5\.co\.il/.*\b(?:Vi|docID)=(?P<id>\d+)'
|
||||||
|
_TESTS = [
|
||||||
|
{
|
||||||
|
'url': 'http://vod.sport5.co.il/?Vc=147&Vi=176331&Page=1',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 's5-Y59xx1-GUh2',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'ולנסיה-קורדובה 0:3',
|
||||||
|
'description': 'אלקאסר, גאייה ופגולי סידרו לקבוצה של נונו ניצחון על קורדובה ואת המקום הראשון בליגה',
|
||||||
|
'duration': 228,
|
||||||
|
'categories': list,
|
||||||
|
},
|
||||||
|
'skip': 'Blocked outside of Israel',
|
||||||
|
}, {
|
||||||
|
'url': 'http://www.sport5.co.il/articles.aspx?FolderID=3075&docID=176372&lang=HE',
|
||||||
|
'info_dict': {
|
||||||
|
'id': 's5-SiXxx1-hKh2',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'GOALS_CELTIC_270914.mp4',
|
||||||
|
'description': '',
|
||||||
|
'duration': 87,
|
||||||
|
'categories': list,
|
||||||
|
},
|
||||||
|
'skip': 'Blocked outside of Israel',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
def _real_extract(self, url):
|
||||||
|
mobj = re.match(self._VALID_URL, url)
|
||||||
|
media_id = mobj.group('id')
|
||||||
|
|
||||||
|
webpage = self._download_webpage(url, media_id)
|
||||||
|
|
||||||
|
video_id = self._html_search_regex('clipId=([\w-]+)', webpage, 'video id')
|
||||||
|
|
||||||
|
metadata = self._download_xml(
|
||||||
|
'http://sport5-metadata-rr-d.nsacdn.com/vod/vod/%s/HDS/metadata.xml' % video_id,
|
||||||
|
video_id)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
title = metadata.find('./Title').text
|
||||||
|
description = metadata.find('./Description').text
|
||||||
|
duration = int(metadata.find('./Duration').text)
|
||||||
|
|
||||||
|
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 []
|
||||||
|
|
||||||
|
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')]
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'id': video_id,
|
||||||
|
'title': title,
|
||||||
|
'description': description,
|
||||||
|
'thumbnails': thumbnails,
|
||||||
|
'duration': duration,
|
||||||
|
'categories': categories,
|
||||||
|
'formats': formats,
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user