mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-11 07:07:46 +08:00
Merge branch 'master' into fix.25.12.2018
This commit is contained in:
commit
8f371686d2
@ -632,7 +632,10 @@ from .massengeschmacktv import MassengeschmackTVIE
|
||||
from .matchtv import MatchTVIE
|
||||
from .mdr import MDRIE
|
||||
from .mediaset import MediasetIE
|
||||
from .mediasite import MediasiteIE
|
||||
from .mediasite import (
|
||||
MediasiteIE,
|
||||
MediasiteCatalogIE,
|
||||
)
|
||||
from .medici import MediciIE
|
||||
from .megaphone import MegaphoneIE
|
||||
from .meipai import MeipaiIE
|
||||
@ -1114,6 +1117,7 @@ from .teachertube import (
|
||||
)
|
||||
from .teachingchannel import TeachingChannelIE
|
||||
from .teamcoco import TeamcocoIE
|
||||
from .teamtreehouse import TeamTreeHouseIE
|
||||
from .techtalks import TechTalksIE
|
||||
from .ted import TEDIE
|
||||
from .tele5 import Tele5IE
|
||||
|
@ -13,6 +13,8 @@ from ..utils import (
|
||||
ExtractorError,
|
||||
float_or_none,
|
||||
mimetype2ext,
|
||||
str_or_none,
|
||||
try_get,
|
||||
unescapeHTML,
|
||||
unsmuggle_url,
|
||||
url_or_none,
|
||||
@ -20,8 +22,11 @@ from ..utils import (
|
||||
)
|
||||
|
||||
|
||||
_ID_RE = r'[0-9a-f]{32,34}'
|
||||
|
||||
|
||||
class MediasiteIE(InfoExtractor):
|
||||
_VALID_URL = r'(?xi)https?://[^/]+/Mediasite/(?:Play|Showcase/(?:default|livebroadcast)/Presentation)/(?P<id>[0-9a-f]{32,34})(?P<query>\?[^#]+|)'
|
||||
_VALID_URL = r'(?xi)https?://[^/]+/Mediasite/(?:Play|Showcase/(?:default|livebroadcast)/Presentation)/(?P<id>%s)(?P<query>\?[^#]+|)' % _ID_RE
|
||||
_TESTS = [
|
||||
{
|
||||
'url': 'https://hitsmediaweb.h-its.org/mediasite/Play/2db6c271681e4f199af3c60d1f82869b1d',
|
||||
@ -109,7 +114,7 @@ class MediasiteIE(InfoExtractor):
|
||||
return [
|
||||
unescapeHTML(mobj.group('url'))
|
||||
for mobj in re.finditer(
|
||||
r'(?xi)<iframe\b[^>]+\bsrc=(["\'])(?P<url>(?:(?:https?:)?//[^/]+)?/Mediasite/Play/[0-9a-f]{32,34}(?:\?.*?)?)\1',
|
||||
r'(?xi)<iframe\b[^>]+\bsrc=(["\'])(?P<url>(?:(?:https?:)?//[^/]+)?/Mediasite/Play/%s(?:\?.*?)?)\1' % _ID_RE,
|
||||
webpage)]
|
||||
|
||||
def _real_extract(self, url):
|
||||
@ -221,3 +226,110 @@ class MediasiteIE(InfoExtractor):
|
||||
'formats': formats,
|
||||
'thumbnails': thumbnails,
|
||||
}
|
||||
|
||||
|
||||
class MediasiteCatalogIE(InfoExtractor):
|
||||
_VALID_URL = r'''(?xi)
|
||||
(?P<url>https?://[^/]+/Mediasite)
|
||||
/Catalog/Full/
|
||||
(?P<catalog_id>{0})
|
||||
(?:
|
||||
/(?P<current_folder_id>{0})
|
||||
/(?P<root_dynamic_folder_id>{0})
|
||||
)?
|
||||
'''.format(_ID_RE)
|
||||
_TESTS = [{
|
||||
'url': 'http://events7.mediasite.com/Mediasite/Catalog/Full/631f9e48530d454381549f955d08c75e21',
|
||||
'info_dict': {
|
||||
'id': '631f9e48530d454381549f955d08c75e21',
|
||||
'title': 'WCET Summit: Adaptive Learning in Higher Ed: Improving Outcomes Dynamically',
|
||||
},
|
||||
'playlist_count': 6,
|
||||
'expected_warnings': ['is not a supported codec'],
|
||||
}, {
|
||||
# with CurrentFolderId and RootDynamicFolderId
|
||||
'url': 'https://medaudio.medicine.iu.edu/Mediasite/Catalog/Full/9518c4a6c5cf4993b21cbd53e828a92521/97a9db45f7ab47428c77cd2ed74bb98f14/9518c4a6c5cf4993b21cbd53e828a92521',
|
||||
'info_dict': {
|
||||
'id': '9518c4a6c5cf4993b21cbd53e828a92521',
|
||||
'title': 'IUSM Family and Friends Sessions',
|
||||
},
|
||||
'playlist_count': 2,
|
||||
}, {
|
||||
'url': 'http://uipsyc.mediasite.com/mediasite/Catalog/Full/d5d79287c75243c58c50fef50174ec1b21',
|
||||
'only_matching': True,
|
||||
}, {
|
||||
# no AntiForgeryToken
|
||||
'url': 'https://live.libraries.psu.edu/Mediasite/Catalog/Full/8376d4b24dd1457ea3bfe4cf9163feda21',
|
||||
'only_matching': True,
|
||||
}, {
|
||||
'url': 'https://medaudio.medicine.iu.edu/Mediasite/Catalog/Full/9518c4a6c5cf4993b21cbd53e828a92521/97a9db45f7ab47428c77cd2ed74bb98f14/9518c4a6c5cf4993b21cbd53e828a92521',
|
||||
'only_matching': True,
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
mobj = re.match(self._VALID_URL, url)
|
||||
mediasite_url = mobj.group('url')
|
||||
catalog_id = mobj.group('catalog_id')
|
||||
current_folder_id = mobj.group('current_folder_id') or catalog_id
|
||||
root_dynamic_folder_id = mobj.group('root_dynamic_folder_id')
|
||||
|
||||
webpage = self._download_webpage(url, catalog_id)
|
||||
|
||||
# AntiForgeryToken is optional (e.g. [1])
|
||||
# 1. https://live.libraries.psu.edu/Mediasite/Catalog/Full/8376d4b24dd1457ea3bfe4cf9163feda21
|
||||
anti_forgery_token = self._search_regex(
|
||||
r'AntiForgeryToken\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
|
||||
webpage, 'anti forgery token', default=None, group='value')
|
||||
if anti_forgery_token:
|
||||
anti_forgery_header = self._search_regex(
|
||||
r'AntiForgeryHeaderName\s*:\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
|
||||
webpage, 'anti forgery header name',
|
||||
default='X-SOFO-AntiForgeryHeader', group='value')
|
||||
|
||||
data = {
|
||||
'IsViewPage': True,
|
||||
'IsNewFolder': True,
|
||||
'AuthTicket': None,
|
||||
'CatalogId': catalog_id,
|
||||
'CurrentFolderId': current_folder_id,
|
||||
'RootDynamicFolderId': root_dynamic_folder_id,
|
||||
'ItemsPerPage': 1000,
|
||||
'PageIndex': 0,
|
||||
'PermissionMask': 'Execute',
|
||||
'CatalogSearchType': 'SearchInFolder',
|
||||
'SortBy': 'Date',
|
||||
'SortDirection': 'Descending',
|
||||
'StartDate': None,
|
||||
'EndDate': None,
|
||||
'StatusFilterList': None,
|
||||
'PreviewKey': None,
|
||||
'Tags': [],
|
||||
}
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Referer': url,
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
}
|
||||
if anti_forgery_token:
|
||||
headers[anti_forgery_header] = anti_forgery_token
|
||||
|
||||
catalog = self._download_json(
|
||||
'%s/Catalog/Data/GetPresentationsForFolder' % mediasite_url,
|
||||
catalog_id, data=json.dumps(data).encode(), headers=headers)
|
||||
|
||||
entries = []
|
||||
for video in catalog['PresentationDetailsList']:
|
||||
if not isinstance(video, dict):
|
||||
continue
|
||||
video_id = str_or_none(video.get('Id'))
|
||||
if not video_id:
|
||||
continue
|
||||
entries.append(self.url_result(
|
||||
'%s/Play/%s' % (mediasite_url, video_id),
|
||||
ie=MediasiteIE.ie_key(), video_id=video_id))
|
||||
|
||||
title = try_get(
|
||||
catalog, lambda x: x['CurrentFolder']['Name'], compat_str)
|
||||
|
||||
return self.playlist_result(entries, catalog_id, title,)
|
||||
|
140
youtube_dl/extractor/teamtreehouse.py
Normal file
140
youtube_dl/extractor/teamtreehouse.py
Normal file
@ -0,0 +1,140 @@
|
||||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
clean_html,
|
||||
determine_ext,
|
||||
ExtractorError,
|
||||
float_or_none,
|
||||
get_element_by_class,
|
||||
get_element_by_id,
|
||||
parse_duration,
|
||||
remove_end,
|
||||
urlencode_postdata,
|
||||
urljoin,
|
||||
)
|
||||
|
||||
|
||||
class TeamTreeHouseIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://(?:www\.)?teamtreehouse\.com/library/(?P<id>[^/]+)'
|
||||
_TESTS = [{
|
||||
# Course
|
||||
'url': 'https://teamtreehouse.com/library/introduction-to-user-authentication-in-php',
|
||||
'info_dict': {
|
||||
'id': 'introduction-to-user-authentication-in-php',
|
||||
'title': 'Introduction to User Authentication in PHP',
|
||||
'description': 'md5:405d7b4287a159b27ddf30ca72b5b053',
|
||||
},
|
||||
'playlist_mincount': 24,
|
||||
}, {
|
||||
# WorkShop
|
||||
'url': 'https://teamtreehouse.com/library/deploying-a-react-app',
|
||||
'info_dict': {
|
||||
'id': 'deploying-a-react-app',
|
||||
'title': 'Deploying a React App',
|
||||
'description': 'md5:10a82e3ddff18c14ac13581c9b8e5921',
|
||||
},
|
||||
'playlist_mincount': 4,
|
||||
}, {
|
||||
# Video
|
||||
'url': 'https://teamtreehouse.com/library/application-overview-2',
|
||||
'info_dict': {
|
||||
'id': 'application-overview-2',
|
||||
'ext': 'mp4',
|
||||
'title': 'Application Overview',
|
||||
'description': 'md5:4b0a234385c27140a4378de5f1e15127',
|
||||
},
|
||||
'expected_warnings': ['This is just a preview'],
|
||||
}]
|
||||
_NETRC_MACHINE = 'teamtreehouse'
|
||||
|
||||
def _real_initialize(self):
|
||||
email, password = self._get_login_info()
|
||||
if email is None:
|
||||
return
|
||||
|
||||
signin_page = self._download_webpage(
|
||||
'https://teamtreehouse.com/signin',
|
||||
None, 'Downloading signin page')
|
||||
data = self._form_hidden_inputs('new_user_session', signin_page)
|
||||
data.update({
|
||||
'user_session[email]': email,
|
||||
'user_session[password]': password,
|
||||
})
|
||||
error_message = get_element_by_class('error-message', self._download_webpage(
|
||||
'https://teamtreehouse.com/person_session',
|
||||
None, 'Logging in', data=urlencode_postdata(data)))
|
||||
if error_message:
|
||||
raise ExtractorError(clean_html(error_message), expected=True)
|
||||
|
||||
def _real_extract(self, url):
|
||||
display_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, display_id)
|
||||
title = self._html_search_meta(['og:title', 'twitter:title'], webpage)
|
||||
description = self._html_search_meta(
|
||||
['description', 'og:description', 'twitter:description'], webpage)
|
||||
entries = self._parse_html5_media_entries(url, webpage, display_id)
|
||||
if entries:
|
||||
info = entries[0]
|
||||
|
||||
for subtitles in info.get('subtitles', {}).values():
|
||||
for subtitle in subtitles:
|
||||
subtitle['ext'] = determine_ext(subtitle['url'], 'srt')
|
||||
|
||||
is_preview = 'data-preview="true"' in webpage
|
||||
if is_preview:
|
||||
self.report_warning(
|
||||
'This is just a preview. You need to be signed in with a Basic account to download the entire video.', display_id)
|
||||
duration = 30
|
||||
else:
|
||||
duration = float_or_none(self._search_regex(
|
||||
r'data-duration="(\d+)"', webpage, 'duration'), 1000)
|
||||
if not duration:
|
||||
duration = parse_duration(get_element_by_id(
|
||||
'video-duration', webpage))
|
||||
|
||||
info.update({
|
||||
'id': display_id,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'duration': duration,
|
||||
})
|
||||
return info
|
||||
else:
|
||||
def extract_urls(html, extract_info=None):
|
||||
for path in re.findall(r'<a[^>]+href="([^"]+)"', html):
|
||||
page_url = urljoin(url, path)
|
||||
entry = {
|
||||
'_type': 'url_transparent',
|
||||
'id': self._match_id(page_url),
|
||||
'url': page_url,
|
||||
'id_key': self.ie_key(),
|
||||
}
|
||||
if extract_info:
|
||||
entry.update(extract_info)
|
||||
entries.append(entry)
|
||||
|
||||
workshop_videos = self._search_regex(
|
||||
r'(?s)<ul[^>]+id="workshop-videos"[^>]*>(.+?)</ul>',
|
||||
webpage, 'workshop videos', default=None)
|
||||
if workshop_videos:
|
||||
extract_urls(workshop_videos)
|
||||
else:
|
||||
stages_path = self._search_regex(
|
||||
r'(?s)<div[^>]+id="syllabus-stages"[^>]+data-url="([^"]+)"',
|
||||
webpage, 'stages path')
|
||||
if stages_path:
|
||||
stages_page = self._download_webpage(
|
||||
urljoin(url, stages_path), display_id, 'Downloading stages page')
|
||||
for chapter_number, (chapter, steps_list) in enumerate(re.findall(r'(?s)<h2[^>]*>\s*(.+?)\s*</h2>.+?<ul[^>]*>(.+?)</ul>', stages_page), 1):
|
||||
extract_urls(steps_list, {
|
||||
'chapter': chapter,
|
||||
'chapter_number': chapter_number,
|
||||
})
|
||||
title = remove_end(title, ' Course')
|
||||
|
||||
return self.playlist_result(
|
||||
entries, display_id, title, description)
|
@ -19,7 +19,7 @@ from ..utils import (
|
||||
|
||||
|
||||
class WeiboIE(InfoExtractor):
|
||||
_VALID_URL = r'https?://weibo\.com/[0-9]+/(?P<id>[a-zA-Z0-9]+)'
|
||||
_VALID_URL = r'https?://(?:www\.)?weibo\.com/[0-9]+/(?P<id>[a-zA-Z0-9]+)'
|
||||
_TEST = {
|
||||
'url': 'https://weibo.com/6275294458/Fp6RGfbff?type=comment',
|
||||
'info_dict': {
|
||||
|
@ -20,7 +20,7 @@ from ..utils import (
|
||||
class XHamsterIE(InfoExtractor):
|
||||
_VALID_URL = r'''(?x)
|
||||
https?://
|
||||
(?:.+?\.)?xhamster\.com/
|
||||
(?:.+?\.)?xhamster\.(?:com|one)/
|
||||
(?:
|
||||
movies/(?P<id>\d+)/(?P<display_id>[^/]*)\.html|
|
||||
videos/(?P<display_id_2>[^/]*)-(?P<id_2>\d+)
|
||||
@ -91,6 +91,9 @@ class XHamsterIE(InfoExtractor):
|
||||
# new URL schema
|
||||
'url': 'https://pt.xhamster.com/videos/euro-pedal-pumping-7937821',
|
||||
'only_matching': True,
|
||||
}, {
|
||||
'url': 'https://xhamster.one/videos/femaleagent-shy-beauty-takes-the-bait-1509445',
|
||||
'only_matching': True,
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
|
Loading…
x
Reference in New Issue
Block a user