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.
57 lines
2.1 KiB
Python
57 lines
2.1 KiB
Python
11 years ago
|
from __future__ import unicode_literals
|
||
|
|
||
11 years ago
|
import re
|
||
|
import json
|
||
|
|
||
|
from .common import InfoExtractor
|
||
10 years ago
|
from ..compat import (
|
||
11 years ago
|
compat_urlparse,
|
||
10 years ago
|
)
|
||
|
from ..utils import (
|
||
11 years ago
|
ExtractorError,
|
||
9 years ago
|
get_element_by_id,
|
||
11 years ago
|
)
|
||
|
|
||
|
|
||
|
class SlideshareIE(InfoExtractor):
|
||
8 years ago
|
_VALID_URL = r'https?://(?:www\.)?slideshare\.net/[^/]+?/(?P<title>.+?)($|\?)'
|
||
11 years ago
|
|
||
|
_TEST = {
|
||
11 years ago
|
'url': 'http://www.slideshare.net/Dataversity/keynote-presentation-managing-scale-and-complexity',
|
||
|
'info_dict': {
|
||
|
'id': '25665706',
|
||
|
'ext': 'mp4',
|
||
|
'title': 'Managing Scale and Complexity',
|
||
|
'description': 'This was a keynote presentation at the NoSQL Now! 2013 Conference & Expo (http://www.nosqlnow.com). This presentation was given by Adrian Cockcroft from Netflix.',
|
||
11 years ago
|
},
|
||
|
}
|
||
|
|
||
|
def _real_extract(self, url):
|
||
|
mobj = re.match(self._VALID_URL, url)
|
||
|
page_title = mobj.group('title')
|
||
|
webpage = self._download_webpage(url, page_title)
|
||
|
slideshare_obj = self._search_regex(
|
||
8 years ago
|
r'\$\.extend\(.*?slideshare_object,\s*(\{.*?\})\);',
|
||
11 years ago
|
webpage, 'slideshare object')
|
||
11 years ago
|
info = json.loads(slideshare_obj)
|
||
11 years ago
|
if info['slideshow']['type'] != 'video':
|
||
|
raise ExtractorError('Webpage type is "%s": only video extraction is supported for Slideshare' % info['slideshow']['type'], expected=True)
|
||
11 years ago
|
|
||
|
doc = info['doc']
|
||
|
bucket = info['jsplayer']['video_bucket']
|
||
|
ext = info['jsplayer']['video_extension']
|
||
|
video_url = compat_urlparse.urljoin(bucket, doc + '-SD.' + ext)
|
||
9 years ago
|
description = get_element_by_id('slideshow-description-paragraph', webpage) or self._html_search_regex(
|
||
10 years ago
|
r'(?s)<p[^>]+itemprop="description"[^>]*>(.+?)</p>', webpage,
|
||
11 years ago
|
'description', fatal=False)
|
||
11 years ago
|
|
||
|
return {
|
||
|
'_type': 'video',
|
||
|
'id': info['slideshow']['id'],
|
||
|
'title': info['slideshow']['title'],
|
||
|
'ext': ext,
|
||
|
'url': video_url,
|
||
|
'thumbnail': info['slideshow']['pin_image_url'],
|
||
9 years ago
|
'description': description.strip() if description else None,
|
||
11 years ago
|
}
|