0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-19 01:45:13 +00:00
This commit is contained in:
geauxlo 2020-06-10 06:42:44 +00:00 committed by GitHub
parent 66c498e558
commit 33afd662d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,6 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
from ..compat import ( from ..compat import (
compat_parse_qs, compat_parse_qs,
@ -14,9 +12,7 @@
class ScreencastIE(InfoExtractor): class ScreencastIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?screencast\.com/(?:t|users/[^/]+/folders/[^/]+/media)/(?P<id>[a-zA-Z0-9\-]+)' _VALID_URL = r'https?://(?:www\.)?screencast\.com/t/(?P<id>[a-zA-Z0-9]+)'
_API_URL = 'https://www.screencast.com/api/external/oembed?url=%s&format=json'
_TESTS = [{ _TESTS = [{
'url': 'http://www.screencast.com/t/3ZEjQXlT', 'url': 'http://www.screencast.com/t/3ZEjQXlT',
'md5': '917df1c13798a3e96211dd1561fded83', 'md5': '917df1c13798a3e96211dd1561fded83',
@ -60,46 +56,17 @@ class ScreencastIE(InfoExtractor):
}, { }, {
'url': 'http://screencast.com/t/aAB3iowa', 'url': 'http://screencast.com/t/aAB3iowa',
'only_matching': True, 'only_matching': True,
}, {
'url': 'https://www.screencast.com/users/cindyhailes/folders/Jing/media/c9be177c-5808-4c4f-af56-eadceb3a7c82',
'md5': '589d37a28d2add53c8bf16b9126d9dc2',
'info_dict': {
'id': 'c9be177c-5808-4c4f-af56-eadceb3a7c82',
'ext': 'swf',
'title': '2020-05-31_1737',
'description': 'Shared from Screencast.com',
'thumbnail': r're:^https?://.*\.(?:gif|jpg)$',
}
}] }]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
# The JSON given by the API has a thumbnail URL,
# but it's inferior to the webpage's thumbnail.
# It also has no video description, so we
# definitely still need to get the webpage.
info = self._download_json(
self._API_URL % url, video_id,
'Downloading video info JSON')
video_url = info.get('url')
if video_url != None:
video_url_raw = compat_urllib_request.quote(video_url)
video_url = re.sub(r'^(?P<proto>https|http)%3A',
lambda match: '%s:' % match.group('proto'),
video_url_raw)
title = info.get('title')
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
if video_url == None:
video_url = self._html_search_regex( video_url = self._html_search_regex(
r'<embed name="Video".*?src="([^"]+)"', webpage, r'<embed name="Video".*?src="([^"]+)"', webpage,
'QuickTime embed', default=None) 'QuickTime embed', default=None)
if video_url == None: if video_url is None:
flash_vars_s = self._html_search_regex( flash_vars_s = self._html_search_regex(
r'<param name="flashVars" value="([^"]+)"', webpage, 'flash vars', r'<param name="flashVars" value="([^"]+)"', webpage, 'flash vars',
default=None) default=None)
@ -113,11 +80,9 @@ def _real_extract(self, url):
flash_vars = compat_parse_qs(flash_vars_s) flash_vars = compat_parse_qs(flash_vars_s)
video_url_raw = compat_urllib_request.quote( video_url_raw = compat_urllib_request.quote(
flash_vars['content'][0]) flash_vars['content'][0])
video_url = re.sub(r'^(?P<proto>http|https)%3A', video_url = video_url_raw.replace('http%3A', 'http:')
lambda match: '%s:' % match.group('proto'),
video_url_raw)
if video_url == None: if video_url is None:
video_meta = self._html_search_meta( video_meta = self._html_search_meta(
'og:video', webpage, default=None) 'og:video', webpage, default=None)
if video_meta: if video_meta:
@ -125,31 +90,28 @@ def _real_extract(self, url):
r'src=(.*?)(?:$|&)', video_meta, r'src=(.*?)(?:$|&)', video_meta,
'meta tag video URL', default=None) 'meta tag video URL', default=None)
if video_url == None: if video_url is None:
video_url = self._html_search_regex( video_url = self._html_search_regex(
r'MediaContentUrl["\']\s*:(["\'])(?P<url>(?:(?!\1).)+)\1', r'MediaContentUrl["\']\s*:(["\'])(?P<url>(?:(?!\1).)+)\1',
webpage, 'video url', default=None, group='url') webpage, 'video url', default=None, group='url')
if video_url == None: if video_url is None:
video_url = self._html_search_meta( video_url = self._html_search_meta(
'og:video', webpage, default=None) 'og:video', webpage, default=None)
if video_url == None: if video_url is None:
raise ExtractorError('Cannot find video') raise ExtractorError('Cannot find video')
if title == None:
title = self._og_search_title(webpage, default=None) title = self._og_search_title(webpage, default=None)
if title is None:
if title == None:
title = self._html_search_regex( title = self._html_search_regex(
[r'<b>Title:</b> ([^<]+)</div>', [r'<b>Title:</b> ([^<]+)</div>',
r'class="tabSeperator">></span><span class="tabText">(.+?)<', r'class="tabSeperator">></span><span class="tabText">(.+?)<',
r'<title>([^<]+)</title>'], r'<title>([^<]+)</title>'],
webpage, 'title') webpage, 'title')
thumbnail = self._og_search_thumbnail(webpage) thumbnail = self._og_search_thumbnail(webpage)
description = self._og_search_description(webpage, default=None) description = self._og_search_description(webpage, default=None)
if description == None: if description is None:
description = self._html_search_meta('description', webpage) description = self._html_search_meta('description', webpage)
return { return {